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

feat[test]: add hevm harness for venom passes #4460

Merged

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jan 21, 2025

What I did

How I did it

How to verify it

Commit message

this commit adds `hevm` as a harness to some venom tests. to accomplish
this, it adds a new venom instruction "sink", which in the new
`hevm_check_venom` function gets compiled to a `return` instruction
so that hevm can check the returndata for equivalence. this allows us
to rely on bytecode equivalence of the compiled code to "prove" our
optimizations are sound.

the new pattern has been applied to the tests in
`test_algebraic_binopt.py` as a first pass, but it can (and should) be
applied to more venom tests in the future. and `hevm=False` kwarg has
been added for some cases where hevm cannot resolve the equivalence.

an hevm harness could also be added to vyper sources, but that is out
of scope for this PR and left for future work.

references:
- https://github.com/ethereum/hevm

Description for the changelog

Cute Animal Picture

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

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.09%. Comparing base (1aaa78e) to head (bed64d6).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
vyper/venom/venom_to_assembly.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4460      +/-   ##
==========================================
- Coverage   92.11%   92.09%   -0.02%     
==========================================
  Files         119      119              
  Lines       16933    16936       +3     
  Branches     2865     2866       +1     
==========================================
+ Hits        15597    15598       +1     
- Misses        917      919       +2     
  Partials      419      419              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@charles-cooper charles-cooper force-pushed the feat/venom/hevm-equivalence branch from ab27245 to 1e02f4c Compare January 31, 2025 21:57
@charles-cooper charles-cooper marked this pull request as ready for review January 31, 2025 21:57
self.updater._update(inst, "eq", [operands[1], IRLiteral(never)])
# canary:
# self.updater._update(inst, "eq", [operands[1], IRLiteral(lo)])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want to leave this here or could be revert this?

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'll leave it for people to review then remove

tests/hevm.py Outdated
ctx = parse_from_basic_block(venom_source_code)

num_calldataloads = 0
num_return_values = 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

you could remove this one right (num_return_values)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, looks like it

@charles-cooper charles-cooper enabled auto-merge (squash) February 6, 2025 13:57
@charles-cooper charles-cooper merged commit ebd1c41 into vyperlang:master Feb 6, 2025
159 checks passed
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.

3 participants