Skip to content

perf(guest): route all guest keccak through the chip via a vendored t… - #885

Open
diegokingston wants to merge 6 commits into
mainfrom
perf/guest-keccak-ecall
Open

perf(guest): route all guest keccak through the chip via a vendored t…#885
diegokingston wants to merge 6 commits into
mainfrom
perf/guest-keccak-ecall

Conversation

@diegokingston

Copy link
Copy Markdown
Collaborator

…iny-keccak patch

ethrex's free-fn keccak_hash path (trie/RLP/tx hashing) bypasses the Crypto trait, so ~6% of a 20-tx block ran tiny_keccak's pure-Rust keccakf in the guest despite the keccak chip. Vendor tiny-keccak 2.0.2 under crypto/tiny-keccak with a one-hunk patch: on riscv64, keccakf calls the keccak_permute ecall; host keeps the software impl. Activated via [patch.crates-io] in the ethrex guest workspace.

Measured vs origin/main (same fixtures, deterministic):
transfers_20 8,732,213 -> 8,461,843 (-270,370, -3.1%)
erc20_20 10,328,222 -> 9,929,487 (-398,735, -3.9%)
mixed_20 9,817,444 -> 9,450,857 (-366,587, -3.7%)
software tiny_keccak::keccakf in the guest flamegraph: 397k -> 0 (erc20_20).

Verified: test_prove_ethrex_empty_block (prove+verify) passes.

…iny-keccak patch

ethrex's free-fn keccak_hash path (trie/RLP/tx hashing) bypasses the Crypto
trait, so ~6% of a 20-tx block ran tiny_keccak's pure-Rust keccakf in the
guest despite the keccak chip. Vendor tiny-keccak 2.0.2 under
crypto/tiny-keccak with a one-hunk patch: on riscv64, keccakf calls the
keccak_permute ecall; host keeps the software impl. Activated via
[patch.crates-io] in the ethrex guest workspace (same pattern as
sp1-patches/tiny-keccak).

Measured vs origin/main (same fixtures, deterministic):
  transfers_20  8,732,213 -> 8,461,843  (-270,370, -3.1%)
  erc20_20     10,328,222 -> 9,929,487  (-398,735, -3.9%)
  mixed_20      9,817,444 -> 9,450,857  (-366,587, -3.7%)
software tiny_keccak::keccakf in the guest flamegraph: 397k -> 0 (erc20_20).

Verified: test_prove_ethrex_empty_block (prove+verify) passes.
@diegokingston

Copy link
Copy Markdown
Collaborator Author

/bench

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Benchmark — real block (ethrex_mainnet_25368371.bin) (median of 3)

continuations · epoch 2^22 · 11 epochs

Metric main PR Δ
Peak heap 47814 MB 46420 MB -1394 MB (-2.9%) ⚪
Prove time 141.796s 139.832s -1.964s (-1.4%) ⚪

✅ No significant change.

Prove-time spread 0.9% (140.993s / 139.832s / 139.705s)

Commit: 8ba87f8 · Baseline: cached · Runner: self-hosted bench

@diegokingston
diegokingston marked this pull request as ready for review July 31, 2026 21:24
@MauroToscano

Copy link
Copy Markdown
Contributor

/bench

@diegokingston

Copy link
Copy Markdown
Collaborator Author

/bench

@diegokingston

Copy link
Copy Markdown
Collaborator Author

/bench

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