diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f0cc4ca51a..500033f728 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -120,14 +120,14 @@ jobs: env: CARGO_INCREMENTAL: 1 - # - name: Add wasm target - # run: rustup target add wasm32-unknown-unknown + - name: Add wasm target + run: rustup target add wasm32-unknown-unknown - # - name: Check wasm compatibility for sdk - # uses: actions-rs/cargo@v1 - # with: - # command: check - # args: -p sp1-sdk --target wasm32-unknown-unknown --no-default-features + - name: Check wasm compatibility for sdk + uses: actions-rs/cargo@v1 + with: + command: check + args: -p sp1-sdk --target wasm32-unknown-unknown --no-default-features examples: name: Examples @@ -270,55 +270,55 @@ jobs: --commit-hash "${{ github.sha }}" \ --author "${{ github.event.pull_request.user.login || github.actor }}" - # low-memory: - # name: Low Memory - # strategy: - # matrix: - # mem_limit: [16, 32, 64] - # runs-on: - # [ - # runs-on, - # "ram=${{ matrix.mem_limit}}", - # family=c7a, - # image=ubuntu22-full-x64, - # "run-id=${{ github.run_id }}", - # ] - # env: - # CARGO_NET_GIT_FETCH_WITH_CLI: "true" - # steps: - # - name: Checkout sources - # uses: actions/checkout@v4 + low-memory: + name: Low Memory + strategy: + matrix: + mem_limit: [16, 32, 64] + runs-on: + [ + runs-on, + "ram=${{ matrix.mem_limit}}", + family=c7a, + image=ubuntu22-full-x64, + "run-id=${{ github.run_id }}", + ] + env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + steps: + - name: Checkout sources + uses: actions/checkout@v4 - # - name: Setup CI - # uses: ./.github/actions/setup + - name: Setup CI + uses: ./.github/actions/setup - # - name: Install SP1 toolchain - # run: | - # curl -L https://sp1.succinct.xyz | bash - # ~/.sp1/bin/sp1up - # ~/.sp1/bin/cargo-prove prove --version + - name: Install SP1 toolchain + run: | + curl -L https://sp1.succinct.xyz | bash + ~/.sp1/bin/sp1up + ~/.sp1/bin/cargo-prove prove --version - # - name: Install SP1 CLI - # run: | - # cd crates/cli - # cargo install --force --locked --path . - # cd ~ + - name: Install SP1 CLI + run: | + cd crates/cli + cargo install --force --locked --path . + cd ~ - # - name: Run tendermint script - # run: | - # cd examples/tendermint/program - # cargo add sp1-zkvm --path $GITHUB_WORKSPACE/crates/zkvm/entrypoint - # cargo prove build - # cd ../script - # cargo remove sp1-sdk - # cargo add sp1-sdk --path $GITHUB_WORKSPACE/crates/sdk - # SP1_DEV=1 RUST_LOG=info cargo run --release + - name: Run tendermint script + run: | + cd examples/tendermint/program + cargo add sp1-zkvm --path $GITHUB_WORKSPACE/crates/zkvm/entrypoint + cargo prove build + cd ../script + cargo remove sp1-sdk + cargo add sp1-sdk --path $GITHUB_WORKSPACE/crates/sdk + SP1_DEV=1 RUST_LOG=info cargo run --release - # - name: Run cycle tracking script - # run: | - # cd examples/cycle-tracking/script - # cargo add sp1-sdk --path $GITHUB_WORKSPACE/crates/sdk - # SP1_DEV=1 RUST_LOG=info cargo run --release + - name: Run cycle tracking script + run: | + cd examples/cycle-tracking/script + cargo add sp1-sdk --path $GITHUB_WORKSPACE/crates/sdk + SP1_DEV=1 RUST_LOG=info cargo run --release # toolchain-test: # name: "Test toolchain installation (${{ matrix.name }})" diff --git a/Cargo.lock b/Cargo.lock index 5af714da23..a105054669 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -988,14 +988,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.10.0", + "uuid 1.11.0", ] [[package]] name = "aws-sdk-s3" -version = "1.56.0" +version = "1.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecd672c8d4265fd4fbecacd4a479180e616881bbe639250cf81ddb604e4c301" +checksum = "8888c238bf93c77c5df8274b3999fd7fc1bb3fb658616f40dfde9e4fcd9efd94" dependencies = [ "ahash", "aws-credential-types", @@ -3758,7 +3758,7 @@ dependencies = [ "http 1.1.0", "hyper 1.5.0", "hyper-util", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -4623,9 +4623,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "7b8cefcf97f41316955f9294cd61f639bdcfa9f2f230faac6cb896aa8ab64704" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -4655,9 +4655,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -5379,9 +5379,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -5476,7 +5476,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.0.0", - "rustls 0.23.14", + "rustls 0.23.15", "socket2", "thiserror", "tokio", @@ -5493,7 +5493,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rustc-hash 2.0.0", - "rustls 0.23.14", + "rustls 0.23.15", "slab", "thiserror", "tinyvec", @@ -5776,7 +5776,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", @@ -6039,9 +6039,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.14" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "log", "once_cell", @@ -6702,7 +6702,7 @@ dependencies = [ [[package]] name = "sp1-build" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "anyhow", "cargo_metadata", @@ -6713,7 +6713,7 @@ dependencies = [ [[package]] name = "sp1-cli" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "anstyle", "anyhow", @@ -6741,7 +6741,7 @@ dependencies = [ [[package]] name = "sp1-core-executor" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "bincode", "bytemuck", @@ -6774,7 +6774,7 @@ dependencies = [ [[package]] name = "sp1-core-machine" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "bincode", "cfg-if", @@ -6823,7 +6823,7 @@ dependencies = [ [[package]] name = "sp1-cuda" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "bincode", "ctrlc", @@ -6840,7 +6840,7 @@ dependencies = [ [[package]] name = "sp1-curves" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "cfg-if", "curve25519-dalek", @@ -6862,7 +6862,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "quote", "syn 1.0.109", @@ -6870,7 +6870,7 @@ dependencies = [ [[package]] name = "sp1-eval" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "anyhow", "bincode", @@ -6890,14 +6890,14 @@ dependencies = [ [[package]] name = "sp1-helper" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "sp1-build", ] [[package]] name = "sp1-lib" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "bincode", "serde", @@ -6905,7 +6905,7 @@ dependencies = [ [[package]] name = "sp1-perf" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "anyhow", "bincode", @@ -6916,6 +6916,7 @@ dependencies = [ "serde", "serde_json", "slack-rust-rs", + "sp1-core-executor", "sp1-cuda", "sp1-prover", "sp1-sdk", @@ -6926,7 +6927,7 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "bincode", "hex", @@ -6942,7 +6943,7 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "anyhow", "bincode", @@ -6982,7 +6983,7 @@ dependencies = [ [[package]] name = "sp1-recursion-circuit" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "ff 0.13.0", "hashbrown 0.14.5", @@ -7018,7 +7019,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "backtrace", "criterion", @@ -7043,7 +7044,7 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "backtrace", "ff 0.13.0", @@ -7078,7 +7079,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "quote", "syn 1.0.109", @@ -7086,7 +7087,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-cli" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "bincode", "clap", @@ -7095,7 +7096,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "anyhow", "bincode", @@ -7119,7 +7120,7 @@ dependencies = [ [[package]] name = "sp1-sdk" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "alloy-primitives 0.8.8", "alloy-signer", @@ -7165,7 +7166,7 @@ dependencies = [ [[package]] name = "sp1-stark" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "arrayref", "getrandom 0.2.15", @@ -7200,7 +7201,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "3.0.0-rc4" +version = "3.0.0" dependencies = [ "cfg-if", "getrandom 0.2.15", @@ -7755,7 +7756,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pki-types", "tokio", ] @@ -8193,9 +8194,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "valuable" diff --git a/Cargo.toml b/Cargo.toml index 37fc7c09c2..cad031a8a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "3.0.0-rc4" +version = "3.0.0" edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/succinctlabs/sp1" @@ -46,26 +46,26 @@ debug-assertions = true [workspace.dependencies] # sp1 -sp1-build = { path = "crates/build", version = "=3.0.0-rc4" } -sp1-cli = { path = "crates/cli", version = "=3.0.0-rc4", default-features = false } -sp1-core-machine = { path = "crates/core/machine", version = "=3.0.0-rc4" } -sp1-core-executor = { path = "crates/core/executor", version = "=3.0.0-rc4" } -sp1-curves = { path = "crates/curves", version = "=3.0.0-rc4" } -sp1-derive = { path = "crates/derive", version = "=3.0.0-rc4" } -sp1-eval = { path = "crates/eval", version = "=3.0.0-rc4" } -sp1-helper = { path = "crates/helper", version = "=3.0.0-rc4", default-features = false } -sp1-primitives = { path = "crates/primitives", version = "=3.0.0-rc4" } -sp1-prover = { path = "crates/prover", version = "=3.0.0-rc4" } -sp1-recursion-compiler = { path = "crates/recursion/compiler", version = "=3.0.0-rc4" } -sp1-recursion-core = { path = "crates/recursion/core", version = "=3.0.0-rc4", default-features = false } -sp1-recursion-derive = { path = "crates/recursion/derive", version = "=3.0.0-rc4", default-features = false } -sp1-recursion-gnark-ffi = { path = "crates/recursion/gnark-ffi", version = "=3.0.0-rc4", default-features = false } -sp1-recursion-circuit = { path = "crates/recursion/circuit", version = "=3.0.0-rc4", default-features = false } -sp1-sdk = { path = "crates/sdk", version = "=3.0.0-rc4" } -sp1-cuda = { path = "crates/cuda", version = "=3.0.0-rc4" } -sp1-stark = { path = "crates/stark", version = "=3.0.0-rc4" } -sp1-lib = { path = "crates/zkvm/lib", version = "=3.0.0-rc4", default-features = false } -sp1-zkvm = { path = "crates/zkvm/entrypoint", version = "=3.0.0-rc4", default-features = false } +sp1-build = { path = "crates/build", version = "3.0.0" } +sp1-cli = { path = "crates/cli", version = "3.0.0", default-features = false } +sp1-core-machine = { path = "crates/core/machine", version = "3.0.0" } +sp1-core-executor = { path = "crates/core/executor", version = "3.0.0" } +sp1-curves = { path = "crates/curves", version = "3.0.0" } +sp1-derive = { path = "crates/derive", version = "3.0.0" } +sp1-eval = { path = "crates/eval", version = "3.0.0" } +sp1-helper = { path = "crates/helper", version = "3.0.0", default-features = false } +sp1-primitives = { path = "crates/primitives", version = "3.0.0" } +sp1-prover = { path = "crates/prover", version = "3.0.0" } +sp1-recursion-compiler = { path = "crates/recursion/compiler", version = "3.0.0" } +sp1-recursion-core = { path = "crates/recursion/core", version = "3.0.0", default-features = false } +sp1-recursion-derive = { path = "crates/recursion/derive", version = "3.0.0", default-features = false } +sp1-recursion-gnark-ffi = { path = "crates/recursion/gnark-ffi", version = "3.0.0", default-features = false } +sp1-recursion-circuit = { path = "crates/recursion/circuit", version = "3.0.0", default-features = false } +sp1-sdk = { path = "crates/sdk", version = "3.0.0" } +sp1-cuda = { path = "crates/cuda", version = "3.0.0" } +sp1-stark = { path = "crates/stark", version = "3.0.0" } +sp1-lib = { path = "crates/zkvm/lib", version = "3.0.0", default-features = false } +sp1-zkvm = { path = "crates/zkvm/entrypoint", version = "3.0.0", default-features = false } # p3 p3-air = "0.1.4-succinct" diff --git a/book/generating-proofs/proof-types.md b/book/generating-proofs/proof-types.md index 28e7a7a4e7..67e5b7532b 100644 --- a/book/generating-proofs/proof-types.md +++ b/book/generating-proofs/proof-types.md @@ -26,11 +26,9 @@ let client = ProverClient::new(); client.prove(&pk, stdin).compressed().run().unwrap(); ``` -## Groth16 +## Groth16 (Recommended) -> WARNING: The Groth16 prover requires around 64GB of RAM and only has prebuilt circuit artifacts on official releases of SP1. We recommend using the prover network to generate these proofs. - -The Groth16 prover mode generate a SNARK proof that is ~260 bytes large and can be verified onchain for around ~270k gas. Groth16 proofs take about ~30s longer to generate over a compressed proof. +The Groth16 prover mode generate a SNARK proof that is ~260 bytes large and can be verified onchain for around ~270k gas. The trusted setup for the Groth16 circuit keys uses the [Aztec Ignition ceremony](https://github.com/AztecProtocol/ignition-verification) + entropy contributions from members of the Succinct team. @@ -41,8 +39,6 @@ client.prove(&pk, stdin).groth16().run().unwrap(); ## PLONK -> WARNING: The PLONK prover requires around 64GB of RAM and only has prebuilt circuit artifacts on official releases of SP1. We recommend using the prover network to generate these proofs. - The PLONK prover mode generate a SNARK proof that is ~868 bytes large and can also be verified onchain for around ~300k gas. Plonk proofs take about ~1m30s longer to generate over a compressed proof. PLONK does not require a trusted setup. diff --git a/book/getting-started/hardware-requirements.md b/book/getting-started/hardware-requirements.md index 8e149fb023..828ea96080 100644 --- a/book/getting-started/hardware-requirements.md +++ b/book/getting-started/hardware-requirements.md @@ -15,9 +15,9 @@ If you want to generate SP1 proofs locally, this section has an overview of the | | Mock / Network | Core / Compress | Groth16 and PLONK (EVM) | | -------------- | ---------------------------- | ---------------------------------- | ----------------------- | -| CPU | 1+, single-core perf matters | 16+, more is better | 32+, more is better | -| Memory | 8GB+, more is better | 32GB+, more if you have more cores | 64GB+, more is better | -| Disk | 20GB+ | 20GB+ | 12GB+ | +| CPU | 1+, single-core perf matters | 16+, more is better | 16+, more is better | +| Memory | 8GB+, more is better | 16GB+, more if you have more cores | 16GB+, more is better | +| Disk | 10GB+ | 10GB+ | 10GB+ | | EVM Compatible | ✅ | ❌ | ✅ | ### CPU @@ -31,8 +31,7 @@ which can be parallelized with multiple cores. Our prover requires keeping large matrices (i.e., traces) in memory to generate the proofs. Certain steps of the prover have a minimum memory requirement, meaning that if you have less than this amount of memory, the process will OOM. -This effect is most noticeable when using the Groth16 or PLONK provers, which requires around 128GB -of RAM to generate a proof. +This effect is most noticeable when using the Groth16 or PLONK provers. ### Disk diff --git a/book/onchain-verification/contract-addresses.md b/book/onchain-verification/contract-addresses.md index fe3aa5c9a7..3acb971edf 100644 --- a/book/onchain-verification/contract-addresses.md +++ b/book/onchain-verification/contract-addresses.md @@ -1,6 +1,10 @@ # Contract Addresses -To verify SP1 proofs on-chain, we recommend using our deployed verifier gateways. For the chains listed below, an [SP1VerifierGateway](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol) can automatically route your SP1 proof to the correct verifier based on the SP1 version. +To verify SP1 proofs on-chain, we recommend using our deployed canonical verifier gateways. The +[SP1VerifierGateway](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol) +will automatically route your SP1 proof to the correct verifier based on the SP1 version used. + +## Canonical Verifier Gateways | Chain ID | Chain | Gateway | | -------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------- | @@ -12,13 +16,42 @@ To verify SP1 proofs on-chain, we recommend using our deployed verifier gateways | 8453 | Base | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | | 84532 | Base Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | | 10 | Optimism | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://optimistic.etherscan.io/address/0x3b6041173b80e77f038f3f2c0f9744f04837185e) | -| 11155420 | Optimism Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](hhttps://sepolia-optimism.etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 11155420 | Optimism Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia-optimism.etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | | 534351 | Scroll Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.scrollscan.com/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | | 534352 | Scroll | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://scrollscan.com/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | -A complete reference for all of the SP1Verifier contract addresses can be also be found in the [SP1 Contracts Repo](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/deployments). +The most up-to-date reference on each chain can be found in the +[deployments](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/deployments) +directory in the +SP1 contracts repository, where each chain has a dedicated JSON file with each verifier's address. + +## Versioning Policy + +Whenever a verifier for a new SP1 version is deployed, the gateway contract will be updated to +support it with +[addRoute()](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol#L65). +If a verifier for an SP1 version has an issue, the route will be frozen with +[freezeRoute()](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol#L71). + +On mainnets, only official versioned releases are deployed and added to the gateway. Testnets have +`rc` versions of the verifier deployed supported in addition to the official versions. + +## Deploying to other Chains + +In the case that you need to use a chain that is not listed above, you can deploy your own +verifier contract by following the instructions in the +[SP1 Contracts Repo](https://github.com/succinctlabs/sp1-contracts/blob/main/README.md#deployments). + +Since both the `SP1VerifierGateway` and each `SP1Verifier` implement the [ISP1Verifier +interface](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1Verifier.sol), you can choose to either: + +* Deploy the `SP1VerifierGateway` and add `SP1Verifier` contracts to it. Then point to the + `SP1VerifierGateway` address in your contracts. +* Deploy just the `SP1Verifier` contract that you want to use. Then point to the `SP1Verifier` + address in + your contracts. -Whenever a verifier for a new SP1 version is deployed, the gateway contract will be updated to support it with [addRoute()](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol#L65). If a verifier for an SP1 version has an issue, the route will be frozen with [freezeRoute()](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol#L71). +If you want support for a canonical verifier on your chain, contact us [here](https://t.me/+AzG4ws-kD24yMGYx). We often deploy canonical verifiers on new chains if there's enough demand. ## ISP1Verifier Interface diff --git a/book/onchain-verification/getting-started.md b/book/onchain-verification/getting-started.md index 93051b9da0..834a23dc18 100644 --- a/book/onchain-verification/getting-started.md +++ b/book/onchain-verification/getting-started.md @@ -6,7 +6,7 @@ The best way to get started with verifying SP1 proofs on-chain is to refer to th - The template [script](https://github.com/succinctlabs/sp1-project-template/blob/main/script/src/bin/prove.rs) shows how to generate the proof using the SDK and save it to a file. - The template [contract](https://github.com/succinctlabs/sp1-project-template/blob/main/contracts/src/Fibonacci.sol) shows how to verify the proof onchain using Solidity. -Refer to the section on [Contract Addresses](./contract-addresses.md) for the addresses of the deployed verifiers. +Refer to the section on [Contract Addresses](./contract-addresses.md#contract-addresses) for the addresses of the deployed verifiers. ## Generating SP1 Proofs for Onchain Verification diff --git a/book/onchain-verification/solidity-sdk.md b/book/onchain-verification/solidity-sdk.md index 51a0e1e23d..822ab620b9 100644 --- a/book/onchain-verification/solidity-sdk.md +++ b/book/onchain-verification/solidity-sdk.md @@ -37,7 +37,7 @@ contract Fibonacci { /// @dev This can either be a specific SP1Verifier for a specific version, or the /// SP1VerifierGateway which can be used to verify proofs for any version of SP1. /// For the list of supported verifiers on each chain, see: - /// https://github.com/succinctlabs/sp1-contracts/tree/main/contracts/deployments + /// https://docs.succinct.xyz/onchain-verification/contract-addresses address public verifier; /// @notice The verification key for the fibonacci program. @@ -64,7 +64,32 @@ contract Fibonacci { ``` -For more details on the contracts, refer to the [sp1-contracts](https://github.com/succinctlabs/sp1-contracts) repo. +### Finding your program vkey + +The program vkey (`fibonacciProgramVKey` in the example above) is passed into the `ISP1Verifier` along with the public values and proof bytes. You +can find your program vkey by going through the following steps: + +1. Find what version of SP1 crates you are using. +2. Use the version from step to run this command: `sp1up --version ` +3. Use the vkey command to get the program vkey: `cargo prove vkey -elf ` + +Alternatively, you can set up a simple script to do this using the `sp1-sdk` crate: + +```rust +fn main() { + // Setup the logger. + sp1_sdk::utils::setup_logger(); + + // Setup the prover client. + let client = ProverClient::new(); + + // Setup the program. + let (_, vk) = client.setup(FIBONACCI_ELF); + + // Print the verification key. + println!("Program Verification Key: {}", vk.bytes32()); +} +``` ### Testing diff --git a/crates/core/machine/src/lib.rs b/crates/core/machine/src/lib.rs index f50ee422c6..16fd571c95 100644 --- a/crates/core/machine/src/lib.rs +++ b/crates/core/machine/src/lib.rs @@ -30,7 +30,7 @@ pub mod utils; /// This string should be updated whenever any step in verifying an SP1 proof changes, including /// core, recursion, and plonk-bn254. This string is used to download SP1 artifacts and the gnark /// docker image. -pub const SP1_CIRCUIT_VERSION: &str = "v3.0.0-rc4"; +pub const SP1_CIRCUIT_VERSION: &str = "v3.0.0"; // Re-export the `SP1ReduceProof` struct from sp1_core_machine. // diff --git a/crates/cuda/src/lib.rs b/crates/cuda/src/lib.rs index f299d59d52..f63a65c744 100644 --- a/crates/cuda/src/lib.rs +++ b/crates/cuda/src/lib.rs @@ -91,7 +91,7 @@ impl SP1CudaProver { /// [SP1ProverClient] that can be used to communicate with the container. pub fn new() -> Result> { let container_name = "sp1-gpu"; - let image_name = "public.ecr.aws/succinct-labs/sp1-gpu:445c33b"; + let image_name = "public.ecr.aws/succinct-labs/sp1-gpu:7e66232"; let cleaned_up = Arc::new(AtomicBool::new(false)); let cleanup_name = container_name; diff --git a/crates/perf/Cargo.toml b/crates/perf/Cargo.toml index fd4e92c8b2..3cc77b6fc9 100644 --- a/crates/perf/Cargo.toml +++ b/crates/perf/Cargo.toml @@ -11,6 +11,7 @@ categories = { workspace = true } [dependencies] sp1-prover = { workspace = true } +sp1-core-executor = { workspace = true, features = ["programs"] } sp1-sdk = { workspace = true } p3-baby-bear = { workspace = true } sp1-stark = { workspace = true } diff --git a/crates/perf/run_s3.sh b/crates/perf/run_s3.sh index f26278ee9b..a9a0ef7a06 100755 --- a/crates/perf/run_s3.sh +++ b/crates/perf/run_s3.sh @@ -14,9 +14,10 @@ aws s3 cp s3://sp1-testing-suite/$s3_path/program.bin /tmp/program.bin aws s3 cp s3://sp1-testing-suite/$s3_path/stdin.bin /tmp/stdin.bin # Set environment variables -export RUSTFLAGS="-Copt-level=3 -Ctarget-cpu=native" +export RUSTFLAGS="-Copt-level=3 -Ctarget-cpu=native -Cdebuginfo=2" export RUST_BACKTRACE=1 export RUST_LOG=debug +export SP1_DEBUG=1 # Run moongate-perf -cargo run --release -p sp1-perf -- --program /tmp/program.bin --stdin /tmp/stdin.bin --mode $stage \ No newline at end of file +cargo run -p sp1-perf -- --program /tmp/program.bin --stdin /tmp/stdin.bin --mode $stage \ No newline at end of file diff --git a/crates/perf/src/main.rs b/crates/perf/src/main.rs index 51f2e70f3c..baeffbc49b 100644 --- a/crates/perf/src/main.rs +++ b/crates/perf/src/main.rs @@ -1,8 +1,10 @@ use std::time::{Duration, Instant}; use clap::{command, Parser, ValueEnum}; +use sp1_core_executor::programs::tests::VERIFY_PROOF_ELF; use sp1_cuda::SP1CudaProver; use sp1_prover::components::DefaultProverComponents; +use sp1_prover::HashableKey; use sp1_sdk::{self, ProverClient, SP1Context, SP1Prover, SP1Stdin}; use sp1_stark::SP1ProverOpts; @@ -17,7 +19,7 @@ struct PerfArgs { pub mode: ProverMode, } -#[derive(Debug, Clone)] +#[derive(Default, Debug, Clone)] #[allow(dead_code)] struct PerfResult { pub cycles: u64, @@ -71,14 +73,15 @@ fn main() { let (_, verify_core_duration) = time_operation(|| prover.verify(&core_proof.proof, &vk)); + let proofs = stdin.proofs.into_iter().map(|(proof, _)| proof).collect::>(); let (compress_proof, compress_duration) = - time_operation(|| prover.compress(&vk, core_proof, vec![], opts).unwrap()); + time_operation(|| prover.compress(&vk, core_proof.clone(), proofs, opts).unwrap()); let (_, verify_compressed_duration) = time_operation(|| prover.verify_compressed(&compress_proof, &vk)); let (shrink_proof, shrink_duration) = - time_operation(|| prover.shrink(compress_proof, opts).unwrap()); + time_operation(|| prover.shrink(compress_proof.clone(), opts).unwrap()); let (_, verify_shrink_duration) = time_operation(|| prover.verify_shrink(&shrink_proof, &vk)); @@ -89,6 +92,30 @@ fn main() { let (_, verify_wrap_duration) = time_operation(|| prover.verify_wrap_bn254(&wrapped_bn254_proof, &vk)); + // Generate a proof that verifies two deferred proofs from the proof above. + let (pk_verify_proof, vk_verify_proof) = prover.setup(VERIFY_PROOF_ELF); + let pv = core_proof.public_values.to_vec(); + + let mut stdin = SP1Stdin::new(); + let vk_u32 = vk.hash_u32(); + stdin.write::<[u32; 8]>(&vk_u32); + stdin.write::>>(&vec![pv.clone(), pv.clone()]); + stdin.write_proof(compress_proof.clone(), vk.vk.clone()); + stdin.write_proof(compress_proof.clone(), vk.vk.clone()); + + let context = SP1Context::default(); + let (core_proof, _) = time_operation(|| { + prover.prove_core(&pk_verify_proof, &stdin, opts, context).unwrap() + }); + let deferred_proofs = + stdin.proofs.into_iter().map(|(proof, _)| proof).collect::>(); + let (compress_proof, _) = time_operation(|| { + prover + .compress(&vk_verify_proof, core_proof.clone(), deferred_proofs, opts) + .unwrap() + }); + prover.verify_compressed(&compress_proof, &vk_verify_proof).unwrap(); + let result = PerfResult { cycles, execution_duration, @@ -118,8 +145,9 @@ fn main() { prover.verify(&core_proof.proof, &vk).expect("Proof verification failed") }); + let proofs = stdin.proofs.into_iter().map(|(proof, _)| proof).collect::>(); let (compress_proof, compress_duration) = - time_operation(|| server.compress(&vk, core_proof, vec![]).unwrap()); + time_operation(|| server.compress(&vk, core_proof, proofs).unwrap()); let (_, verify_compressed_duration) = time_operation(|| prover.verify_compressed(&compress_proof, &vk)); @@ -132,10 +160,9 @@ fn main() { let (_, wrap_duration) = time_operation(|| server.wrap_bn254(shrink_proof).unwrap()); - // TODO: Verify wrapped bn254 proofs. + // TODO: FIX // let (_, verify_wrap_duration) = // time_operation(|| prover.verify_wrap_bn254(&wrapped_bn254_proof, &vk)); - let verify_wrap_duration = Duration::from_secs(0); let result = PerfResult { cycles, @@ -147,7 +174,7 @@ fn main() { shrink_duration, verify_shrink_duration, wrap_duration, - verify_wrap_duration, + ..Default::default() }; println!("{:?}", result); diff --git a/crates/prover/src/lib.rs b/crates/prover/src/lib.rs index f728216dd4..40f0751fce 100644 --- a/crates/prover/src/lib.rs +++ b/crates/prover/src/lib.rs @@ -491,11 +491,15 @@ impl SP1Prover { let operations = builder.into_operations(); operations_span.exit(); - // Compile the program. - tracing::debug_span!("compile compress program").in_scope(|| { - let mut compiler = AsmCompiler::::default(); - Arc::new(compiler.compile(operations)) - }) + let compiler_span = tracing::debug_span!("compile deferred program").entered(); + let mut compiler = AsmCompiler::::default(); + let mut program = compiler.compile(operations); + if let Some(recursion_shape_config) = &self.recursion_shape_config { + recursion_shape_config.fix_shape(&mut program); + } + let program = Arc::new(program); + compiler_span.exit(); + program } pub fn get_recursion_core_inputs( diff --git a/crates/prover/vk_map.bin b/crates/prover/vk_map.bin index 02f271f835..afa7df3b13 100644 Binary files a/crates/prover/vk_map.bin and b/crates/prover/vk_map.bin differ diff --git a/crates/recursion/circuit/src/machine/deferred.rs b/crates/recursion/circuit/src/machine/deferred.rs index 1afc3cb014..0f38620a7d 100644 --- a/crates/recursion/circuit/src/machine/deferred.rs +++ b/crates/recursion/circuit/src/machine/deferred.rs @@ -181,6 +181,10 @@ where // Get the current public values. let current_public_values: &RecursionPublicValues> = shard_proof.public_values.as_slice().borrow(); + // Assert that the `vk_root` is the same as the witnessed one. + for (elem, expected) in current_public_values.vk_root.iter().zip(vk_root.iter()) { + builder.assert_felt_eq(*elem, *expected); + } // Assert that the public values are valid. assert_recursion_public_values_valid::(builder, current_public_values); diff --git a/crates/recursion/gnark-ffi/build.rs b/crates/recursion/gnark-ffi/build.rs index 78325f356b..3f29556463 100644 --- a/crates/recursion/gnark-ffi/build.rs +++ b/crates/recursion/gnark-ffi/build.rs @@ -46,9 +46,6 @@ fn main() { let header_path = dest_path.join(format!("lib{}.h", lib_name)); let bindings = bindgen::Builder::default() .header(header_path.to_str().unwrap()) - // `rerun_on_header_files` needs to be turned off as `libsp1gnark.h` is regenerated - // on each run. - .parse_callbacks(Box::new(CargoCallbacks::new().rerun_on_header_files(false))) .generate() .expect("Unable to generate bindings"); diff --git a/crates/recursion/gnark-ffi/go/main.go b/crates/recursion/gnark-ffi/go/main.go index 45f63b78e5..5f9acfc9e6 100644 --- a/crates/recursion/gnark-ffi/go/main.go +++ b/crates/recursion/gnark-ffi/go/main.go @@ -2,6 +2,7 @@ package main /* #include "./babybear.h" +#include typedef struct { char *PublicInputs[2]; @@ -21,6 +22,7 @@ import ( "fmt" "os" "sync" + "unsafe" "github.com/consensys/gnark-crypto/ecc" "github.com/consensys/gnark/backend/groth16" @@ -56,6 +58,15 @@ func ProvePlonkBn254(dataDir *C.char, witnessPath *C.char) *C.C_PlonkBn254Proof return structPtr } +//export FreePlonkBn254Proof +func FreePlonkBn254Proof(proof *C.C_PlonkBn254Proof) { + C.free(unsafe.Pointer(proof.EncodedProof)) + C.free(unsafe.Pointer(proof.RawProof)) + C.free(unsafe.Pointer(proof.PublicInputs[0])) + C.free(unsafe.Pointer(proof.PublicInputs[1])) + C.free(unsafe.Pointer(proof)) +} + //export BuildPlonkBn254 func BuildPlonkBn254(dataDir *C.char) { // Sanity check the required arguments have been provided. @@ -116,6 +127,15 @@ func ProveGroth16Bn254(dataDir *C.char, witnessPath *C.char) *C.C_Groth16Bn254Pr return structPtr } +//export FreeGroth16Bn254Proof +func FreeGroth16Bn254Proof(proof *C.C_Groth16Bn254Proof) { + C.free(unsafe.Pointer(proof.EncodedProof)) + C.free(unsafe.Pointer(proof.RawProof)) + C.free(unsafe.Pointer(proof.PublicInputs[0])) + C.free(unsafe.Pointer(proof.PublicInputs[1])) + C.free(unsafe.Pointer(proof)) +} + //export BuildGroth16Bn254 func BuildGroth16Bn254(dataDir *C.char) { // Sanity check the required arguments have been provided. @@ -280,3 +300,8 @@ func TestPoseidonBabyBear2() *C.char { return nil } + +//export FreeString +func FreeString(s *C.char) { + C.free(unsafe.Pointer(s)) +} diff --git a/crates/recursion/gnark-ffi/src/ffi/native.rs b/crates/recursion/gnark-ffi/src/ffi/native.rs index d3faba0fe8..46ab4eacb9 100644 --- a/crates/recursion/gnark-ffi/src/ffi/native.rs +++ b/crates/recursion/gnark-ffi/src/ffi/native.rs @@ -8,7 +8,10 @@ use crate::{Groth16Bn254Proof, PlonkBn254Proof}; use cfg_if::cfg_if; use sp1_core_machine::SP1_CIRCUIT_VERSION; -use std::ffi::{c_char, CString}; +use std::{ + ffi::{c_char, CStr, CString}, + mem::forget, +}; #[allow(warnings, clippy::all)] mod bind { @@ -22,8 +25,8 @@ enum ProofSystem { } enum ProofResult { - Plonk(C_PlonkBn254Proof), - Groth16(C_Groth16Bn254Proof), + Plonk(*mut C_PlonkBn254Proof), + Groth16(*mut C_Groth16Bn254Proof), } impl ProofSystem { @@ -80,12 +83,12 @@ fn prove(system: ProofSystem, data_dir: &str, witness_path: &str) -> ProofResult ProveFunction::Plonk(func) => { let proof = func(data_dir.as_ptr() as *mut c_char, witness_path.as_ptr() as *mut c_char); - ProofResult::Plonk(*proof) + ProofResult::Plonk(proof) } ProveFunction::Groth16(func) => { let proof = func(data_dir.as_ptr() as *mut c_char, witness_path.as_ptr() as *mut c_char); - ProofResult::Groth16(*proof) + ProofResult::Groth16(proof) } } } @@ -115,9 +118,10 @@ fn verify( if err_ptr.is_null() { Ok(()) } else { - // Safety: The error message is returned from the go code and is guaranteed to be valid. - let err = unsafe { CString::from_raw(err_ptr) }; - Err(err.into_string().unwrap()) + unsafe { + // Safety: The error message is returned from the go code and is guaranteed to be valid. + Err(ptr_to_string_freed(err_ptr)) + } } } @@ -131,8 +135,7 @@ fn test(system: ProofSystem, witness_json: &str, constraints_json: &str) { ); if !err_ptr.is_null() { // Safety: The error message is returned from the go code and is guaranteed to be valid. - let err = CString::from_raw(err_ptr); - panic!("Test failed: {}", err.into_string().unwrap()); + panic!("Test failed: {:?}", ptr_to_string_freed(err_ptr)); } } } @@ -145,7 +148,7 @@ pub fn build_plonk_bn254(data_dir: &str) { pub fn prove_plonk_bn254(data_dir: &str, witness_path: &str) -> PlonkBn254Proof { match prove(ProofSystem::Plonk, data_dir, witness_path) { - ProofResult::Plonk(proof) => proof.into(), + ProofResult::Plonk(proof) => unsafe { PlonkBn254Proof::from_raw(proof) }, _ => unreachable!(), } } @@ -169,7 +172,7 @@ pub fn build_groth16_bn254(data_dir: &str) { pub fn prove_groth16_bn254(data_dir: &str, witness_path: &str) -> Groth16Bn254Proof { match prove(ProofSystem::Groth16, data_dir, witness_path) { - ProofResult::Groth16(proof) => proof.into(), + ProofResult::Groth16(proof) => unsafe { Groth16Bn254Proof::from_raw(proof) }, _ => unreachable!(), } } @@ -192,8 +195,7 @@ pub fn test_babybear_poseidon2() { let err_ptr = bind::TestPoseidonBabyBear2(); if !err_ptr.is_null() { // Safety: The error message is returned from the go code and is guaranteed to be valid. - let err = CString::from_raw(err_ptr); - panic!("TestPoseidonBabyBear2 failed: {}", err.into_string().unwrap()); + panic!("TestPoseidonBabyBear2 failed: {}", ptr_to_string_freed(err_ptr)); } } } @@ -201,43 +203,52 @@ pub fn test_babybear_poseidon2() { /// Converts a C string into a Rust String. /// /// # Safety -/// This function frees the string memory, so the caller must ensure that the pointer is not used +/// This function does not free the pointer, so the caller must ensure that the pointer is handled +/// correctly. +unsafe fn ptr_to_string_cloned(input: *mut c_char) -> String { + CStr::from_ptr(input).to_owned().into_string().expect("CStr::into_string failed") +} + +/// Converts a C string into a Rust String. +/// +/// # Safety +/// This function frees the pointer, so the caller must ensure that the pointer is not used /// after this function is called. -unsafe fn c_char_ptr_to_string(input: *mut c_char) -> String { - CString::from_raw(input).into_string().expect("CString::into_string failed") +unsafe fn ptr_to_string_freed(input: *mut c_char) -> String { + let string = ptr_to_string_cloned(input); + bind::FreeString(input); + string } -impl From for PlonkBn254Proof { - fn from(c_proof: C_PlonkBn254Proof) -> Self { - // Safety: The raw pointers are not used anymore after converted into Rust strings. - unsafe { - PlonkBn254Proof { - public_inputs: [ - c_char_ptr_to_string(c_proof.PublicInputs[0]), - c_char_ptr_to_string(c_proof.PublicInputs[1]), - ], - encoded_proof: c_char_ptr_to_string(c_proof.EncodedProof), - raw_proof: c_char_ptr_to_string(c_proof.RawProof), - plonk_vkey_hash: [0; 32], - } - } +impl PlonkBn254Proof { + unsafe fn from_raw(c_proof: *mut C_PlonkBn254Proof) -> Self { + let proof = PlonkBn254Proof { + public_inputs: [ + ptr_to_string_cloned((*c_proof).PublicInputs[0]), + ptr_to_string_cloned((*c_proof).PublicInputs[1]), + ], + encoded_proof: ptr_to_string_cloned((*c_proof).EncodedProof), + raw_proof: ptr_to_string_cloned((*c_proof).RawProof), + plonk_vkey_hash: [0; 32], + }; + bind::FreePlonkBn254Proof(c_proof); + proof } } -impl From for Groth16Bn254Proof { - fn from(c_proof: C_Groth16Bn254Proof) -> Self { - // Safety: The raw pointers are not used anymore after converted into Rust strings. - unsafe { - Groth16Bn254Proof { - public_inputs: [ - c_char_ptr_to_string(c_proof.PublicInputs[0]), - c_char_ptr_to_string(c_proof.PublicInputs[1]), - ], - encoded_proof: c_char_ptr_to_string(c_proof.EncodedProof), - raw_proof: c_char_ptr_to_string(c_proof.RawProof), - groth16_vkey_hash: [0; 32], - } - } +impl Groth16Bn254Proof { + unsafe fn from_raw(c_proof: *mut C_Groth16Bn254Proof) -> Self { + let proof = Groth16Bn254Proof { + public_inputs: [ + ptr_to_string_cloned((*c_proof).PublicInputs[0]), + ptr_to_string_cloned((*c_proof).PublicInputs[1]), + ], + encoded_proof: ptr_to_string_cloned((*c_proof).EncodedProof), + raw_proof: ptr_to_string_cloned((*c_proof).RawProof), + groth16_vkey_hash: [0; 32], + }; + bind::FreeGroth16Bn254Proof(c_proof); + proof } } diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index ba4ff38046..dc2df12506 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -70,18 +70,19 @@ impl ProverClient { /// let client = ProverClient::new(); /// ``` pub fn new() -> Self { - #[cfg(debug_assertions)] - panic!("sp1-sdk must be built in release mode. please compile with the --release flag."); - #[allow(unreachable_code)] match env::var("SP1_PROVER").unwrap_or("local".to_string()).to_lowercase().as_str() { "mock" => Self { prover: Box::new(MockProver::new()) }, - "local" => Self { - #[cfg(not(feature = "cuda"))] - prover: Box::new(CpuProver::new()), - #[cfg(feature = "cuda")] - prover: Box::new(CudaProver::new(SP1Prover::new())), - }, + "local" => { + #[cfg(debug_assertions)] + println!("Warning: Local prover in dev mode is not recommended. Proof generation may be slow."); + Self { + #[cfg(not(feature = "cuda"))] + prover: Box::new(CpuProver::new()), + #[cfg(feature = "cuda")] + prover: Box::new(CudaProver::new(SP1Prover::new())), + } + } "network" => { cfg_if! { if #[cfg(feature = "network-v2")] { diff --git a/crates/sdk/src/network-v2/client.rs b/crates/sdk/src/network-v2/client.rs index a2ad18a2a8..362d7a08c5 100644 --- a/crates/sdk/src/network-v2/client.rs +++ b/crates/sdk/src/network-v2/client.rs @@ -14,6 +14,7 @@ use std::str::FromStr; use std::time::{SystemTime, UNIX_EPOCH}; use tokio::sync::OnceCell; use tokio::try_join; +use tonic::transport::channel::ClientTlsConfig; use tonic::transport::Channel; use crate::network_v2::proto::artifact::{ @@ -58,14 +59,32 @@ impl NetworkClient { /// Get a connected RPC client. async fn get_rpc(&self) -> Result> { let rpc_url = Self::rpc_url(); - let channel = Channel::from_shared(rpc_url)?.connect().await?; - Ok(ProverNetworkClient::new(channel.clone())) + let mut endpoint = Channel::from_shared(rpc_url.clone())?; + + // Check if the URL scheme is HTTPS and configure TLS. + if rpc_url.starts_with("https://") { + println!("Using TLS"); + let tls_config = ClientTlsConfig::new().with_enabled_roots(); + endpoint = endpoint.tls_config(tls_config)?; + } + + let channel = endpoint.connect().await?; + Ok(ProverNetworkClient::new(channel)) } /// Get a connected artifact store client. async fn get_store(&self) -> Result> { let rpc_url = Self::rpc_url(); - let channel = Channel::from_shared(rpc_url)?.connect().await?; + let mut endpoint = Channel::from_shared(rpc_url.clone())?; + + // Check if the URL scheme is HTTPS and configure TLS. + if rpc_url.starts_with("https://") { + println!("Using TLS"); + let tls_config = ClientTlsConfig::new().with_enabled_roots(); + endpoint = endpoint.tls_config(tls_config)?; + } + + let channel = endpoint.connect().await?; Ok(ArtifactStoreClient::new(channel.clone())) } @@ -203,6 +222,9 @@ impl NetworkClient { let response = self.http.put(&presigned_url).body(bincode::serialize::(item)?).send().await?; + if !response.status().is_success() { + log::debug!("Artifact upload failed with status: {}", response.status()); + } assert!(response.status().is_success()); Ok(uri) diff --git a/crates/stark/src/lookup/debug.rs b/crates/stark/src/lookup/debug.rs index 8d051d8f82..fd3e0b61ce 100644 --- a/crates/stark/src/lookup/debug.rs +++ b/crates/stark/src/lookup/debug.rs @@ -154,6 +154,9 @@ where for chip in chips.iter() { let mut total_events = 0; for shard in shards { + if !chip.included(shard) { + continue; + } let (_, count) = debug_interactions::(chip, pkey, shard, interaction_kinds.clone(), scope); total_events += count.len(); diff --git a/examples/bls12381/script/Cargo.toml b/examples/bls12381/script/Cargo.toml index 1390dafceb..89fc5b4118 100644 --- a/examples/bls12381/script/Cargo.toml +++ b/examples/bls12381/script/Cargo.toml @@ -4,7 +4,7 @@ name = "bls12381-script" edition = "2021" [dependencies] -sp1-sdk = { path = "../../../../sp1/crates/sdk" } +sp1-sdk = { path = "../../../crates/sdk" } [build-dependencies] diff --git a/examples/bn254/script/Cargo.toml b/examples/bn254/script/Cargo.toml index bd448e9fd3..074a15d906 100644 --- a/examples/bn254/script/Cargo.toml +++ b/examples/bn254/script/Cargo.toml @@ -4,8 +4,8 @@ name = "bn254-script" edition = "2021" [dependencies] -sp1-sdk = { path = "../../../../sp1/crates/sdk" } +sp1-sdk = { path = "../../../crates/sdk" } [build-dependencies] -sp1-build = { path = "../../../../sp1/crates/build" } +sp1-build = { path = "../../../crates/build" }