Skip to content

Commit

Permalink
fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Sep 14, 2024
1 parent dc2107b commit 70cb00f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ceno_zkvm/src/instructions/riscv/addsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ mod test {
.into_iter()
.map(|v| v.into())
.collect_vec(),
Some([100.into(), 100000.into()]),
None,
);
}
}
9 changes: 5 additions & 4 deletions ceno_zkvm/src/instructions/riscv/blt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl BltInput {
&self,
config: &InstructionConfig<E>,
instance: &mut [MaybeUninit<F>],
lk_multiplicity: &mut LkMultiplicity,
) {
assert!(!self.lhs_limb8.is_empty() && (self.lhs_limb8.len() == self.rhs_limb8.len()));
// TODO: add boundary check for witin
Expand Down Expand Up @@ -108,12 +109,12 @@ impl BltInput {
lhs: self.prev_rs1_ts as u64,
rhs: self.ts as u64,
}
.assign(instance, &config.lt_rs1_cfg);
.assign(instance, &config.lt_rs1_cfg, lk_multiplicity);
ExprLtInput {
lhs: self.prev_rs2_ts as u64,
rhs: (self.ts + 1) as u64,
}
.assign(instance, &config.lt_rs2_cfg);
.assign(instance, &config.lt_rs2_cfg, lk_multiplicity);
}

pub fn random() -> Self {
Expand Down Expand Up @@ -223,12 +224,12 @@ impl<E: ExtensionField> Instruction<E> for BltInstruction {
fn assign_instance(
config: &Self::InstructionConfig,
instance: &mut [std::mem::MaybeUninit<E::BaseField>],
_lk_multiplicity: &mut LkMultiplicity,
lk_multiplicity: &mut LkMultiplicity,
_step: &ceno_emul::StepRecord,
) -> Result<(), ZKVMError> {
// take input from _step
let input = BltInput::random();
input.assign(config, instance);
input.assign(config, instance, lk_multiplicity);
Ok(())
}
}
Expand Down
37 changes: 25 additions & 12 deletions ceno_zkvm/src/scheme/mock_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,11 @@ mod tests {
expression::{ToExpr, WitIn},
instructions::riscv::config::{ExprLtConfig, ExprLtInput},
set_val,
witness::RowMajorMatrix,
witness::{LkMultiplicity, RowMajorMatrix},
};
use ff::Field;
use goldilocks::{Goldilocks, GoldilocksExt2};
use multilinear_extensions::mle::{IntoMLE, IntoMLEs};
use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator};

#[derive(Debug)]
#[allow(dead_code)]
Expand Down Expand Up @@ -649,14 +648,15 @@ mod tests {
&self,
instance: &mut [MaybeUninit<E::BaseField>],
input: AssertLtCircuitInput,
lk_multiplicity: &mut LkMultiplicity,
) -> Result<(), ZKVMError> {
set_val!(instance, self.a, input.a);
set_val!(instance, self.b, input.b);
ExprLtInput {
lhs: input.a,
rhs: input.b,
}
.assign(instance, &self.lt_wtns);
.assign(instance, &self.lt_wtns, lk_multiplicity);

Ok(())
}
Expand All @@ -665,14 +665,16 @@ mod tests {
&self,
num_witin: usize,
instances: Vec<AssertLtCircuitInput>,
lk_multiplicity: &mut LkMultiplicity,
) -> Result<RowMajorMatrix<E::BaseField>, ZKVMError> {
let mut raw_witin = RowMajorMatrix::<E::BaseField>::new(instances.len(), num_witin);
let raw_witin_iter = raw_witin.par_iter_mut();
let raw_witin_iter = raw_witin.iter_mut();

raw_witin_iter
.zip_eq(instances.into_par_iter())
.map(|(instance, input)| self.assign_instance::<E>(instance, input))
.collect::<Result<(), ZKVMError>>()?;
.zip_eq(instances.into_iter())
.try_for_each(|(instance, input)| {
self.assign_instance::<E>(instance, input, lk_multiplicity)
})?;

Ok(raw_witin)
}
Expand All @@ -685,13 +687,15 @@ mod tests {

let circuit = AssertLtCircuit::construct_circuit(&mut builder).unwrap();

let mut lk_multiplicity = LkMultiplicity::default();
let raw_witin = circuit
.assign_instances::<GoldilocksExt2>(
builder.cs.num_witin as usize,
vec![
AssertLtCircuitInput { a: 3, b: 5 },
AssertLtCircuitInput { a: 7, b: 11 },
],
&mut lk_multiplicity,
)
.unwrap();

Expand All @@ -713,6 +717,7 @@ mod tests {
let mut builder = CircuitBuilder::<GoldilocksExt2>::new(&mut cs);

let circuit = AssertLtCircuit::construct_circuit(&mut builder).unwrap();
let mut lk_multiplicity = LkMultiplicity::default();
let raw_witin = circuit
.assign_instances::<GoldilocksExt2>(
builder.cs.num_witin as usize,
Expand All @@ -726,6 +731,7 @@ mod tests {
b: u32::MAX as u64 - 2,
},
],
&mut lk_multiplicity,
)
.unwrap();

Expand Down Expand Up @@ -765,14 +771,15 @@ mod tests {
&self,
instance: &mut [MaybeUninit<E::BaseField>],
input: LtCircuitInput,
lk_multiplicity: &mut LkMultiplicity,
) -> Result<(), ZKVMError> {
set_val!(instance, self.a, input.a);
set_val!(instance, self.b, input.b);
ExprLtInput {
lhs: input.a,
rhs: input.b,
}
.assign(instance, &self.lt_wtns);
.assign(instance, &self.lt_wtns, lk_multiplicity);

Ok(())
}
Expand All @@ -781,14 +788,16 @@ mod tests {
&self,
num_witin: usize,
instances: Vec<LtCircuitInput>,
lk_multiplicity: &mut LkMultiplicity,
) -> Result<RowMajorMatrix<E::BaseField>, ZKVMError> {
let mut raw_witin = RowMajorMatrix::<E::BaseField>::new(instances.len(), num_witin);
let raw_witin_iter = raw_witin.par_iter_mut();
let raw_witin_iter = raw_witin.iter_mut();

raw_witin_iter
.zip_eq(instances.into_par_iter())
.map(|(instance, input)| self.assign_instance::<E>(instance, input))
.collect::<Result<(), ZKVMError>>()?;
.zip_eq(instances.into_iter())
.try_for_each(|(instance, input)| {
self.assign_instance::<E>(instance, input, lk_multiplicity)
})?;

Ok(raw_witin)
}
Expand All @@ -801,13 +810,15 @@ mod tests {

let circuit = LtCircuit::construct_circuit(&mut builder).unwrap();

let mut lk_multiplicity = LkMultiplicity::default();
let raw_witin = circuit
.assign_instances::<GoldilocksExt2>(
builder.cs.num_witin as usize,
vec![
LtCircuitInput { a: 3, b: 5 },
LtCircuitInput { a: 7, b: 11 },
],
&mut lk_multiplicity,
)
.unwrap();

Expand All @@ -830,6 +841,7 @@ mod tests {

let circuit = LtCircuit::construct_circuit(&mut builder).unwrap();

let mut lk_multiplicity = LkMultiplicity::default();
let raw_witin = circuit
.assign_instances::<GoldilocksExt2>(
builder.cs.num_witin as usize,
Expand All @@ -843,6 +855,7 @@ mod tests {
b: u32::MAX as u64 - 5,
},
],
&mut lk_multiplicity,
)
.unwrap();

Expand Down

0 comments on commit 70cb00f

Please sign in to comment.