Skip to content

zkevm: add remaining precompiles #1581

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 19 commits into from
May 21, 2025
Merged

zkevm: add remaining precompiles #1581

merged 19 commits into from
May 21, 2025

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented May 9, 2025

This PR adds coverage for all remaining precompiles:

  • bn128_add
  • bn128_mul
  • bn128_pairing
  • blake2f
  • point_evaluation
  • All seven new BLS precompiles activated in Pectra.

I created a generic setup, so adding other precompile cases (if anyone thinks other inputs create even worse-case scenarios) is very simple.

I ran this in the SP1 for counting cycles:

  • bls12_fp_to_g1 -> 2.3 billion cycles
  • bls12_fp_to_g2 -> 2.4 billion cycles
  • bls12_g1add -> 2.4 billion cycles
  • bls12_g1msm -> Crash
  • bls12_g2add -> 2.5 billion cycles
  • bls12_g2msm -> Crash
  • bls12_pairing -> 2.4 billion cycles
  • bn128_add -> 18.5 billion cycles
  • bn128_mul -> 28.5 billion cycles
  • bn128_pairing -> 18.6 billion cycles
  • point_evaluation -> 6.8 billion cycles
  • blake2f -> 21 billion cycles

@jsign jsign force-pushed the jsign-more-precompiles branch 2 times, most recently from 63ae656 to d732c83 Compare May 13, 2025 18:18
@jsign jsign force-pushed the jsign-zkvm-ecrecover branch from 7376d45 to 100a25e Compare May 13, 2025 18:19
@jsign jsign force-pushed the jsign-more-precompiles branch from d732c83 to 1ff3fa6 Compare May 13, 2025 18:39
@chfast chfast added scope:tests Scope: Changes EL client test cases in `./tests` feature:zkevm labels May 14, 2025
@jsign jsign force-pushed the jsign-zkvm-ecrecover branch from 100a25e to 97de8f5 Compare May 15, 2025 11:56
Base automatically changed from jsign-zkvm-ecrecover to main May 16, 2025 15:43
@jsign jsign force-pushed the jsign-more-precompiles branch 2 times, most recently from 8aa3517 to dcebcf9 Compare May 16, 2025 18:13
@jsign jsign force-pushed the jsign-more-precompiles branch from 774fab7 to d52d458 Compare May 16, 2025 19:04
@jsign
Copy link
Collaborator Author

jsign commented May 16, 2025

@chfast, I applied your suggestions if you'd like to take another look.
Cycles remained the same for everything, but now both MSM make the SP1 RISCV emulator crash :)

@jsign jsign marked this pull request as ready for review May 16, 2025 19:32
@jsign jsign requested review from chfast and raxhvl May 16, 2025 19:32
@jsign jsign force-pushed the jsign-more-precompiles branch from cbed263 to 16f5eae Compare May 16, 2025 19:49
jsign added 9 commits May 20, 2025 13:28
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
jsign added 7 commits May 20, 2025 13:29
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
@jsign jsign force-pushed the jsign-more-precompiles branch from 16f5eae to d9bd7a5 Compare May 20, 2025 16:37
@jsign jsign requested a review from marioevz May 20, 2025 21:21
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.

I left two questions/comments I'd like to see address. But overall looks good to me.

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
@jsign jsign merged commit f14624b into main May 21, 2025
26 checks passed
@jsign jsign deleted the jsign-more-precompiles branch May 21, 2025 15:09
codeofcarson pushed a commit to codeofcarson/execution-spec-tests that referenced this pull request Jul 1, 2025
* zkevm: more precompiles

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* improve params format

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* improve parameters

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* add bls12_g1msm

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* add bls12_g2msm

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* add blas12 pairing check

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* add bls_map tests

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* rebase & format

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* remove input length parameter

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* use bls12381 precompile addresses from spec and simplify parameter

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* make the linter happy

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* use symbolic parameters for bls12381 precompiles

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* lints

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* linter

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* add slow marker

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* rebase fixes

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* reuse some constants and precompile inputs

* comments and fixes

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* clarify comment

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

---------

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Paweł Bylica <pawel@ethereum.org>
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.

3 participants