Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

perf: update risc0 prover to use k256 and keccak acceleration #450

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

austinabell
Copy link
Contributor

Haven't extensively benchmarked against a lot of blocks, but shaves off most cycles in the ones I have.

A subtle change that might be missed is that I switched the keccak impl in this repo to use alloy-primitives (which internally is k256) from sha3 to optimize for our use case. It is the only change that might have some impact on other provers, but also didn't make sense to me why three different implementations of secp256k1 were being used. Happy to revert that or put it behind a feature flag/cfg that's only used in our prover impl if preferred.

Pointing at this PR of reth to enable k256 taikoxyz/taiko-reth#62

@dantaik dantaik requested a review from smtmfft January 14, 2025 01:34
@hmrtn
Copy link
Contributor

hmrtn commented Jan 17, 2025

Note: We've released risc0-* 1.2.1 - be sure to update the versions in the TOML files before testing.

@austinabell
Copy link
Contributor Author

Note: We've released risc0-* 1.2.1 - be sure to update the versions in the TOML files before testing.

Done in b04d541 (#450)

@austinabell austinabell marked this pull request as ready for review January 21, 2025 17:20
@smtmfft smtmfft requested a review from keroro520 February 7, 2025 00:47
@austinabell austinabell changed the title Update risc0 prover to use k256 and keccak acceleration perf: Update risc0 prover to use k256 and keccak acceleration Feb 11, 2025
@austinabell austinabell changed the title perf: Update risc0 prover to use k256 and keccak acceleration perf: update risc0 prover to use k256 and keccak acceleration Feb 11, 2025
Copy link
Contributor

@keroro520 keroro520 left a comment

Choose a reason for hiding this comment

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

LGTM 👍
The cycles have been reduced by ~65% in the worst-case mainnet blocks.

keroro520 added a commit that referenced this pull request Feb 19, 2025
* config(Cargo.toml): bump taiko-reth

* config(provers/risc0/guest/): bump taiko-reth

* perf(provers/sp1/guest): accelerate Secp256k1 by using k256

See also:
- https://docs.succinct.xyz/docs/sp1/writing-programs/patched-crates#secp256k1-acceleration
- #450

* chore(provers/sp1/guest): replace harness::entrypoint! with sp1_zkvm::entrypoint!

* feat(provers/{risc0,sp1}/guest): bump guest image
github-merge-queue bot pushed a commit that referenced this pull request Feb 19, 2025
* update raiko to use k256 signature verification

* update to use new precompiles

* update to 1.2.1-rc.1 to enable keccak acceleration

* consolidate keccak hashing fns to just use alloy-primitives -> tiny-keccak

* remove commented out deps

* update to 1.2.1 stable from rc

* swap to tagged release (same commit as before)

* update lockfile

* update po2 for testing

* bump version to 1.2.3 for paging cycle reduction

* feat: support ballot (#460)

* feat(host): apply reqactor,reqpool

* feat(ballot): support ballot

* refactor(host): remove duplicate types

* feat(host): embed proof_type into response

* docs(api.md): desc v2/proof

* feat(core): add HostError::ZkAnyNotDrawn

* feat: flag --enable-redis-pool

* feat(host): serialize proof_type into lowercase

* feat(host): add zk_any prover opts

* feat(script): prove-block.sh zk_any

* chore(reqactor): twink logs

* config(host): default zk prover is network

* config(host): update devnet info

* feat(taskdb): add TaskStatus::ZKAnyNotDrawn

* provers: update guest image

* chore: apply review suggestion

* chore(host): jq format config files

* config: revert ethereum rpc endpoint

* config(Cargo.toml): bump taiko-reth

* config(provers/risc0/guest/): bump taiko-reth

* perf(provers/sp1/guest): accelerate Secp256k1 by using k256

See also:
- https://docs.succinct.xyz/docs/sp1/writing-programs/patched-crates#secp256k1-acceleration
- #450

* chore(provers/sp1/guest): replace harness::entrypoint! with sp1_zkvm::entrypoint!

* feat(provers/{risc0,sp1}/guest): bump guest image

---------

Co-authored-by: Austin Abell <austinabell8@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants