-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: result instead of exit(1) on trap in recursion #1089
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,15 +443,10 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
let proofs = inputs | ||
.into_par_iter() | ||
.map(|input| { | ||
let proof = self.compress_machine_proof( | ||
input, | ||
&self.recursion_program, | ||
&self.rec_pk, | ||
opts, | ||
); | ||
(proof, ReduceProgramType::Core) | ||
self.compress_machine_proof(input, &self.recursion_program, &self.rec_pk, opts) | ||
.map(|p| (p, ReduceProgramType::Core)) | ||
}) | ||
.collect::<Vec<_>>(); | ||
.collect::<Result<Vec<_>, _>>()?; | ||
reduce_proofs.extend(proofs); | ||
} | ||
|
||
|
@@ -460,15 +455,15 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
let proofs = inputs | ||
.into_par_iter() | ||
.map(|input| { | ||
let proof = self.compress_machine_proof( | ||
self.compress_machine_proof( | ||
input, | ||
&self.deferred_program, | ||
&self.deferred_pk, | ||
opts, | ||
); | ||
(proof, ReduceProgramType::Deferred) | ||
) | ||
.map(|p| (p, ReduceProgramType::Deferred)) | ||
}) | ||
.collect::<Vec<_>>(); | ||
.collect::<Result<Vec<_>, _>>()?; | ||
reduce_proofs.extend(proofs); | ||
} | ||
|
||
|
@@ -482,7 +477,7 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
let batched_compress_inputs = | ||
compress_inputs.chunks(shard_batch_size).collect::<Vec<_>>(); | ||
reduce_proofs = batched_compress_inputs | ||
.into_iter() | ||
.into_par_iter() | ||
.flat_map(|batches| { | ||
batches | ||
.par_iter() | ||
|
@@ -498,17 +493,17 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
is_complete, | ||
}; | ||
|
||
let proof = self.compress_machine_proof( | ||
self.compress_machine_proof( | ||
input, | ||
&self.compress_program, | ||
&self.compress_pk, | ||
opts, | ||
); | ||
(proof, ReduceProgramType::Reduce) | ||
) | ||
.map(|p| (p, ReduceProgramType::Reduce)) | ||
}) | ||
.collect::<Vec<_>>() | ||
}) | ||
.collect::<Vec<_>>(); | ||
.collect::<Result<Vec<_>, _>>()?; | ||
|
||
if reduce_proofs.len() == 1 { | ||
break; | ||
|
@@ -528,7 +523,7 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
program: &RecursionProgram<BabyBear>, | ||
pk: &StarkProvingKey<InnerSC>, | ||
opts: SP1ProverOpts, | ||
) -> ShardProof<InnerSC> { | ||
) -> Result<ShardProof<InnerSC>, SP1RecursionProverError> { | ||
let mut runtime = RecursionRuntime::<Val<InnerSC>, Challenge<InnerSC>, _>::new( | ||
program, | ||
self.compress_prover.config().perm.clone(), | ||
|
@@ -538,11 +533,15 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
witness_stream.extend(input.write()); | ||
|
||
runtime.witness_stream = witness_stream.into(); | ||
runtime.run(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more canonical way to do this would be to do runtime.run().map_err(..)?; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
|
||
runtime | ||
.run() | ||
.map_err(|e| SP1RecursionProverError::RuntimeError(e.to_string()))?; | ||
runtime.print_stats(); | ||
|
||
let mut recursive_challenger = self.compress_prover.config().challenger(); | ||
self.compress_prover | ||
let proof = self | ||
.compress_prover | ||
.prove( | ||
pk, | ||
vec![runtime.record], | ||
|
@@ -552,7 +551,9 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
.unwrap() | ||
.shard_proofs | ||
.pop() | ||
.unwrap() | ||
.unwrap(); | ||
|
||
Ok(proof) | ||
} | ||
|
||
/// Wrap a reduce proof into a STARK proven over a SNARK-friendly field. | ||
|
@@ -579,7 +580,11 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
witness_stream.extend(input.write()); | ||
|
||
runtime.witness_stream = witness_stream.into(); | ||
runtime.run(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
runtime | ||
.run() | ||
.map_err(|e| SP1RecursionProverError::RuntimeError(e.to_string()))?; | ||
|
||
runtime.print_stats(); | ||
tracing::debug!("Compress program executed successfully"); | ||
|
||
|
@@ -623,7 +628,11 @@ impl<C: SP1ProverComponents> SP1Prover<C> { | |
witness_stream.extend(input.write()); | ||
|
||
runtime.witness_stream = witness_stream.into(); | ||
runtime.run(); | ||
|
||
runtime | ||
.run() | ||
.map_err(|e| SP1RecursionProverError::RuntimeError(e.to_string()))?; | ||
|
||
runtime.print_stats(); | ||
tracing::debug!("Wrap program executed successfully"); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,7 +294,7 @@ mod tests { | |
let program = basic_program::<F>(); | ||
let config = SC::new(); | ||
let mut runtime = Runtime::<F, EF, DiffusionMatrixBabyBear>::new_no_perm(&program); | ||
runtime.run(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unwrap There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
runtime.run().unwrap(); | ||
let machine = A::machine(config); | ||
let prover = DefaultProver::new(machine); | ||
let (pk, vk) = prover.setup(&program); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ fn main() { | |
|
||
let config = SC::new(); | ||
let mut runtime = Runtime::<F, EF, _>::new(&program, config.perm.clone()); | ||
runtime.run(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unwrap There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
runtime.run().unwrap(); | ||
|
||
// let machine = RecursionAir::machine(config); | ||
// let (pk, vk) = machine.setup(&program); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,7 +326,7 @@ mod tests { | |
let program = builder.compile_program(); | ||
|
||
let mut runtime = Runtime::<F, EF, _>::new(&program, config.perm.clone()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unrwap There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
runtime.run(); | ||
runtime.run().unwrap(); | ||
} | ||
|
||
#[test] | ||
|
@@ -363,6 +363,6 @@ mod tests { | |
let program = builder.compile_program(); | ||
|
||
let mut runtime = Runtime::<F, EF, _>::new(&program, config.perm.clone()); | ||
runtime.run(); | ||
runtime.run().unwrap(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems kind of free? Or is there a reason we chose to not do this concurrently? just lmk and I'll remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, good catch. That looks good :)