Skip to content

Commit

Permalink
Get range check inputs one by one.
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 committed Jul 16, 2024
1 parent 1a3a52f commit 9e2af28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
12 changes: 5 additions & 7 deletions stwo_cairo_prover/src/components/range_check_unit/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ impl ComponentGen for RangeCheckUnitTraceGenerator {}

impl ComponentTraceGenerator<CpuBackend> for RangeCheckUnitTraceGenerator {
type Component = RangeCheckUnitComponent;
type Inputs = Vec<BaseField>;
type Inputs = BaseField;

fn add_inputs(&mut self, inputs: &Self::Inputs) {
for input in inputs {
let input = input.0 as usize;
// TODO: replace the debug_assert! with an error return.
debug_assert!(input < self.max_value, "Input out of range");
self.multiplicities[input] += 1;
}
let input = inputs.0 as usize;
// TODO: replace the debug_assert! with an error return.
debug_assert!(input < self.max_value, "Input out of range");
self.multiplicities[input] += 1;
}

fn write_trace(
Expand Down
12 changes: 6 additions & 6 deletions stwo_cairo_prover/src/components/range_check_unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod tests {
use std::collections::BTreeMap;

use component::{RangeCheckUnitComponent, RangeCheckUnitTraceGenerator, RC_COMPONENT_ID, RC_Z};
use itertools::Itertools;
use stwo_prover::core::air::{Air, AirProver, Component, ComponentProver};
use stwo_prover::core::backend::CpuBackend;
use stwo_prover::core::channel::{Blake2sChannel, Channel};
Expand All @@ -28,7 +27,7 @@ mod tests {

pub fn register_test_rc(registry: &mut ComponentGenerationRegistry) {
registry.register(RC_COMPONENT_ID, RangeCheckUnitTraceGenerator::new(8));
let inputs = vec![
vec![
vec![BaseField::from_u32_unchecked(0); 3],
vec![BaseField::from_u32_unchecked(1); 1],
vec![BaseField::from_u32_unchecked(2); 2],
Expand All @@ -40,10 +39,11 @@ mod tests {
]
.into_iter()
.flatten()
.collect_vec();
registry
.get_generator_mut::<RangeCheckUnitTraceGenerator>(RC_COMPONENT_ID)
.add_inputs(&inputs);
.for_each(|input| {
registry
.get_generator_mut::<RangeCheckUnitTraceGenerator>(RC_COMPONENT_ID)
.add_inputs(&input);
});
}

struct TestAirGenerator {
Expand Down

0 comments on commit 9e2af28

Please sign in to comment.