Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix[tool]: fix output formats for .vyz files #4338

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

charles-cooper
Copy link
Member

run the format name through the translate map. for instance, -f annotated_ast was not working for .vyz files.

What I did

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

run the format name through the translate map. for instance,
`-f annotated_ast` was not working for `.vyz` files.
@charles-cooper charles-cooper added this to the v0.4.1 milestone Oct 28, 2024
@charles-cooper charles-cooper added the release - must release blocker label Oct 28, 2024
@cyberthirst
Copy link
Collaborator

cyberthirst commented Nov 1, 2024

let's add this

def test_archive_compile_options(input_files):
    tmpdir, _, _, contract_file = input_files
    search_paths = [".", tmpdir]

    options = ["abi_python", "json", "ast", "annotated_ast", "ir_json"]

    for option in options:
        out = compile_files([contract_file], ["archive_b64", option], paths=search_paths)

        archive_b64 = out[contract_file].pop("archive_b64")

        archive_path = Path("foo.zip.b64")
        with archive_path.open("w") as f:
            f.write(archive_b64)

        # compare compiling the two input bundles
        out2 = compile_files([archive_path], [option])

        if option in ["ast", "annotated_ast"]:
            # would have to normalize paths and imports, so just verify it compiles
            continue

        assert out[contract_file] == out2[archive_path]

@charles-cooper charles-cooper requested review from cyberthirst and removed request for cyberthirst November 21, 2024 07:43
continue

if option in ["ir_runtime", "ir", "asm", "archive", "solc_json"]:
# TODO investigate why these don't pass the assert
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the should be correct, but would like to explore this before approving

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suspect that has to do with codegen.reset_names(), which was fixed in 8f433f8

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf. as well: vyper/ir/compile_ir.py:_next_symbol may need to be reset.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assembly one should be fixed here: e09f589

the others might need a bit more investigation. but i think the important thing here is that the bytecode output and integrity hashes are the same; if some metadata is different that is not such a big deal.

Copy link
Collaborator

@cyberthirst cyberthirst Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugged this a bit further and got the following:

def _eq_helper(ir1, ir2):
    assert isinstance(ir1, IRnode) and isinstance(ir2, IRnode)
    for n1, n2 in zip(ir1.args, ir2.args):
        if n1 != n2:
            if isinstance(n1, IRnode) and n1.value == "external_contract":
                print("value comparison:", n1.value == n2.value)
                print("args comparison:", n1.args == n2.args)
                print("typ comparison:", n1.typ == n2.typ)
                print("location comparison:", n1.location == n2.location)
                print("mutable comparison:", n1.mutable == n2.mutable)
                print("add_gas_estimate comparison:", n1.add_gas_estimate == n2.add_gas_estimate)
        if isinstance(n1, IRnode):
            _eq_helper(n1, n2

_eq_helper(out[contract_file]['ir_runtime'], out2[archive_path]['ir_runtime'])

output:

value comparison: True
args comparison: True
typ comparison: False
location comparison: True
mutable comparison: True
add_gas_estimate comparison: True

typ is InterfaceT where we don't have def __eq__(self, other): method but inherit from _UserType which defines:

    def __eq__(self, other):
        return self is other

edit: update formatting

these should have been failing before, but --debug was not getting
passed correctly to compiler phases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release - must release blocker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants