test: Add 64 byte test cases for SHA256 and RIPEMD160 precompile benchmarks#2801
Merged
felix314159 merged 1 commit intoethereum:forks/amsterdamfrom May 5, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2801 +/- ##
================================================
Coverage 88.17% 88.17%
================================================
Files 577 577
Lines 35659 35659
Branches 3490 3490
================================================
Hits 31442 31442
Misses 3654 3654
Partials 563 563
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
benchmarks/compute/precompile/test_ripemd160.py: Add 64 byte test cases. Due to how, internally, padding+splitting into blocks (of 64bytes) in the actual hash functions works, even multiples of 32bytes behave slightly differently wrt. gas pricing. So we need to add a 64byte test case here.
69f26d3 to
8d18048
Compare
felix314159
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
benchmarks/compute/precompile/test_ripemd160.py: Add 64 byte test cases.
Due to how, internally, padding+splitting into blocks (of 64bytes) in the actual hash functions works, even multiples of 32bytes behave slightly differently wrt. gas pricing. So we need to add a 64byte test case here.
🗒️ Description
This just adds a 64 byte test case (to the existing list) to the relevant hash function precompile benchmarks.
🔗 Related Issues or PRs
Internally, both SHA256 and RIPEMD160 start input processing by padding (to store the length and to align the size with the internal blocksize) and then chopping the result into 64byte blocks. Each block is then processed sequentially. As a consequence, both 0byte and 32byte inputs result in 1 block, 64byte and 96byte inputs result in 2 blocks etc.
The number of such blocks largely determines the amount of actual work that needs to be done in hashing.
Since the gas consumed is computed on a 32byte granularity level (rather than the 64byte blocksize), the behaviour, for small input lengths, of
work_done/gas_consumed
may differ for even and odd multiples of 32bytes. The worst-case should be EVEN multiples.
Consequently, we should add a 64byte test case to cover this.
See STEEL discord benchmarking/Cryptography precompile worst case
✅ Checklist
just statictype(scope):.