Skip to content

Commit 993333d

Browse files
committed
refactor: use mock client for mock proves
1 parent 38eea41 commit 993333d

File tree

1 file changed

+6
-40
lines changed
  • aggregation-mode/src/aggregator

1 file changed

+6
-40
lines changed
Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use sp1_aggregator::SP1CompressedProof;
2-
use sp1_sdk::{ProverClient, SP1ProofMode, SP1ProofWithPublicValues, SP1Stdin, SP1VerifyingKey};
2+
use sp1_sdk::{Prover, ProverClient, SP1ProofWithPublicValues, SP1Stdin, SP1VerifyingKey};
33

44
use super::interface::{AggregatedProof, AggregatedVerificationError, ProgramOutput};
55

@@ -13,23 +13,15 @@ pub struct SP1AggregatedProof {
1313
pub(crate) fn aggregate_proofs(
1414
proofs: Vec<SP1CompressedProof>,
1515
) -> Result<ProgramOutput, AggregatedVerificationError> {
16-
#[cfg(feature = "prove")]
17-
{
18-
prove(proofs)
19-
}
20-
// If not in prove mode, execute the program and create a mock proof
21-
#[cfg(not(feature = "prove"))]
22-
{
23-
mock_prove(proofs)
24-
}
25-
}
26-
27-
#[cfg(feature = "prove")]
28-
fn prove(proofs: Vec<SP1CompressedProof>) -> Result<ProgramOutput, AggregatedVerificationError> {
2916
let mut stdin = SP1Stdin::new();
3017
stdin.write(&proofs);
3118

19+
#[cfg(feature = "prove")]
3220
let client = ProverClient::from_env();
21+
// If not in prove mode, create a mock proof via mock client
22+
#[cfg(not(feature = "prove"))]
23+
let client = ProverClient::builder().mock().build();
24+
3325
let (pk, vk) = client.setup(PROGRAM_ELF);
3426
let proof = client
3527
.prove(&pk, &stdin)
@@ -46,29 +38,3 @@ fn prove(proofs: Vec<SP1CompressedProof>) -> Result<ProgramOutput, AggregatedVer
4638

4739
Ok(output)
4840
}
49-
50-
fn mock_prove(
51-
proofs: Vec<SP1CompressedProof>,
52-
) -> Result<ProgramOutput, AggregatedVerificationError> {
53-
let mut stdin = SP1Stdin::new();
54-
stdin.write(&proofs);
55-
56-
let client = ProverClient::from_env();
57-
let (pk, vk) = client.setup(PROGRAM_ELF);
58-
let (public_vales, _) = client
59-
.execute(PROGRAM_ELF, &stdin)
60-
.run()
61-
.map_err(|_| AggregatedVerificationError::SP1Proving)?;
62-
63-
let output = ProgramOutput::new(AggregatedProof::SP1(SP1AggregatedProof {
64-
proof: SP1ProofWithPublicValues::create_mock_proof(
65-
&pk,
66-
public_vales,
67-
SP1ProofMode::Groth16,
68-
"",
69-
),
70-
vk,
71-
}));
72-
73-
Ok(output)
74-
}

0 commit comments

Comments
 (0)