Skip to content

test: Add 64 byte test cases for SHA256 and RIPEMD160 precompile benchmarks#2801

Merged
felix314159 merged 1 commit intoethereum:forks/amsterdamfrom
GottfriedHerold:FixHashSizesInBenchmarks
May 5, 2026
Merged

test: Add 64 byte test cases for SHA256 and RIPEMD160 precompile benchmarks#2801
felix314159 merged 1 commit intoethereum:forks/amsterdamfrom
GottfriedHerold:FixHashSizesInBenchmarks

Conversation

@GottfriedHerold
Copy link
Copy Markdown
Contributor

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.17%. Comparing base (8fa9a05) to head (8d18048).

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           
Flag Coverage Δ
unittests 88.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

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.
@GottfriedHerold GottfriedHerold force-pushed the FixHashSizesInBenchmarks branch from 69f26d3 to 8d18048 Compare May 4, 2026 19:36
Copy link
Copy Markdown
Contributor

@kevaundray kevaundray left a comment

Choose a reason for hiding this comment

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

Thanks Gotti!

@felix314159 felix314159 merged commit 1f41b21 into ethereum:forks/amsterdam May 5, 2026
18 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