Skip to content

zkevm: add ECRECOVER, SHA2-256, IDENTITY and RIPEMD precompiles #1524

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

Merged
merged 12 commits into from
May 16, 2025

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented May 1, 2025

This PR:

  • Adds tests four new precompiles: ECRECOVER, SHA2-256, IDENTITY, and RIPEMD.
  • Removes zkevm pytest markers since the testing framework now automatically does this.
  • Uses Environment() configured gas limits, which are expected to be correctly set via the new --block-gas-limit filling flag.
  • I updated the CI pipeline to use 36M gas limit for filling.

Cycle counts in the new precompiles:

  • ECRECOVER: 682 million cycles
  • SHA2-256: 5.8 billion cycles
  • IDENTITY: 305 million cycles
  • RIPEMD: 360 million cycles

The last three are all part of a generic test since these precompiles have the same input parameter structure (i.e., data). The generic test automatically discovers the optimal input length for each case to amortize the static cost as much as possible against the quadratic cost of memory expansions. ECRECOVER is a separate test since the parameter input structure is particular.

@jsign jsign force-pushed the jsign-zkvm-ecrecover branch from d53e674 to bdfaa17 Compare May 1, 2025 21:53
@jsign jsign force-pushed the jsign-zkvm-modexp branch 2 times, most recently from b8d50b4 to 99f249d Compare May 5, 2025 22:27
Base automatically changed from jsign-zkvm-modexp to main May 5, 2025 22:38
@jsign jsign force-pushed the jsign-zkvm-ecrecover branch from bdfaa17 to d56f4ef Compare May 5, 2025 22:48
@jsign jsign changed the title zkevm: add ECRECOVER attack zkevm: add ECRECOVER, SHA2-256, IDENTITY and RIPEMD attacks May 6, 2025
@jsign jsign changed the title zkevm: add ECRECOVER, SHA2-256, IDENTITY and RIPEMD attacks zkevm: add ECRECOVER, SHA2-256, IDENTITY and RIPEMD precompiles May 6, 2025
@jsign jsign marked this pull request as ready for review May 6, 2025 17:38
@jsign jsign requested a review from marioevz May 6, 2025 17:38
Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

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

These are not zkevm specific but good general benchmarks for EVM. Can we make this framework for benchmarks a bit more generic? I'd like to contribute my existing benchmarks and more.

@jsign
Copy link
Collaborator Author

jsign commented May 8, 2025

@marioevz, can you take a look at this PR? Since I'm touching the filling command, I would prefer to have some quick check from you if sounds good!

@jsign jsign force-pushed the jsign-zkvm-ecrecover branch from 7376d45 to 100a25e Compare May 13, 2025 18:19
@chfast chfast added feature:zkevm scope:tests Scope: Changes EL client test cases in `./tests` labels May 14, 2025
jsign added 6 commits May 15, 2025 08:55
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
@jsign jsign force-pushed the jsign-zkvm-ecrecover branch from 100a25e to 97de8f5 Compare May 15, 2025 11:56
jsign added 3 commits May 15, 2025 08:57
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Two minor comments, thanks!

Signed-off-by: Ignacio Hagopian <[email protected]>
@raxhvl raxhvl merged commit 25f0012 into main May 16, 2025
22 checks passed
@raxhvl raxhvl deleted the jsign-zkvm-ecrecover branch May 16, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:zkevm scope:tests Scope: Changes EL client test cases in `./tests`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants