Skip to content

Conversation

@tserg
Copy link
Contributor

@tserg tserg commented Mar 24, 2025

What I did

We omitted to fold hexbytes for keccak and sha256 builtins.

The following example should compile but does not:

PROXY_CHILD_BYTECODE: constant(Bytes[16]) = x"67363d3d37363d34f03d5260086018f3"
PROXY_CHILD_BYTECODE_HASH: constant(bytes32) = keccak256(PROXY_CHILD_BYTECODE)
Error compiling: test.vy
vyper.exceptions.StateAccessViolation: Value must be a literal

  contract "test.vy:4", line 4:47 
       3 PROXY_CHILD_BYTECODE: constant(Bytes[16]) = x"67363d3d37363d34f03d5260086018f3"
  ---> 4 PROXY_CHILD_BYTECODE_HASH: constant(bytes32) = keccak256(PROXY_CHILD_BYTECODE)
  ------------------------------------------------------^
       5

How I did it

Handle HexBytes node when folding these builtins.

How to verify it

See new tests.

Commit message

This commit allows `keccak` and `sha256` of a constant hexbytes value
to be folded.

Description for the changelog

Fold keccak and sha256 of constant hexbytes.

Cute Animal Picture

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

@codecov
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.35%. Comparing base (61d259a) to head (68d0343).
Report is 87 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4536   +/-   ##
=======================================
  Coverage   92.35%   92.35%           
=======================================
  Files         123      123           
  Lines       17499    17499           
  Branches     2949     2949           
=======================================
  Hits        16162    16162           
  Misses        933      933           
  Partials      404      404           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

lgtm. paging @cyberthirst for review

@charles-cooper charles-cooper merged commit 6ed37b8 into vyperlang:master Mar 25, 2025
162 checks passed
@tserg tserg deleted the fix/keccak_hexbytes branch March 25, 2025 09:01
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