-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Bytecode difference caused by SSA transform #14968
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
Conversation
|
Are there any tests for non-determinism like running in a loop and checking that each compilation of the same source unit results in the same bytecode? |
What you're describing is fully deterministic already - i.e. the same sources will always compile to the same bytecode - the issue here is of a different sort; we use a ton of associative containers (e.g. a These inconsistencies don't actually change the behavior of contracts - the code will semantically remain the same, but the bytecode in such cases should none the less be identical, especially when it comes to source verification. |
11b27e3 to
b423c2a
Compare
|
Given how easy it is to inadvertently run into this problem when using |
b423c2a to
a031490
Compare
a031490 to
972c464
Compare
5148ff3 to
7b86576
Compare
843b813 to
6822901
Compare
test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/test.py
Outdated
Show resolved
Hide resolved
test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/test.py
Outdated
Show resolved
Hide resolved
scripts/common/cmdline_helpers.py
Outdated
| via_ir: bool, | ||
| optimize: bool = False, | ||
| yul_optimizations: Optional[str] = None) -> FileReport: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a note, so we can remember to eventually refactor this. We could pass a dictionary here like what was done in https://github.com/ethereum/solidity/blob/bbb7f58be026fdc51b0b4694a6f25c22a1425586/scripts/externalTests/test_helpers.py#L52 or event have a class for compiler settings so we could reuse in other scripts. I believe this will be desirable when we migrate the external tests to python.
b4a8906 to
df5229e
Compare
|
@cameel this should be ready now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in terms of correctness, just needs two style tweaks.
test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/test.py
Outdated
Show resolved
Hide resolved
Changelog Review comments Unique vector Repro test
df5229e to
7f882ef
Compare
| template<typename T> | ||
| void swap(UniqueVector<T>& _lhs, UniqueVector<T>& _rhs) | ||
| { | ||
| std::swap(_lhs.contents(), _rhs.contents()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just looking at this to consider using it for #15262 and noticed: this swap function won't work, will it? contents is a const reference, you can't swap these things...
what the std::swap below will do is to use the implicit move constructors of UniqueVector...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right, contents() should ideally just return a reference...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have honestly expected a compilation error here, this is really insidious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, it's currently unused - and C++ only type-checks on instantiation :-). And I mean, it's not unused without reason: we don't need it, so we might as well remove the swap - std::swap will just work based on moving regardless
Fixes #14829