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: call graph stability #3370

Merged

Conversation

charles-cooper
Copy link
Member

the use of set (which does not guarantee order of its elements) instead of dict (which guarantees insertion order) led to instability across runs of the compiler between different versions of python. this commit patches the problem by using a derivation of dict to track the call graph instead of set.

What I did

fix #3369

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-->

the use of `set` (which does not guarantee order of its elements)
instead of `dict` (which guarantees insertion order) led to instability
across runs of the compiler between different versions of python. this
commit patches the problem by using a derivation of `dict` to track the
call graph instead of `set`.
@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2023

Codecov Report

Merging #3370 (81133dc) into master (7c3cf61) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3370      +/-   ##
==========================================
- Coverage   88.88%   88.73%   -0.15%     
==========================================
  Files          85       85              
  Lines       10706    10709       +3     
  Branches     2233     2233              
==========================================
- Hits         9516     9503      -13     
- Misses        788      805      +17     
+ Partials      402      401       -1     
Impacted Files Coverage Δ
vyper/semantics/types/function.py 84.70% <100.00%> (ø)
vyper/utils.py 83.25% <100.00%> (+0.25%) ⬆️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pcaversaccio
Copy link
Collaborator

It might be worth adding a unit & fuzz test here to guarantee that the ordering is always checked as part of the test suite in the future.

@charles-cooper
Copy link
Member Author

Will add a test for call graph stability before merging. Do we need other fuzz tests to check bytecode is stable (i.e. it could be influenced for other reasons besides call graph stability) or just checking the call graph is in a certain order is fine?

@pcaversaccio
Copy link
Collaborator

Maybe we should also check for ir and asm stability (and not only bytecode). In case some regression is introduced via a non-deterministic behaviour another time it might help to know whether ir, asm, and bytecode are failing all or not.

@charles-cooper
Copy link
Member Author

i mean we can, but if bytecode stability is being tested, checking ir and asm stability is overkill IMO. since whoever runs into those test failures will probably dig into the ir and asm anyways

@charles-cooper
Copy link
Member Author

@pcaversaccio added some tests, take a look?

Copy link
Collaborator

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

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

LGTM, just one comment: it might be useful to fuzz the built-in decorators (view, nonreentrant etc.) as well so we're sure that any of the current (and any future introduced) decorators don't affect the call graph stability. It should have no effect at all but such tests can prevent and/or detect future introduced regressions.

@charles-cooper charles-cooper enabled auto-merge (squash) May 4, 2023 18:52
@charles-cooper charles-cooper merged commit 5ae0a07 into vyperlang:master May 5, 2023
@charles-cooper charles-cooper deleted the fix/call_graph_stability branch July 21, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to reproduce bytecode between contract generated from docker and binary
4 participants