perf(sp1): fast path Reth precompiles - #61
Closed
figtracer wants to merge 6 commits into
Closed
Conversation
figtracer
force-pushed
the
fig/sp1-reth-modexp-fast-paths
branch
from
July 13, 2026 08:44
da4d5c4 to
5543f57
Compare
figtracer
marked this pull request as ready for review
July 13, 2026 10:00
figtracer
marked this pull request as draft
July 13, 2026 15:43
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.
Summary
Adds SP1-only optimizations to the Reth guest's precompile provider before its existing zkVM syscall fallback:
MODEXPpaths for common bounded operands and exponentsMODEXPandBLAKE2Fcallsstatelessimprovements from #30 and #31 via revision3d2fc17The Reth validation path still consumes and validates transaction public keys.
Ownership
This belongs in
ere-guestsbecause it selects SP1 syscall and cache policy in ERE's Reth crypto adapter.statelessremains zkVM-agnostic; genericMODEXPpaths could move into SP1'slibzkevmlater so the Ethrex guest can use them too.Correctness
The fast paths are checked against
aurora-engine-modexp, including zero/modulus edge cases,U256, fixed-width, Montgomery/REDC, and repeated 248-bit chunk inputs. Both benchmark builds also produced the exact expected output for every fixture.Full cycle benchmark
Paired SP1 run using
zkevm-benchmark-workloadate0b6519, EREv0.13.0, Rethv2.3.0, SP1v6.3.1, and four workers. The same 1,077 Osaka 10M cases were converted to v0.13 canonical SSZ through ERE's legacy-to-canonical input bridge.cffc3f1+stateless@3d2fc17)810,421,889,7021,077 / 1,0775770b2e)185,706,351,8281,077 / 1,077-624,715,537,874(-77.085%)0mismatchesPR / control = 0.229PR ELF SHA-256:
08052808b3aeef0f92ac0a83bc9caccf3ed33ef4d21f1043f4b2c3d14370677fThe Zilkworm article reports
159,156,117,864cycles under the older legacy-input runner. That is useful historical context, but it is not the paired control for the v0.13 result above because the current guest also performs canonical SSZ input/output work.Checks
.github/scripts/cargo-fetch-all.sh --locked.github/scripts/cargo-fmt-all.sh --checkcargo clippy --all-targets -- -D warningscargo test --lib --no-fail-fastcargo test --doc --no-fail-fast