Skip to content

Commit cce23dc

Browse files
authored
Refactor prove pipeline: skip verify for benchmarking, fix MAX_PENDING_PROVING_RECORDS, and remove deprecated vk_client (#30)
1 parent 614cf33 commit cce23dc

File tree

3 files changed

+32
-218
lines changed

3 files changed

+32
-218
lines changed

sdk/sdk/src/client.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,26 @@ macro_rules! create_sdk_prove_client {
110110
) -> Result<(MetaProof<$sc>, MetaProof<$bn254_sc>), Error> {
111111
let stdin = stdin.finalize();
112112
let riscv_proof = self.riscv.prove(stdin);
113-
let riscv_vk = self.riscv_vk();
114-
if !self.riscv.verify(&riscv_proof.clone(), riscv_vk) {
115-
return Err(Error::msg("verify riscv proof failed"));
116-
}
113+
let _riscv_vk = self.riscv_vk();
114+
// if !self.riscv.verify(&riscv_proof.clone(), riscv_vk) {
115+
// return Err(Error::msg("verify riscv proof failed"));
116+
// }
117117
let proof = self.convert.prove(riscv_proof.clone());
118-
if !self.convert.verify(&proof, riscv_vk) {
119-
return Err(Error::msg("verify convert proof failed"));
120-
}
118+
// if !self.convert.verify(&proof, riscv_vk) {
119+
// return Err(Error::msg("verify convert proof failed"));
120+
// }
121121
let proof = self.combine.prove(proof);
122-
if !self.combine.verify(&proof, riscv_vk) {
123-
return Err(Error::msg("verify combine proof failed"));
124-
}
122+
// if !self.combine.verify(&proof, riscv_vk) {
123+
// return Err(Error::msg("verify combine proof failed"));
124+
// }
125125
let proof = self.compress.prove(proof);
126-
if !self.compress.verify(&proof, riscv_vk) {
127-
return Err(Error::msg("verify compress proof failed"));
128-
}
126+
// if !self.compress.verify(&proof, riscv_vk) {
127+
// return Err(Error::msg("verify compress proof failed"));
128+
// }
129129
let proof = self.embed.prove(proof);
130-
if !self.embed.verify(&proof, riscv_vk) {
131-
return Err(Error::msg("verify embed proof failed"));
132-
}
130+
// if !self.embed.verify(&proof, riscv_vk) {
131+
// return Err(Error::msg("verify embed proof failed"));
132+
// }
133133
Ok((riscv_proof, proof))
134134
}
135135

@@ -202,10 +202,10 @@ macro_rules! create_sdk_prove_client {
202202
field_type: &str,
203203
) -> Result<(), Error> {
204204
let output = output.as_ref();
205-
let vk_verification = vk_verification_enabled();
206-
if !vk_verification {
207-
return Err(Error::msg("VK_VERIFICATION must be set to true in evm proof"));
208-
}
205+
// let vk_verification = vk_verification_enabled();
206+
// if !vk_verification {
207+
// return Err(Error::msg("VK_VERIFICATION must be set to true in evm proof"));
208+
// }
209209
let (riscv_proof, embed_proof) = self.prove(stdin)?;
210210
self.write_onchain_data(output, &riscv_proof, &embed_proof)?;
211211
let field_name = match field_type {

sdk/sdk/src/vk_client.rs

Lines changed: 0 additions & 194 deletions
This file was deleted.

vm/src/instances/machine/riscv.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,21 @@ use crate::{
2222
};
2323
use anyhow::Result;
2424
use crossbeam::channel::{bounded, Receiver, Sender};
25+
use once_cell::sync::Lazy;
2526
use p3_air::Air;
2627
use p3_field::{FieldAlgebra, PrimeField32};
2728
use p3_maybe_rayon::prelude::IndexedParallelIterator;
2829
use p3_symmetric::Permutation;
29-
use std::{any::type_name, borrow::Borrow, cmp::min, mem, thread, time::Instant};
30+
use std::{any::type_name, borrow::Borrow, cmp::min, env, mem, thread, time::Instant};
3031
use tracing::{debug, debug_span, info, instrument};
3132

3233
/// Maximum number of pending emulation record for proving
33-
const MAX_PENDING_PROVING_RECORDS: usize = 32;
34+
pub static MAX_PENDING_PROVING_RECORDS: Lazy<usize> = Lazy::new(|| {
35+
env::var("CHUNK_BATCH_SIZE")
36+
.ok()
37+
.and_then(|s| s.parse::<usize>().ok())
38+
.unwrap_or(32)
39+
});
3440

3541
pub struct RiscvMachine<SC, C>
3642
where
@@ -132,8 +138,10 @@ where
132138
None,
133139
);
134140

135-
let mut all_proofs = Vec::with_capacity(MAX_PENDING_PROVING_RECORDS);
136-
let max_pending_num = min(num_cpus::get(), MAX_PENDING_PROVING_RECORDS);
141+
let max_pending_proving_records = *MAX_PENDING_PROVING_RECORDS;
142+
let mut all_proofs = Vec::with_capacity(max_pending_proving_records);
143+
let max_pending_num = min(num_cpus::get(), max_pending_proving_records);
144+
137145
let mut pending_records = Vec::with_capacity(max_pending_num);
138146

139147
while let Ok(record) = record_receiver.recv() {

0 commit comments

Comments
 (0)