Skip to content

Commit

Permalink
feat: nextgen ci for sp1-prover (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas authored May 6, 2024
1 parent 02c6ea6 commit c16cb9d
Show file tree
Hide file tree
Showing 13 changed files with 267 additions and 237 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:

jobs:
test:
name: Core
name: SP1 Prover E2E
runs-on: warp-ubuntu-latest-arm64-32x
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
Expand All @@ -36,13 +36,40 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: -p sp1-core -p sp1-recursion-compiler -p sp1-recursion-program -p sp1-recursion-circuit -p sp1-sdk --release
args: -p sp1-prover --release
env:
RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native
RUST_LOG: 1
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 1
FRI_QUERIES: 1
SP1_DEV_WRAPPER: false

test-main:
name: SP1 Tests
runs-on: warp-ubuntu-latest-arm64-32x
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Setup CI
uses: ./.github/actions/setup
with:
pull_token: ${{ secrets.PULL_TOKEN }}

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --release
env:
RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native
RUST_LOG: 1
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 1
FRI_QUERIES: 1
SP1_DEV_WRAPPER: false

lints:
name: Formatting & Clippy
Expand Down
30 changes: 15 additions & 15 deletions core/src/stark/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> StarkMachine<SC, A> {
vk: &StarkVerifyingKey<SC>,
proof: &MachineProof<SC>,
challenger: &mut SC::Challenger,
) -> Result<(), ProgramVerificationError<SC>>
) -> Result<(), MachineVerificationError<SC>>
where
SC::Challenger: Clone,
A: for<'a> Air<VerifierConstraintFolder<'a, SC>>,
Expand All @@ -312,7 +312,7 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> StarkMachine<SC, A> {

// Verify the shard proofs.
if proof.shard_proofs.is_empty() {
return Err(ProgramVerificationError::EmptyProof);
return Err(MachineVerificationError::EmptyProof);
}

tracing::debug_span!("verify shard proofs").in_scope(|| {
Expand All @@ -328,7 +328,7 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> StarkMachine<SC, A> {
&mut challenger.clone(),
shard_proof,
)
.map_err(ProgramVerificationError::InvalidSegmentProof)
.map_err(MachineVerificationError::InvalidSegmentProof)
})?;
}

Expand All @@ -343,7 +343,7 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> StarkMachine<SC, A> {
}
match sum.is_zero() {
true => Ok(()),
false => Err(ProgramVerificationError::NonZeroCumulativeSum),
false => Err(MachineVerificationError::NonZeroCumulativeSum),
}
})
}
Expand Down Expand Up @@ -461,7 +461,7 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> StarkMachine<SC, A> {
}
}

pub enum ProgramVerificationError<SC: StarkGenericConfig> {
pub enum MachineVerificationError<SC: StarkGenericConfig> {
InvalidSegmentProof(VerificationError<SC>),
InvalidGlobalProof(VerificationError<SC>),
NonZeroCumulativeSum,
Expand All @@ -471,41 +471,41 @@ pub enum ProgramVerificationError<SC: StarkGenericConfig> {
InvalidPublicValues(&'static str),
}

impl<SC: StarkGenericConfig> Debug for ProgramVerificationError<SC> {
impl<SC: StarkGenericConfig> Debug for MachineVerificationError<SC> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ProgramVerificationError::InvalidSegmentProof(e) => {
MachineVerificationError::InvalidSegmentProof(e) => {
write!(f, "Invalid segment proof: {:?}", e)
}
ProgramVerificationError::InvalidGlobalProof(e) => {
MachineVerificationError::InvalidGlobalProof(e) => {
write!(f, "Invalid global proof: {:?}", e)
}
ProgramVerificationError::NonZeroCumulativeSum => {
MachineVerificationError::NonZeroCumulativeSum => {
write!(f, "Non-zero cumulative sum")
}
ProgramVerificationError::InvalidPublicValuesDigest => {
MachineVerificationError::InvalidPublicValuesDigest => {
write!(f, "Invalid public values digest")
}
ProgramVerificationError::EmptyProof => {
MachineVerificationError::EmptyProof => {
write!(f, "Empty proof")
}
ProgramVerificationError::DebugInteractionsFailed => {
MachineVerificationError::DebugInteractionsFailed => {
write!(f, "Debug interactions failed")
}
ProgramVerificationError::InvalidPublicValues(s) => {
MachineVerificationError::InvalidPublicValues(s) => {
write!(f, "Invalid public values: {}", s)
}
}
}
}

impl<SC: StarkGenericConfig> std::fmt::Display for ProgramVerificationError<SC> {
impl<SC: StarkGenericConfig> std::fmt::Display for MachineVerificationError<SC> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(self, f)
}
}

impl<SC: StarkGenericConfig> std::error::Error for ProgramVerificationError<SC> {}
impl<SC: StarkGenericConfig> std::error::Error for MachineVerificationError<SC> {}

#[cfg(test)]
#[allow(non_snake_case)]
Expand Down
8 changes: 4 additions & 4 deletions core/src/utils/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const LOG_DEGREE_BOUND: usize = 31;
pub fn run_test_io(
program: Program,
inputs: SP1Stdin,
) -> Result<SP1PublicValues, crate::stark::ProgramVerificationError<BabyBearPoseidon2>> {
) -> Result<SP1PublicValues, crate::stark::MachineVerificationError<BabyBearPoseidon2>> {
let runtime = tracing::info_span!("runtime.run(...)").in_scope(|| {
let mut runtime = Runtime::new(program);
runtime.write_vecs(&inputs.buffer);
Expand All @@ -49,7 +49,7 @@ pub fn run_test(
program: Program,
) -> Result<
crate::stark::MachineProof<BabyBearPoseidon2>,
crate::stark::ProgramVerificationError<BabyBearPoseidon2>,
crate::stark::MachineVerificationError<BabyBearPoseidon2>,
> {
let runtime = tracing::info_span!("runtime.run(...)").in_scope(|| {
let mut runtime = Runtime::new(program);
Expand All @@ -64,7 +64,7 @@ pub fn run_test_core(
runtime: Runtime,
) -> Result<
crate::stark::MachineProof<BabyBearPoseidon2>,
crate::stark::ProgramVerificationError<BabyBearPoseidon2>,
crate::stark::MachineVerificationError<BabyBearPoseidon2>,
> {
let config = BabyBearPoseidon2::new();
let machine = RiscvAir::machine(config);
Expand All @@ -80,7 +80,7 @@ pub fn run_test_machine<SC, A>(
machine: StarkMachine<SC, A>,
pk: StarkProvingKey<SC>,
vk: StarkVerifyingKey<SC>,
) -> Result<crate::stark::MachineProof<SC>, crate::stark::ProgramVerificationError<SC>>
) -> Result<crate::stark::MachineProof<SC>, crate::stark::MachineVerificationError<SC>>
where
A: MachineAir<SC::Val>
+ for<'a> Air<ProverConstraintFolder<'a, SC>>
Expand Down
4 changes: 0 additions & 4 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ path = "scripts/tendermint_sweep.rs"
name = "fibonacci_groth16"
path = "scripts/fibonacci_groth16.rs"

[[bin]]
name = "e2e"
path = "scripts/e2e.rs"

[[bin]]
name = "test_groth16_verification"
path = "scripts/test_groth16_verification.rs"
Expand Down
105 changes: 0 additions & 105 deletions prover/scripts/e2e.rs

This file was deleted.

4 changes: 2 additions & 2 deletions prover/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ fn dummy_proof() -> (StarkVerifyingKey<OuterSC>, ShardProof<OuterSC>) {
tracing::info!("wrap");
let wrapped_proof = prover.wrap_bn254(&vk, shrink_proof);

(prover.wrap_vk, wrapped_proof)
(prover.wrap_vk, wrapped_proof.proof)
}

/// Build the verifier constraints and template witness for the circuit.
fn build_constraints(
pub fn build_constraints(
wrap_vk: &StarkVerifyingKey<OuterSC>,
wrapped_proof: &ShardProof<OuterSC>,
) -> (Vec<Constraint>, Witness<OuterConfig>) {
Expand Down
Loading

0 comments on commit c16cb9d

Please sign in to comment.