Skip to content

Commit

Permalink
finally! -- fixed domain size mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Jan 16, 2025
1 parent bd058b7 commit 609773f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions o1vm/src/pickles/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ark_ff::{UniformRand, Zero};
use ark_poly::domain;
use clap::Parser;
use kimchi::{circuits::domains::EvaluationDomains, precomputed_srs::TestSRS};
use kimchi_msm::expr::E;
Expand All @@ -25,8 +26,6 @@ use poly_commitment::{ipa::SRS, SRS as _};
use rand::rngs::ThreadRng;
use std::{fs::File, io::BufReader, path::Path, process::ExitCode, time::Instant};

pub const DOMAIN_SIZE: usize = 1 << 15;

pub fn cannon_main(args: cli::cannon::RunArgs) {
let mut rng = rand::thread_rng();

Expand All @@ -49,8 +48,7 @@ pub fn cannon_main(args: cli::cannon::RunArgs) {
// Initialize some data used for statistical computations
let start = Start::create(state.step as usize);

let domain_fp = EvaluationDomains::<Fp>::create(DOMAIN_SIZE).unwrap();
let srs: SRS<Vesta> = match &args.srs_cache {
let (srs, domain_fp) = match &args.srs_cache {
Some(cache) => {
debug!("Loading SRS from cache {}", cache);
let file_path = Path::new(cache);
Expand All @@ -72,14 +70,17 @@ pub fn cannon_main(args: cli::cannon::RunArgs) {
}
};
debug!("SRS loaded successfully from cache");
srs
let domain_fp = EvaluationDomains::<Fp>::create(srs.size()).unwrap();
(srs, domain_fp)
}
None => {
debug!("No SRS cache provided. Creating SRS from scratch");
let srs = SRS::create(DOMAIN_SIZE);
let domain_size = 2 << 16;
let domain_fp = EvaluationDomains::<Fp>::create(domain_size).unwrap();
let srs = SRS::create(domain_size);
srs.get_lagrange_basis(domain_fp.d1);
debug!("SRS created successfully");
srs
(srs, domain_fp)
}
};

Expand Down Expand Up @@ -107,7 +108,8 @@ pub fn cannon_main(args: cli::cannon::RunArgs) {

let constraints = mips_constraints::get_all_constraints::<Fp>();

let mut curr_proof_inputs: ProofInputs<Vesta> = ProofInputs::new(DOMAIN_SIZE);
let domain_size = domain_fp.d1.size as usize;
let mut curr_proof_inputs: ProofInputs<Vesta> = ProofInputs::new(domain_size);

while !mips_wit_env.halt {
step_prover(
Expand All @@ -119,17 +121,17 @@ pub fn cannon_main(args: cli::cannon::RunArgs) {
&mut rng,
);

if curr_proof_inputs.evaluations.instruction_counter.len() == DOMAIN_SIZE {
debug!("Limit of {DOMAIN_SIZE} reached. We make a proof, verify it (for testing) and start with a new chunk");
if curr_proof_inputs.evaluations.instruction_counter.len() == domain_size {
debug!("Limit of {domain_size} reached. We make a proof, verify it (for testing) and start with a new chunk");
prove_and_verify(domain_fp, &srs, &constraints, curr_proof_inputs, &mut rng);

curr_proof_inputs = ProofInputs::new(DOMAIN_SIZE);
curr_proof_inputs = ProofInputs::new(domain_size);
}
}

// debug!("Before padding {:?}", curr_proof_inputs);

if curr_proof_inputs.evaluations.instruction_counter.len() < DOMAIN_SIZE {
if curr_proof_inputs.evaluations.instruction_counter.len() < domain_size {
debug!(
"Evaluation ended with {} elements. Pad it to prove and verify",
curr_proof_inputs.evaluations.instruction_counter.len()
Expand Down

0 comments on commit 609773f

Please sign in to comment.