diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e57346e04..cfc5854ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,4 +38,13 @@ jobs: args: --release -p sp1-sdk --features plonk -- test_e2e_prove_plonk --nocapture env: RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native - RUST_BACKTRACE: 1 \ No newline at end of file + RUST_BACKTRACE: 1 + check-branch: + name: Check branch + runs-on: ubuntu-latest + steps: + - name: Check branch + if: github.head_ref != 'dev' + run: | + echo "ERROR: You can only merge to main from dev." + exit 1 \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index bba9a1a13..b75a8e566 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4896,7 +4896,6 @@ dependencies = [ name = "sp1-sdk" version = "0.1.0" dependencies = [ - "alloy-primitives", "alloy-sol-types", "anyhow", "async-trait", @@ -4921,6 +4920,8 @@ dependencies = [ "sha2", "sp1-core", "sp1-prover", + "strum", + "strum_macros", "tempfile", "tokio", "tracing", diff --git a/book/SUMMARY.md b/book/SUMMARY.md index 91624caa0..3728ed9b0 100644 --- a/book/SUMMARY.md +++ b/book/SUMMARY.md @@ -40,4 +40,6 @@ - [Recommended Settings](./developers/recommended-settings.md) -- [Building Plonk Bn254 Artifacts](./developers/building-plonk-artifacts.md) \ No newline at end of file +- [Building Plonk Bn254 Artifacts](./developers/building-plonk-artifacts.md) + +- [Common Issues](./developers/common-issues.md) \ No newline at end of file diff --git a/book/developers/common-issues.md b/book/developers/common-issues.md new file mode 100644 index 000000000..285f461a3 --- /dev/null +++ b/book/developers/common-issues.md @@ -0,0 +1,18 @@ +# Alloy Errors + +If you are using a library that depends on `alloy_sol_types`, and encounter an error like this: + +``` +perhaps two different versions of crate `alloy_sol_types` are being used? +``` + +This is likely due to two different versions of `alloy_sol_types` being used. To fix this, you can set `default-features` to `false` for the `sp1-sdk` dependency in your `Cargo.toml`. + +```toml +[dependencies] +sp1-sdk = { version = "0.1.0", default-features = false } +``` + +This will configure out the `network` feature which will remove the dependency on `alloy_sol_types` +and configure out the `NetworkProver`. + diff --git a/book/verifying-proofs/solidity-and-evm.md b/book/verifying-proofs/solidity-and-evm.md index 294023c5b..e75c988f1 100644 --- a/book/verifying-proofs/solidity-and-evm.md +++ b/book/verifying-proofs/solidity-and-evm.md @@ -14,7 +14,6 @@ To use PLONK proving & verification locally, enable the `plonk` feature flag in sp1-sdk = { features = ["plonk"] } ``` - ### Example ```rust,noplayground @@ -23,25 +22,41 @@ sp1-sdk = { features = ["plonk"] } You can run the above script with `RUST_LOG=info cargo run --bin plonk_bn254 --release` in `examples/fibonacci/script`. -## Exporting the Verifier Contract +## Install SP1 Contracts -To export the verifier contract, you can use the export function in the `sp1_sdk` crate. +# SP1 Contracts -### Example +This repository contains the smart contracts for verifying [SP1](https://github.com/succinctlabs/sp1) EVM proofs. -```rust,noplayground -//! Builds the proving artifacts and exports the solidity verifier. -//! -//! You can run this script using the following command: -//! ```shell -//! RUST_LOG=info cargo run --package fibonacci-script --bin artifacts --release -//! ``` - -use std::path::PathBuf; - -fn main() { - let contracts_src_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../contracts/src"); - sp1_sdk::artifacts::export_solidity_plonk_bn254_verifier(contracts_src_dir) - .expect("failed to export verifier"); +## Installation + +> [!WARNING] +> [Foundry](https://github.com/foundry-rs/foundry) installs the latest release version initially, but subsequent `forge update` commands will use the `main` branch. This branch is the development branch and should be avoided in favor of tagged releases. The release process matches a specific SP1 version. + +To install the latest release version: + +```bash +forge install succinctlabs/sp1-contracts +``` + +To install a specific version: +```bash +forge install succinctlabs/sp1-contracts@ +``` + +Add `@sp1-contracts/=lib/sp1-contracts/contracts/src/` in `remappings.txt.` + +### Usage + +Once installed, you can use the contracts in the library by importing them: + +```solidity +pragma solidity ^0.8.25; + +import {SP1Verifier} from "@sp1-contracts/SP1Verifier.sol"; + +contract MyContract is SP1Verifier { } -``` \ No newline at end of file +``` + +For more details on the contracts, refer to the [sp1-contracts](https://github.com/succinctlabs/sp1-contracts) repo. \ No newline at end of file diff --git a/core/benches/main.rs b/core/benches/main.rs index f40f3db01..88c2db087 100644 --- a/core/benches/main.rs +++ b/core/benches/main.rs @@ -1,6 +1,3 @@ -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] - use criterion::{black_box, criterion_group, criterion_main, Criterion}; use sp1_core::io::SP1Stdin; use sp1_core::runtime::{Program, Runtime}; diff --git a/core/src/lib.rs b/core/src/lib.rs index 3fb0786a0..da90db9cf 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -11,7 +11,6 @@ deprecated, incomplete_features )] -#![feature(generic_const_exprs)] #![warn(unused_extern_crates)] extern crate alloc; diff --git a/core/src/runtime/mod.rs b/core/src/runtime/mod.rs index 2a73cf5da..003d35e8c 100644 --- a/core/src/runtime/mod.rs +++ b/core/src/runtime/mod.rs @@ -22,6 +22,7 @@ pub use utils::*; use std::collections::hash_map::Entry; use std::collections::HashMap; +use std::fmt::{Display, Formatter, Result as FmtResult}; use std::fs::File; use std::io::BufWriter; use std::io::Write; @@ -81,6 +82,54 @@ pub struct Runtime { pub max_syscall_cycles: u32, pub emit_events: bool, + + /// Report of the program execution. + pub report: ExecutionReport, + + /// Whether we should write to the report. + pub should_report: bool, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq)] +pub struct ExecutionReport { + pub instruction_counts: HashMap, + pub syscall_counts: HashMap, +} + +impl ExecutionReport { + pub fn total_instruction_count(&self) -> u64 { + self.instruction_counts.values().sum() + } + + pub fn total_syscall_count(&self) -> u64 { + self.syscall_counts.values().sum() + } +} + +impl Display for ExecutionReport { + fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { + writeln!(f, "Instruction Counts:")?; + let mut sorted_instructions = self.instruction_counts.iter().collect::>(); + + // Sort instructions by opcode name + sorted_instructions.sort_by_key(|&(opcode, _)| opcode.to_string()); + for (opcode, count) in sorted_instructions { + writeln!(f, " {}: {}", opcode, count)?; + } + writeln!(f, "Total Instructions: {}", self.total_instruction_count())?; + + writeln!(f, "Syscall Counts:")?; + let mut sorted_syscalls = self.syscall_counts.iter().collect::>(); + + // Sort syscalls by syscall name + sorted_syscalls.sort_by_key(|&(syscall, _)| format!("{:?}", syscall)); + for (syscall, count) in sorted_syscalls { + writeln!(f, " {}: {}", syscall, count)?; + } + writeln!(f, "Total Syscall Count: {}", self.total_syscall_count())?; + + Ok(()) + } } #[derive(Error, Debug)] @@ -140,6 +189,8 @@ impl Runtime { syscall_map, emit_events: true, max_syscall_cycles, + report: Default::default(), + should_report: false, } } @@ -535,6 +586,14 @@ impl Runtime { let mut memory_store_value: Option = None; self.memory_accesses = MemoryAccessRecord::default(); + if self.should_report && !self.unconstrained { + self.report + .instruction_counts + .entry(instruction.opcode) + .and_modify(|c| *c += 1) + .or_insert(1); + } + match instruction.opcode { // Arithmetic instructions. Opcode::ADD => { @@ -749,6 +808,14 @@ impl Runtime { b = self.rr(Register::X10, MemoryAccessPosition::B); let syscall = SyscallCode::from_u32(syscall_id); + if self.should_report && !self.unconstrained { + self.report + .syscall_counts + .entry(syscall) + .and_modify(|c| *c += 1) + .or_insert(1); + } + let syscall_impl = self.get_syscall(syscall).cloned(); let mut precompile_rt = SyscallContext::new(self); let (precompile_next_pc, precompile_cycles, returned_exit_code) = @@ -956,12 +1023,14 @@ impl Runtime { pub fn run_untraced(&mut self) -> Result<(), ExecutionError> { self.emit_events = false; + self.should_report = true; while !self.execute()? {} Ok(()) } pub fn run(&mut self) -> Result<(), ExecutionError> { self.emit_events = true; + self.should_report = true; while !self.execute()? {} Ok(()) } @@ -1110,6 +1179,58 @@ pub mod tests { assert_eq!(runtime.register(Register::X31), 42); } + #[test] + fn test_ssz_withdrawals_program_run_report() { + let program = ssz_withdrawals_program(); + let mut runtime = Runtime::new(program, SP1CoreOpts::default()); + runtime.run().unwrap(); + assert_eq!(runtime.report, { + use super::Opcode::*; + use super::SyscallCode::*; + super::ExecutionReport { + instruction_counts: [ + (LB, 10723), + (DIVU, 6), + (LW, 237094), + (JALR, 38749), + (XOR, 242242), + (BEQ, 26917), + (AND, 151701), + (SB, 58448), + (MUL, 4036), + (SLTU, 16766), + (ADD, 583439), + (JAL, 5372), + (LBU, 57950), + (SRL, 293010), + (SW, 312781), + (ECALL, 2264), + (BLTU, 43457), + (BGEU, 5917), + (BLT, 1141), + (SUB, 12382), + (BGE, 237), + (MULHU, 1152), + (BNE, 51442), + (AUIPC, 19488), + (OR, 301944), + (SLL, 278698), + ] + .into(), + syscall_counts: [ + (COMMIT_DEFERRED_PROOFS, 8), + (SHA_EXTEND, 1091), + (COMMIT, 8), + (WRITE, 65), + (SHA_COMPRESS, 1091), + (HALT, 1), + ] + .into(), + } + }); + assert_eq!(runtime.report.total_instruction_count(), 2757356); + } + #[test] #[should_panic] fn test_panic() { diff --git a/core/src/runtime/syscall.rs b/core/src/runtime/syscall.rs index 4915f2640..c320c7e28 100644 --- a/core/src/runtime/syscall.rs +++ b/core/src/runtime/syscall.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::fmt; use std::sync::Arc; use strum_macros::EnumIter; @@ -28,7 +29,7 @@ use crate::{runtime::ExecutionRecord, runtime::MemoryReadRecord, runtime::Memory /// - The second byte is 0/1 depending on whether the syscall has a separate table. This is used /// in the CPU table to determine whether to lookup the syscall using the syscall interaction. /// - The third byte is the number of additional cycles the syscall uses. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EnumIter)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EnumIter, Ord, PartialOrd)] #[allow(non_camel_case_types)] pub enum SyscallCode { /// Halts the program. @@ -149,6 +150,12 @@ impl SyscallCode { } } +impl fmt::Display for SyscallCode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) + } +} + pub trait Syscall: Send + Sync { /// Execute the syscall and return the resulting value of register a0. `arg1` and `arg2` are the /// values in registers X10 and X11, respectively. While not a hard requirement, the convention diff --git a/core/src/stark/permutation.rs b/core/src/stark/permutation.rs index a76b4c899..865397d5d 100644 --- a/core/src/stark/permutation.rs +++ b/core/src/stark/permutation.rs @@ -65,7 +65,7 @@ pub(crate) fn generate_permutation_trace>( sends: &[Interaction], receives: &[Interaction], preprocessed: Option<&RowMajorMatrix>, - main: &mut RowMajorMatrix, + main: &RowMajorMatrix, random_elements: &[EF], batch_size: usize, ) -> RowMajorMatrix { @@ -96,13 +96,13 @@ pub(crate) fn generate_permutation_trace>( Some(prep) => { permutation_trace .par_rows_mut() - .zip_eq(prep.par_rows()) - .zip_eq(main.par_rows()) + .zip_eq(prep.par_row_slices()) + .zip_eq(main.par_row_slices()) .for_each(|((row, prep_row), main_row)| { populate_permutation_row( row, - prep_row.collect::>().as_slice(), - main_row.collect::>().as_slice(), + prep_row, + main_row, sends, receives, alpha, @@ -114,7 +114,7 @@ pub(crate) fn generate_permutation_trace>( None => { permutation_trace .par_rows_mut() - .zip_eq(main.par_rows_mut()) + .zip_eq(main.par_row_slices()) .for_each(|(row, main_row)| { populate_permutation_row( row, diff --git a/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs b/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs index ac049a5be..adbab629f 100644 --- a/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs +++ b/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs @@ -36,8 +36,7 @@ use crate::utils::ec::weierstrass::WeierstrassParameters; use crate::utils::ec::AffinePoint; use crate::utils::ec::CurveType; use crate::utils::ec::EllipticCurve; -use crate::utils::limbs_from_prev_access; -use crate::utils::pad_rows; +use crate::utils::{limbs_from_prev_access, pad_rows}; pub const fn num_weierstrass_add_cols() -> usize { size_of::>() @@ -202,8 +201,6 @@ impl WeierstrassAddAssignChip { impl MachineAir for WeierstrassAddAssignChip -where - [(); num_weierstrass_add_cols::()]:, { type Record = ExecutionRecord; type Program = Program; @@ -235,7 +232,7 @@ where for i in 0..events.len() { let event = &events[i]; - let mut row = [F::zero(); num_weierstrass_add_cols::()]; + let mut row = vec![F::zero(); num_weierstrass_add_cols::()]; let cols: &mut WeierstrassAddAssignCols = row.as_mut_slice().borrow_mut(); @@ -287,7 +284,7 @@ where output.add_byte_lookup_events(new_byte_lookup_events); pad_rows(&mut rows, || { - let mut row = [F::zero(); num_weierstrass_add_cols::()]; + let mut row = vec![F::zero(); num_weierstrass_add_cols::()]; let cols: &mut WeierstrassAddAssignCols = row.as_mut_slice().borrow_mut(); let zero = BigUint::zero(); diff --git a/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs b/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs index ef610267f..bd38edea8 100644 --- a/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs +++ b/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs @@ -32,7 +32,6 @@ use crate::runtime::Syscall; use crate::runtime::SyscallCode; use crate::syscall::precompiles::create_ec_decompress_event; use crate::syscall::precompiles::SyscallContext; -use crate::utils::bytes_to_words_le_vec; use crate::utils::ec::weierstrass::bls12_381::bls12381_sqrt; use crate::utils::ec::weierstrass::secp256k1::secp256k1_sqrt; use crate::utils::ec::weierstrass::WeierstrassParameters; @@ -40,7 +39,7 @@ use crate::utils::ec::CurveType; use crate::utils::ec::EllipticCurve; use crate::utils::limbs_from_access; use crate::utils::limbs_from_prev_access; -use crate::utils::pad_rows; +use crate::utils::{bytes_to_words_le_vec, pad_rows}; pub const fn num_weierstrass_decompress_cols() -> usize { size_of::>() @@ -137,8 +136,6 @@ impl WeierstrassDecompressChip { impl MachineAir for WeierstrassDecompressChip -where - [(); num_weierstrass_decompress_cols::()]:, { type Record = ExecutionRecord; type Program = Program; @@ -168,7 +165,7 @@ where for i in 0..events.len() { let event = events[i].clone(); - let mut row = [F::zero(); num_weierstrass_decompress_cols::()]; + let mut row = vec![F::zero(); num_weierstrass_decompress_cols::()]; let cols: &mut WeierstrassDecompressCols = row.as_mut_slice().borrow_mut(); @@ -209,7 +206,7 @@ where output.add_byte_lookup_events(new_byte_lookup_events); pad_rows(&mut rows, || { - let mut row = [F::zero(); num_weierstrass_decompress_cols::()]; + let mut row = vec![F::zero(); num_weierstrass_decompress_cols::()]; let cols: &mut WeierstrassDecompressCols = row.as_mut_slice().borrow_mut(); diff --git a/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs b/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs index 241a9b614..50bb0a433 100644 --- a/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs +++ b/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs @@ -37,8 +37,7 @@ use crate::utils::ec::weierstrass::WeierstrassParameters; use crate::utils::ec::AffinePoint; use crate::utils::ec::CurveType; use crate::utils::ec::EllipticCurve; -use crate::utils::limbs_from_prev_access; -use crate::utils::pad_rows; +use crate::utils::{limbs_from_prev_access, pad_rows}; pub const fn num_weierstrass_double_cols() -> usize { size_of::>() @@ -221,8 +220,6 @@ impl WeierstrassDoubleAssignChip { impl MachineAir for WeierstrassDoubleAssignChip -where - [(); num_weierstrass_double_cols::()]:, { type Record = ExecutionRecord; type Program = Program; @@ -261,7 +258,8 @@ where let rows = events .iter() .map(|event| { - let mut row = [F::zero(); num_weierstrass_double_cols::()]; + let mut row = + vec![F::zero(); num_weierstrass_double_cols::()]; let cols: &mut WeierstrassDoubleAssignCols = row.as_mut_slice().borrow_mut(); @@ -310,7 +308,7 @@ where } pad_rows(&mut rows, || { - let mut row = [F::zero(); num_weierstrass_double_cols::()]; + let mut row = vec![F::zero(); num_weierstrass_double_cols::()]; let cols: &mut WeierstrassDoubleAssignCols = row.as_mut_slice().borrow_mut(); let zero = BigUint::zero(); diff --git a/core/src/utils/mod.rs b/core/src/utils/mod.rs index 3632cde1b..664674bee 100644 --- a/core/src/utils/mod.rs +++ b/core/src/utils/mod.rs @@ -65,7 +65,7 @@ pub fn limbs_from_access>(cols: &[M]) Limbs(sized) } -pub fn pad_rows(rows: &mut Vec<[T; N]>, row_fn: impl Fn() -> [T; N]) { +pub fn pad_rows(rows: &mut Vec, row_fn: impl Fn() -> T) { let nb_rows = rows.len(); let mut padded_nb_rows = nb_rows.next_power_of_two(); if padded_nb_rows < 16 { diff --git a/core/src/utils/options.rs b/core/src/utils/options.rs index 432029bae..d823859d1 100644 --- a/core/src/utils/options.rs +++ b/core/src/utils/options.rs @@ -12,7 +12,7 @@ impl Default for SP1CoreOpts { shard_size: 1 << 22, shard_batch_size: 16, shard_chunking_multiplier: 1, - reconstruct_commitments: false, + reconstruct_commitments: true, } } } diff --git a/eval/src/main.rs b/eval/src/main.rs index dbf67c51b..3ed7a9d3a 100644 --- a/eval/src/main.rs +++ b/eval/src/main.rs @@ -1,6 +1,3 @@ -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - use clap::{command, Parser}; use csv::WriterBuilder; use serde::Serialize; diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 47160c32a..76c62068b 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -4956,6 +4956,8 @@ dependencies = [ "sha2 0.10.8", "sp1-core", "sp1-prover", + "strum", + "strum_macros", "tempfile", "tokio", "tracing", diff --git a/examples/aggregation/programs/fibonacci/Cargo.lock b/examples/aggregation/programs/fibonacci/Cargo.lock deleted file mode 100644 index 08f43eb04..000000000 --- a/examples/aggregation/programs/fibonacci/Cargo.lock +++ /dev/null @@ -1,760 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "cpufeatures" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "const-oid", - "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "fibonacci-program" -version = "0.1.0" -dependencies = [ - "sp1-zkvm", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "getrandom" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - -[[package]] -name = "libc" -version = "0.2.154" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - -[[package]] -name = "proc-macro2" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "serde" -version = "1.0.202" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.202" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" -dependencies = [ - "anyhow", - "bincode", - "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", - "serde", - "snowbridge-amcl", -] - -[[package]] -name = "sp1-zkvm" -version = "0.1.0" -dependencies = [ - "bincode", - "cfg-if", - "getrandom", - "k256", - "libm", - "once_cell", - "rand", - "serde", - "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/aggregation/programs/fibonacci/Cargo.toml b/examples/aggregation/programs/fibonacci/Cargo.toml deleted file mode 100644 index 6f08cf227..000000000 --- a/examples/aggregation/programs/fibonacci/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[workspace] -[package] -version = "0.1.0" -name = "fibonacci-program" -edition = "2021" - -[dependencies] -sp1-zkvm = { path = "../../../../zkvm/entrypoint" } diff --git a/examples/aggregation/programs/fibonacci/elf/riscv32im-succinct-zkvm-elf b/examples/aggregation/programs/fibonacci/elf/riscv32im-succinct-zkvm-elf deleted file mode 100755 index 0170fd08b..000000000 Binary files a/examples/aggregation/programs/fibonacci/elf/riscv32im-succinct-zkvm-elf and /dev/null differ diff --git a/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf index 6665fa85d..e67522c9f 100755 Binary files a/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf and b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/fibonacci/script/bin/execute.rs b/examples/fibonacci/script/bin/execute.rs index be8776b41..180da9cee 100644 --- a/examples/fibonacci/script/bin/execute.rs +++ b/examples/fibonacci/script/bin/execute.rs @@ -15,7 +15,7 @@ fn main() { // Only execute the program and get a `SP1PublicValues` object. let client = ProverClient::new(); - let mut public_values = client.execute(ELF, stdin).unwrap(); + let (mut public_values, _) = client.execute(ELF, stdin).unwrap(); println!("generated proof"); diff --git a/prover/Cargo.toml b/prover/Cargo.toml index fb10228f5..3bb4890ee 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -53,7 +53,5 @@ name = "e2e" path = "scripts/e2e.rs" [features] -default = ["plonk"] - neon = ["sp1-core/neon"] plonk = ["sp1-recursion-gnark-ffi/plonk"] diff --git a/prover/Makefile b/prover/Makefile index bc3ad6ef6..a63ebbbea 100644 --- a/prover/Makefile +++ b/prover/Makefile @@ -6,7 +6,7 @@ build-plonk-bn254: rm -rf build && \ mkdir -p build && \ RUSTFLAGS='-C target-cpu=native' \ - cargo run -p sp1-prover --release --bin build_plonk_bn254 -- \ + cargo run -p sp1-prover --release --bin build_plonk_bn254 --features plonk -- \ --build-dir=./build release-plonk-bn254: diff --git a/prover/scripts/build_plonk_bn254.rs b/prover/scripts/build_plonk_bn254.rs index 66ccb229d..e81d62147 100644 --- a/prover/scripts/build_plonk_bn254.rs +++ b/prover/scripts/build_plonk_bn254.rs @@ -1,6 +1,3 @@ -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - use std::path::PathBuf; use clap::Parser; diff --git a/prover/scripts/e2e.rs b/prover/scripts/e2e.rs index c4833f220..ac2f08170 100644 --- a/prover/scripts/e2e.rs +++ b/prover/scripts/e2e.rs @@ -1,6 +1,3 @@ -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - use std::borrow::Borrow; use std::path::PathBuf; diff --git a/prover/scripts/fibonacci_groth16.rs b/prover/scripts/fibonacci_groth16.rs index a17b37bb8..a1fcf2d64 100644 --- a/prover/scripts/fibonacci_groth16.rs +++ b/prover/scripts/fibonacci_groth16.rs @@ -1,8 +1,5 @@ //! Tests end-to-end performance of wrapping a recursion proof to PLONK. -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - use std::time::Instant; use itertools::iproduct; diff --git a/prover/scripts/fibonacci_sweep.rs b/prover/scripts/fibonacci_sweep.rs index 14f353662..d509ffb59 100644 --- a/prover/scripts/fibonacci_sweep.rs +++ b/prover/scripts/fibonacci_sweep.rs @@ -1,8 +1,5 @@ //! Sweeps end-to-end prover performance across a wide range of parameters for Fibonacci. -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - use std::{fs::File, io::BufWriter, io::Write, time::Instant}; use itertools::iproduct; diff --git a/prover/scripts/tendermint_sweep.rs b/prover/scripts/tendermint_sweep.rs index 37209895f..595970e6a 100644 --- a/prover/scripts/tendermint_sweep.rs +++ b/prover/scripts/tendermint_sweep.rs @@ -1,8 +1,5 @@ //! Sweeps end-to-end prover performance across a wide range of parameters for Tendermint. -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - use std::{fs::File, io::BufWriter, io::Write, time::Instant}; use itertools::iproduct; diff --git a/prover/src/install.rs b/prover/src/install.rs index cb4d08f16..873c50f68 100644 --- a/prover/src/install.rs +++ b/prover/src/install.rs @@ -10,7 +10,7 @@ use crate::utils::block_on; pub const PLONK_BN254_ARTIFACTS_URL_BASE: &str = "https://sp1-circuits.s3-us-east-2.amazonaws.com"; /// The current version of the plonk bn254 artifacts. -pub const PLONK_BN254_ARTIFACTS_COMMIT: &str = "57ad9e7d"; +pub const PLONK_BN254_ARTIFACTS_COMMIT: &str = "e48c01ec"; /// Install the latest plonk bn254 artifacts. /// diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 22111fbbd..73e3f27c0 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -7,8 +7,6 @@ //! 3. Wrap the shard proof into a SNARK-friendly field. //! 4. Wrap the last shard proof, proven over the SNARK-friendly field, into a PLONK proof. -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] #![allow(clippy::too_many_arguments)] #![allow(clippy::new_without_default)] @@ -28,7 +26,7 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator}; use rayon::prelude::*; use sp1_core::air::{PublicValues, Word}; pub use sp1_core::io::{SP1PublicValues, SP1Stdin}; -use sp1_core::runtime::{ExecutionError, Runtime}; +use sp1_core::runtime::{ExecutionError, ExecutionReport, Runtime}; use sp1_core::stark::{Challenge, StarkProvingKey}; use sp1_core::stark::{Challenger, MachineVerificationError}; use sp1_core::utils::{SP1CoreOpts, DIGEST_SIZE}; @@ -213,7 +211,10 @@ impl SP1Prover { /// Generate a proof of an SP1 program with the specified inputs. #[instrument(name = "execute", level = "info", skip_all)] - pub fn execute(elf: &[u8], stdin: &SP1Stdin) -> Result { + pub fn execute( + elf: &[u8], + stdin: &SP1Stdin, + ) -> Result<(SP1PublicValues, ExecutionReport), ExecutionError> { let program = Program::from(elf); let opts = SP1CoreOpts::default(); let mut runtime = Runtime::new(program, opts); @@ -222,7 +223,10 @@ impl SP1Prover { runtime.write_proof(proof.clone(), vkey.clone()); } runtime.run_untraced()?; - Ok(SP1PublicValues::from(&runtime.state.public_values_stream)) + Ok(( + SP1PublicValues::from(&runtime.state.public_values_stream), + runtime.report, + )) } /// Generate shard proofs which split up and prove the valid execution of a RISC-V program with diff --git a/recursion/core/src/poseidon2_wide/external.rs b/recursion/core/src/poseidon2_wide/external.rs index 6fb3bc870..9181d3a1f 100644 --- a/recursion/core/src/poseidon2_wide/external.rs +++ b/recursion/core/src/poseidon2_wide/external.rs @@ -61,8 +61,7 @@ impl MachineAir for Poseidon2WideChip>::width(self); for event in &input.poseidon2_events { - let mut row = Vec::new(); - row.resize(num_columns, F::zero()); + let mut row = vec![F::zero(); num_columns]; let mut cols = if use_sbox_3 { let cols: &mut Poseidon2SBoxCols = row.as_mut_slice().borrow_mut(); diff --git a/recursion/gnark-ffi/Cargo.toml b/recursion/gnark-ffi/Cargo.toml index a5270d58d..d10ed2fd3 100644 --- a/recursion/gnark-ffi/Cargo.toml +++ b/recursion/gnark-ffi/Cargo.toml @@ -21,6 +21,4 @@ cc = "1.0" cfg-if = "1.0" [features] -default = ["plonk"] - plonk = [] diff --git a/recursion/gnark-ffi/build.rs b/recursion/gnark-ffi/build.rs index 35c3f63f1..650744599 100644 --- a/recursion/gnark-ffi/build.rs +++ b/recursion/gnark-ffi/build.rs @@ -1,3 +1,5 @@ +#![allow(unused)] + use cfg_if::cfg_if; use std::env; use std::path::PathBuf; @@ -58,6 +60,12 @@ fn main() { // Link the Go library println!("cargo:rustc-link-search=native={}", dest_path.display()); println!("cargo:rustc-link-lib=static={}", lib_name); + + // Static linking doesn't really work on macos, so we need to link some system libs + if cfg!(target_os = "macos") { + println!("cargo:rustc-link-lib=framework=CoreFoundation"); + println!("cargo:rustc-link-lib=framework=Security"); + } } } } diff --git a/recursion/gnark-ffi/src/ffi.rs b/recursion/gnark-ffi/src/ffi.rs index 3ab6914cb..d7ecf9d61 100644 --- a/recursion/gnark-ffi/src/ffi.rs +++ b/recursion/gnark-ffi/src/ffi.rs @@ -1,3 +1,5 @@ +#![allow(unused)] + //! FFI bindings for the Go code. The functions exported in this module are safe to call from Rust. //! All C strings and other C memory should be freed in Rust, including C Strings returned by Go. //! Although we cast to *mut c_char because the Go signatures can't be immutable, the Go functions diff --git a/recursion/program/Makefile b/recursion/program/Makefile deleted file mode 100644 index a1430680b..000000000 --- a/recursion/program/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: - make fri-sweep - -fri-sweep: - mkdir -p experiments/results && \ - RUSTFLAGS='-C target-cpu=native -C target_feature=+avx512ifma,+avx512vl' \ - RUST_LOG=info \ - cargo run --package sp1-recursion-program --release --bin fri_sweep \ No newline at end of file diff --git a/recursion/program/src/commit.rs b/recursion/program/src/commit.rs index 0edff4bfe..100d74c40 100644 --- a/recursion/program/src/commit.rs +++ b/recursion/program/src/commit.rs @@ -3,6 +3,7 @@ use sp1_recursion_compiler::ir::{Array, Builder, Config, Ext, FromConstant, Usiz use crate::fri::types::{FriConfigVariable, TwoAdicPcsRoundVariable}; +/// Reference: [p3_commit::PolynomialSpace] pub trait PolynomialSpaceVariable: Sized + FromConstant { type Constant: PolynomialSpace; @@ -33,6 +34,7 @@ pub trait PolynomialSpaceVariable: Sized + FromConstant { ) -> Self; } +/// Reference: [p3_commit::Pcs] pub trait PcsVariable { type Domain: PolynomialSpaceVariable; diff --git a/recursion/program/src/lib.rs b/recursion/program/src/lib.rs index aa71142ee..dacc8c88c 100644 --- a/recursion/program/src/lib.rs +++ b/recursion/program/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] #![allow(type_alias_bounds)] #![allow(clippy::type_complexity)] #![allow(clippy::too_many_arguments)] diff --git a/recursion/program/src/machine/compress.rs b/recursion/program/src/machine/compress.rs index dcc85fed1..f8fbc857b 100644 --- a/recursion/program/src/machine/compress.rs +++ b/recursion/program/src/machine/compress.rs @@ -96,6 +96,8 @@ where deferred_vk, ); + builder.halt(); + builder.compile_program() } } @@ -472,7 +474,5 @@ where ); commit_public_values(builder, reduce_public_values); - - builder.halt(); } } diff --git a/recursion/program/src/machine/core.rs b/recursion/program/src/machine/core.rs index 916a25a2a..1b8635110 100644 --- a/recursion/program/src/machine/core.rs +++ b/recursion/program/src/machine/core.rs @@ -71,6 +71,8 @@ impl SP1RecursiveVerifier { }; SP1RecursiveVerifier::verify(&mut builder, &pcs, machine, input); + builder.halt(); + builder.compile_program() } } @@ -90,13 +92,39 @@ where /// This program represents a first recursive step in the verification of an SP1 proof /// consisting of one or more shards. Each shard proof is verified and its public values are /// aggregated into a single set representing the start and end state of the program execution - /// across all shards. + /// across all shards. + /// + /// # Constraints + /// + /// ## Verifying the STARK proofs. + /// For each shard, the verifier asserts the correctness of the STARK proof which is composed + /// of verifying the FRI proof for openings and verifying the constraints. + /// + /// ## Aggregating the shard public values. + /// + /// See [SP1Prover::verify] for the verification algorithm of a complete SP1 proof. In this + /// function, we are aggregating several shard proofs and attesting to an aggregated state which + /// reprersents all the shards. The consistency conditions of the aggregated state are + /// asserted in the following way: + /// + /// - Start pc for every shardf should be what the next pc declared in the previous shard was. + /// - Public input, deferred proof digests, and exit code should be the same in all shards. + /// + /// ## The leaf challenger. + /// A key difference between the recursive tree verification and the complete one in + /// [SP1Prover::verify] is that the recursive verifier has no way of reconstructiing the + /// chanllenger only from a part of the shard proof. Therefoee, the value of the leaf challenger + /// is witnessed in the program and the verifier assertds correctness given this challenger. + /// In the course of the recursive verification, the challenger is reconstructed by observing + /// the commitments one by one, and in the final step, the challenger is asserted to be the same + /// as the one witnessed here. pub fn verify( builder: &mut Builder, pcs: &TwoAdicFriPcsVariable, machine: &StarkMachine>, input: SP1RecursionMemoryLayoutVariable, ) { + // Read input. let SP1RecursionMemoryLayoutVariable { vk, shard_proofs, @@ -212,6 +240,8 @@ where }); // Assert compatibility of the shard values. + + // Assert that the committed value digests are all the same. for (word, current_word) in committed_value_digest .iter() .zip_eq(public_values.committed_value_digest.iter()) @@ -233,8 +263,6 @@ where // Assert that exit code is the same for all proofs. builder.assert_felt_eq(exit_code, public_values.exit_code); - // Assert that the committed value digests are all the same. - // Assert that the deferred proof digest is the same for all proofs. for (digest, current_digest) in deferred_proofs_digest .iter() @@ -243,16 +271,19 @@ where builder.assert_felt_eq(*digest, *current_digest); } - // Update the reconstruct challenger, cumulative sum, shard number, and program counter. + // Update the loop variables: the reconstruct challenger, cumulative sum, shard number, + // and program counter. + + // Increment the shard index by one. + builder.assign(current_shard, current_shard + C::F::one()); + + // Update the reconstruct challenger. reconstruct_challenger.observe(builder, proof.commitment.main_commit); for j in 0..machine.num_pv_elts() { let element = builder.get(&proof.public_values, j); reconstruct_challenger.observe(builder, element); } - // Increment the shard count by one. - builder.assign(current_shard, current_shard + C::F::one()); - // Update current_pc to be the end_pc of the current proof. builder.assign(current_pc, public_values.next_pc); @@ -267,6 +298,8 @@ where }); }); + // Write all values to the public values struct and commit to them. + // Compute vk digest. let vk_digest = hash_vkey(builder, &vk); let vk_digest: [Felt<_>; DIGEST_SIZE] = array::from_fn(|i| builder.get(&vk_digest, i)); @@ -281,6 +314,7 @@ where let cumulative_sum_arrray = array::from_fn(|i| builder.get(&cumulative_sum_arrray, i)); let zero: Felt<_> = builder.eval(C::F::zero()); + // Initialize the public values we will commit to. let mut recursion_public_values_stream = [zero; RECURSIVE_PROOF_NUM_PV_ELTS]; @@ -317,7 +351,5 @@ where }); commit_public_values(builder, recursion_public_values); - - builder.halt(); } } diff --git a/recursion/program/src/machine/deferred.rs b/recursion/program/src/machine/deferred.rs index 3df497d44..2ae232ab7 100644 --- a/recursion/program/src/machine/deferred.rs +++ b/recursion/program/src/machine/deferred.rs @@ -91,6 +91,8 @@ where SP1DeferredVerifier::verify(&mut builder, &pcs, machine, input); + builder.halt(); + builder.compile_program() } } @@ -114,7 +116,7 @@ where /// - Asserts that each of these proofs is valid as a `compress` proof. /// - Asserts that each of these proofs is complete by checking the `is_complete` flag in the /// proof's public values. - /// - Aggregates the proof information into an accumulated deferred digest. + /// - Aggregates the proof information into the accumulated deferred digest. pub fn verify( builder: &mut Builder, pcs: &TwoAdicFriPcsVariable, @@ -289,7 +291,5 @@ where deferred_public_values.is_complete = var2felt(builder, is_complete); commit_public_values(builder, deferred_public_values); - - builder.halt(); } } diff --git a/recursion/program/src/machine/utils.rs b/recursion/program/src/machine/utils.rs index 59540136b..c721dae72 100644 --- a/recursion/program/src/machine/utils.rs +++ b/recursion/program/src/machine/utils.rs @@ -22,6 +22,8 @@ use crate::{ }; /// Assertions on the public values describing a complete recursive proof state. +/// +/// See [SP1Prover::verify] for the verification algorithm of a complete SP1 proof. pub(crate) fn assert_complete( builder: &mut Builder, public_values: &RecursionPublicValues>, diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 3b7a122ff..6f0e06ff4 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -16,7 +16,7 @@ reqwest = { version = "0.12.4", features = [ "stream", ] } anyhow = "1.0.83" -sp1-prover = { path = "../prover", default-features = false } +sp1-prover = { path = "../prover" } sp1-core = { path = "../core" } futures = "0.3.30" bincode = "1.3.3" @@ -29,18 +29,24 @@ tracing = "0.1.40" hex = "0.4.3" log = "0.4.21" axum = "=0.7.5" -alloy-primitives = "0.7.0" -alloy-sol-types = "0.7.0" +alloy-sol-types = { version = "0.7.0", optional = true } sha2 = "0.10.8" dirs = "5.0.1" tempfile = "3.10.1" num-bigint = "0.4.5" cfg-if = "1.0" ethers = { version = "2", default-features = false } +strum_macros = "0.26.2" +strum = "0.26.2" [features] +default = ["network"] + neon = ["sp1-core/neon"] plonk = ["sp1-prover/plonk"] +# TODO: Once alloy has a 1.* release, we can likely remove this feature flag, as there will be less +# dependency resolution issues. +network = ["dep:alloy-sol-types"] [build-dependencies] vergen = { version = "8", default-features = false, features = [ diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 4f0a4b1c4..a48ef5e24 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -5,26 +5,33 @@ //! Visit the [Getting Started](https://succinctlabs.github.io/sp1/getting-started.html) section //! in the official SP1 documentation for a quick start guide. -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] - +#[rustfmt::skip] pub mod proto { pub mod network; } pub mod artifacts; -pub mod auth; -pub mod client; +#[cfg(feature = "network")] +pub mod network; +#[cfg(feature = "network")] +pub use crate::network::prover::NetworkProver; + pub mod provers; pub mod utils { pub use sp1_core::utils::setup_logger; } +use cfg_if::cfg_if; use std::{env, fmt::Debug, fs::File, path::Path}; use anyhow::{Ok, Result}; -pub use provers::{LocalProver, MockProver, NetworkProver, Prover}; + +pub use provers::{LocalProver, MockProver, Prover}; + use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use sp1_core::stark::{MachineVerificationError, ShardProof}; +use sp1_core::{ + runtime::ExecutionReport, + stark::{MachineVerificationError, ShardProof}, +}; pub use sp1_prover::{ CoreSC, HashableKey, InnerSC, OuterSC, PlonkBn254Proof, SP1Prover, SP1ProvingKey, SP1PublicValues, SP1Stdin, SP1VerifyingKey, @@ -85,8 +92,16 @@ impl ProverClient { "local" => Self { prover: Box::new(LocalProver::new()), }, - "network" => Self { - prover: Box::new(NetworkProver::new()), + "network" => { + cfg_if! { + if #[cfg(feature = "network")] { + Self { + prover: Box::new(NetworkProver::new()), + } + } else { + panic!("network feature is not enabled") + } + } }, _ => panic!( "invalid value for SP1_PROVER enviroment variable: expected 'local', 'mock', or 'network'" @@ -143,14 +158,20 @@ impl ProverClient { /// let client = ProverClient::network(); /// ``` pub fn network() -> Self { - Self { - prover: Box::new(NetworkProver::new()), + cfg_if! { + if #[cfg(feature = "network")] { + Self { + prover: Box::new(NetworkProver::new()), + } + } else { + panic!("network feature is not enabled") + } } } /// Executes the given program on the given input (without generating a proof). /// - /// Returns the public values of the program after it has been executed. + /// Returns the public values and execution report of the program after it has been executed. /// /// /// ### Examples @@ -168,9 +189,13 @@ impl ProverClient { /// stdin.write(&10usize); /// /// // Execute the program on the inputs. - /// let public_values = client.execute(elf, stdin).unwrap(); + /// let (public_values, report) = client.execute(elf, stdin).unwrap(); /// ``` - pub fn execute(&self, elf: &[u8], stdin: SP1Stdin) -> Result { + pub fn execute( + &self, + elf: &[u8], + stdin: SP1Stdin, + ) -> Result<(SP1PublicValues, ExecutionReport)> { Ok(SP1Prover::execute(elf, &stdin)?) } diff --git a/sdk/src/auth.rs b/sdk/src/network/auth.rs similarity index 98% rename from sdk/src/auth.rs rename to sdk/src/network/auth.rs index 2cf1c8c86..2f34fd0f0 100644 --- a/sdk/src/auth.rs +++ b/sdk/src/network/auth.rs @@ -15,6 +15,7 @@ sol! { uint64 nonce; uint64 deadline; uint32 mode; + string version; } struct SubmitProof { @@ -94,11 +95,13 @@ impl NetworkAuth { nonce: u64, deadline: u64, mode: i32, + version: &str, ) -> Result> { let type_struct = CreateProof { nonce, deadline, mode: mode as u32, + version: version.to_string(), }; self.sign_message(type_struct).await } diff --git a/sdk/src/client.rs b/sdk/src/network/client.rs similarity index 94% rename from sdk/src/client.rs rename to sdk/src/network/client.rs index 87403dbde..9b04ae3b0 100644 --- a/sdk/src/client.rs +++ b/sdk/src/network/client.rs @@ -1,7 +1,7 @@ use std::{env, time::Duration}; use crate::{ - auth::NetworkAuth, + network::auth::NetworkAuth, proto::network::{UnclaimProofRequest, UnclaimReason}, }; use anyhow::{Context, Ok, Result}; @@ -22,11 +22,14 @@ use crate::proto::network::{ }; /// The default RPC endpoint for the Succinct prover network. -const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.succinct.xyz/"; +pub const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.succinct.xyz/"; /// The default SP1 Verifier address on all chains. const DEFAULT_SP1_VERIFIER_ADDRESS: &str = "0xed2107448519345059eab9cddab42ddc78fbebe9"; +/// The timeout for a proof request to be fulfilled. +const TIMEOUT: Duration = Duration::from_secs(60 * 60); + pub struct NetworkClient { pub rpc: TwirpClient, pub http: HttpClientWithMiddleware, @@ -34,19 +37,21 @@ pub struct NetworkClient { } impl NetworkClient { + pub fn rpc_url() -> String { + env::var("PROVER_NETWORK_RPC").unwrap_or_else(|_| DEFAULT_PROVER_NETWORK_RPC.to_string()) + } + // Create a new NetworkClient with the given private key for authentication. pub fn new(private_key: &str) -> Self { let auth = NetworkAuth::new(private_key); - let rpc_url = env::var("PROVER_NETWORK_RPC") - .unwrap_or_else(|_| DEFAULT_PROVER_NETWORK_RPC.to_string()); - let twirp_http_client = HttpClient::builder() .pool_max_idle_per_host(0) .pool_idle_timeout(Duration::from_secs(240)) .build() .unwrap(); + let rpc_url = Self::rpc_url(); let rpc = TwirpClient::new(Url::parse(&rpc_url).unwrap(), twirp_http_client, vec![]).unwrap(); @@ -172,17 +177,18 @@ impl NetworkClient { elf: &[u8], stdin: &SP1Stdin, mode: ProofMode, + version: &str, ) -> Result { let start = SystemTime::now(); let since_the_epoch = start .duration_since(UNIX_EPOCH) .expect("Invalid start time"); - let deadline = since_the_epoch.as_secs() + 1000; + let deadline = since_the_epoch.as_secs() + TIMEOUT.as_secs(); let nonce = self.get_nonce().await?; let create_proof_signature = self .auth - .sign_create_proof_message(nonce, deadline, mode.into()) + .sign_create_proof_message(nonce, deadline, mode.into(), version) .await?; let res = self .rpc @@ -191,6 +197,7 @@ impl NetworkClient { nonce, deadline, mode: mode.into(), + version: version.to_string(), }) .await?; diff --git a/sdk/src/network/mod.rs b/sdk/src/network/mod.rs new file mode 100644 index 000000000..950aa1095 --- /dev/null +++ b/sdk/src/network/mod.rs @@ -0,0 +1,3 @@ +pub mod auth; +pub mod client; +pub mod prover; diff --git a/sdk/src/provers/network.rs b/sdk/src/network/prover.rs similarity index 82% rename from sdk/src/provers/network.rs rename to sdk/src/network/prover.rs index f86900e26..c4870fcac 100644 --- a/sdk/src/provers/network.rs +++ b/sdk/src/network/prover.rs @@ -2,20 +2,19 @@ use std::{env, time::Duration}; use crate::proto::network::ProofMode; use crate::{ - client::NetworkClient, + network::client::{NetworkClient, DEFAULT_PROVER_NETWORK_RPC}, proto::network::{ProofStatus, TransactionStatus}, Prover, }; use crate::{SP1CompressedProof, SP1PlonkBn254Proof, SP1Proof, SP1ProvingKey, SP1VerifyingKey}; use anyhow::{Context, Result}; use serde::de::DeserializeOwned; -use sp1_core::runtime::{Program, Runtime}; -use sp1_core::utils::SP1CoreOpts; +use sp1_prover::install::PLONK_BN254_ARTIFACTS_COMMIT; use sp1_prover::utils::block_on; use sp1_prover::{SP1Prover, SP1Stdin}; use tokio::{runtime, time::sleep}; -use super::LocalProver; +use crate::provers::{LocalProver, ProverType}; /// An implementation of [crate::ProverClient] that can generate proofs on a remote RPC server. pub struct NetworkProver { @@ -42,22 +41,34 @@ impl NetworkProver { mode: ProofMode, ) -> Result

{ let client = &self.client; - // Execute the runtime before creating the proof request. - let program = Program::from(elf); - let opts = SP1CoreOpts::default(); - let mut runtime = Runtime::new(program, opts); - runtime.write_vecs(&stdin.buffer); - for (proof, vkey) in stdin.proofs.iter() { - runtime.write_proof(proof.clone(), vkey.clone()); + + let skip_simulation = env::var("SKIP_SIMULATION") + .map(|val| val == "true") + .unwrap_or(false); + + if !skip_simulation { + let (_, report) = SP1Prover::execute(elf, &stdin)?; + log::info!( + "Simulation complete, cycles: {}", + report.total_instruction_count() + ); + } else { + log::info!("Skipping simulation"); } - runtime - .run_untraced() - .context("Failed to execute program")?; - log::info!("Simulation complete, cycles: {}", runtime.state.global_clk); - let proof_id = client.create_proof(elf, &stdin, mode).await?; + let version = PLONK_BN254_ARTIFACTS_COMMIT; + log::info!("Client version {}", version); + + let proof_id = client.create_proof(elf, &stdin, mode, version).await?; log::info!("Created {}", proof_id); + if NetworkClient::rpc_url() == DEFAULT_PROVER_NETWORK_RPC { + log::info!( + "View in explorer: https://explorer.succinct.xyz/{}", + proof_id.split('_').last().unwrap_or(&proof_id) + ); + } + let mut is_claimed = false; loop { let (status, maybe_proof) = client.get_proof_status::

(&proof_id).await?; @@ -78,10 +89,9 @@ impl NetworkProver { status.unclaim_description() )); } - _ => { - sleep(Duration::from_secs(1)).await; - } + _ => {} } + sleep(Duration::from_secs(2)).await; } } @@ -151,8 +161,8 @@ impl NetworkProver { } impl Prover for NetworkProver { - fn id(&self) -> String { - "remote".to_string() + fn id(&self) -> ProverType { + ProverType::Network } fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { diff --git a/sdk/src/proto/network.rs b/sdk/src/proto/network.rs index 3c8919d7e..5f36a2bd8 100644 --- a/sdk/src/proto/network.rs +++ b/sdk/src/proto/network.rs @@ -16,6 +16,9 @@ pub struct CreateProofRequest { /// The deadline for the proof request, signifying the latest time a fulfillment would be valid. #[prost(uint64, tag = "4")] pub deadline: u64, + /// The client version used, in the form of an 8-character git commit hash. + #[prost(string, tag = "5")] + pub version: ::prost::alloc::string::String, } /// The response for creating a proof. #[derive(serde::Serialize, serde::Deserialize)] @@ -241,6 +244,9 @@ pub struct RequestedProof { /// The mode for proof generation. #[prost(enumeration = "ProofMode", tag = "2")] pub mode: i32, + /// Proof requester's address. + #[prost(bytes = "vec", tag = "3")] + pub requester: ::prost::alloc::vec::Vec, } /// The response for getting proof requests by a given status. #[derive(serde::Serialize, serde::Deserialize)] @@ -306,7 +312,7 @@ impl ProofMode { /// /// The values are not transformed in any way and thus are considered stable /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub const fn as_str_name(&self) -> &'static str { + pub fn as_str_name(&self) -> &'static str { match self { ProofMode::Unspecified => "PROOF_MODE_UNSPECIFIED", ProofMode::Core => "PROOF_MODE_CORE", @@ -359,7 +365,7 @@ impl ProofStatus { /// /// The values are not transformed in any way and thus are considered stable /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub const fn as_str_name(&self) -> &'static str { + pub fn as_str_name(&self) -> &'static str { match self { ProofStatus::ProofUnspecifiedStatus => "PROOF_UNSPECIFIED_STATUS", ProofStatus::ProofPreparing => "PROOF_PREPARING", @@ -416,7 +422,7 @@ impl TransactionStatus { /// /// The values are not transformed in any way and thus are considered stable /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub const fn as_str_name(&self) -> &'static str { + pub fn as_str_name(&self) -> &'static str { match self { TransactionStatus::TransactionUnspecifiedStatus => "TRANSACTION_UNSPECIFIED_STATUS", TransactionStatus::TransactionScheduled => "TRANSACTION_SCHEDULED", diff --git a/sdk/src/provers/local.rs b/sdk/src/provers/local.rs index 41c9f56cf..5eadf79a3 100644 --- a/sdk/src/provers/local.rs +++ b/sdk/src/provers/local.rs @@ -7,6 +7,8 @@ use crate::{ SP1ProvingKey, SP1VerifyingKey, }; +use super::ProverType; + /// An implementation of [crate::ProverClient] that can generate end-to-end proofs locally. pub struct LocalProver { prover: SP1Prover, @@ -21,8 +23,8 @@ impl LocalProver { } impl Prover for LocalProver { - fn id(&self) -> String { - "local".to_string() + fn id(&self) -> ProverType { + ProverType::Local } fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { @@ -54,6 +56,7 @@ impl Prover for LocalProver { }) } + #[allow(unused)] fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { cfg_if! { if #[cfg(feature = "plonk")] { diff --git a/sdk/src/provers/mock.rs b/sdk/src/provers/mock.rs index 66b0dda20..f0d75b310 100644 --- a/sdk/src/provers/mock.rs +++ b/sdk/src/provers/mock.rs @@ -9,6 +9,8 @@ use sp1_prover::{ verify::verify_plonk_bn254_public_inputs, HashableKey, PlonkBn254Proof, SP1Prover, SP1Stdin, }; +use super::ProverType; + /// An implementation of [crate::ProverClient] that can generate mock proofs. pub struct MockProver { pub(crate) prover: SP1Prover, @@ -23,8 +25,8 @@ impl MockProver { } impl Prover for MockProver { - fn id(&self) -> String { - "mock".to_string() + fn id(&self) -> ProverType { + ProverType::Mock } fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { @@ -36,7 +38,7 @@ impl Prover for MockProver { } fn prove(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - let public_values = SP1Prover::execute(&pk.elf, &stdin)?; + let (public_values, _) = SP1Prover::execute(&pk.elf, &stdin)?; Ok(SP1ProofWithPublicValues { proof: vec![], stdin, @@ -53,7 +55,7 @@ impl Prover for MockProver { } fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - let public_values = SP1Prover::execute(&pk.elf, &stdin)?; + let (public_values, _) = SP1Prover::execute(&pk.elf, &stdin)?; Ok(SP1PlonkBn254Proof { proof: PlonkBn254Proof { public_inputs: [ diff --git a/sdk/src/provers/mod.rs b/sdk/src/provers/mod.rs index c18770333..4c731c43d 100644 --- a/sdk/src/provers/mod.rs +++ b/sdk/src/provers/mod.rs @@ -1,22 +1,29 @@ mod local; mod mock; -mod network; use crate::{SP1CompressedProof, SP1PlonkBn254Proof, SP1Proof}; use anyhow::Result; pub use local::LocalProver; pub use mock::MockProver; -pub use network::NetworkProver; use sp1_core::stark::MachineVerificationError; use sp1_prover::CoreSC; use sp1_prover::SP1CoreProofData; use sp1_prover::SP1Prover; use sp1_prover::SP1ReduceProof; use sp1_prover::{SP1ProvingKey, SP1Stdin, SP1VerifyingKey}; +use strum_macros::EnumString; + +/// The type of prover. +#[derive(Debug, PartialEq, EnumString)] +pub enum ProverType { + Local, + Mock, + Network, +} /// An implementation of [crate::ProverClient]. pub trait Prover: Send + Sync { - fn id(&self) -> String; + fn id(&self) -> ProverType; fn sp1_prover(&self) -> &SP1Prover;