Skip to content

Commit

Permalink
fix: docs, initial range_lengths in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin-Ray committed Dec 19, 2024
1 parent 252818d commit f7b2992
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
10 changes: 2 additions & 8 deletions crates/proof-of-sql/src/sql/proof/first_round_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ pub struct FirstRoundBuilder {
num_post_result_challenges: usize,
/// The extra one evaluation lengths used in the proof.
one_evaluation_lengths: Vec<usize>,
/// The range length used in the proof.
/// The max of all `range_lengths` used in sumcheck.
range_length: usize,
}

impl Default for FirstRoundBuilder {
fn default() -> Self {
Self::new(0)
}
}

impl FirstRoundBuilder {
pub fn new(initial_range_length: usize) -> Self {
Self {
Expand All @@ -32,7 +26,7 @@ impl FirstRoundBuilder {
self.range_length
}

/// Update the range length used in the proof.
/// Update the range length used in the proof only if the new range is larger than the existing range.
pub(crate) fn update_range_length(&mut self, new_range_length: usize) {
if new_range_length > self.range_length {
self.range_length = new_range_length;
Expand Down
3 changes: 2 additions & 1 deletion crates/proof-of-sql/src/sql/proof_plans/filter_exec_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ fn we_can_get_an_empty_result_from_a_basic_filter_on_an_empty_table_using_first_
borrowed_varchar("d", [""; 0], &alloc),
borrowed_scalar("e", [0; 0], &alloc),
]);
let data_length = data.num_rows();
let t = "sxt.t".parse().unwrap();
let table_map = indexmap! {
t => data.clone()
Expand All @@ -192,7 +193,7 @@ fn we_can_get_an_empty_result_from_a_basic_filter_on_an_empty_table_using_first_
ColumnType::Decimal75(Precision::new(75).unwrap(), 0),
),
];
let first_round_builder = &mut FirstRoundBuilder::new(0);
let first_round_builder = &mut FirstRoundBuilder::new(data_length);
let res: OwnedTable<Curve25519Scalar> = ProvableQueryResult::from(expr.first_round_evaluate(
first_round_builder,
&alloc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ fn we_can_get_an_empty_result_from_a_basic_projection_on_an_empty_table_using_fi
borrowed_varchar("d", [""; 0], &alloc),
borrowed_scalar("e", [0; 0], &alloc),
]);
let data_length = data.num_rows();
let t = "sxt.t".parse().unwrap();
let table_map = indexmap! {
t => data.clone()
Expand All @@ -174,7 +175,7 @@ fn we_can_get_an_empty_result_from_a_basic_projection_on_an_empty_table_using_fi
ColumnType::Decimal75(Precision::new(75).unwrap(), 0),
),
];
let first_round_builder = &mut FirstRoundBuilder::new(0);
let first_round_builder = &mut FirstRoundBuilder::new(data_length);
let res: OwnedTable<Curve25519Scalar> = ProvableQueryResult::from(expr.first_round_evaluate(
first_round_builder,
&alloc,
Expand Down
3 changes: 2 additions & 1 deletion crates/proof-of-sql/src/sql/proof_plans/slice_exec_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn we_can_get_an_empty_result_from_a_slice_on_an_empty_table_using_first_round_e
borrowed_varchar("d", [""; 0], &alloc),
borrowed_scalar("e", [0; 0], &alloc),
]);
let data_length = data.num_rows();
let t = "sxt.t".parse().unwrap();
let table_map = indexmap! {
t => data.clone()
Expand All @@ -102,7 +103,7 @@ fn we_can_get_an_empty_result_from_a_slice_on_an_empty_table_using_first_round_e
ColumnType::Decimal75(Precision::new(75).unwrap(), 0),
),
];
let first_round_builder = &mut FirstRoundBuilder::new(0);
let first_round_builder = &mut FirstRoundBuilder::new(data_length);
let res: OwnedTable<Curve25519Scalar> = ProvableQueryResult::from(expr.first_round_evaluate(
first_round_builder,
&alloc,
Expand Down
8 changes: 7 additions & 1 deletion crates/proof-of-sql/src/sql/proof_plans/union_exec_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ fn we_can_get_result_from_union_using_first_round_evaluate() {
borrowed_bigint("a0", [1_i64, 2, 3, 4, 5], &alloc),
borrowed_varchar("b0", ["1", "2", "3", "4", "5"], &alloc),
]);
let len_0 = data0.num_rows();
let t0 = "sxt.t0".parse().unwrap();
let data1 = table([
borrowed_bigint("a1", [2_i64, 3, 4, 5, 6], &alloc),
Expand All @@ -258,6 +259,11 @@ fn we_can_get_result_from_union_using_first_round_evaluate() {
t0 => data0.clone(),
t1 => data1.clone()
};

let len_1 = data1.num_rows();

let data_length = std::cmp::max(len_0, len_1);

let mut accessor = TableTestAccessor::<InnerProductProof>::new_empty_with_setup(());
accessor.add_table(t0, data0, 0);
accessor.add_table(t1, data1, 0);
Expand All @@ -272,7 +278,7 @@ fn we_can_get_result_from_union_using_first_round_evaluate() {
],
fields.clone(),
);
let first_round_builder = &mut FirstRoundBuilder::new(0);
let first_round_builder = &mut FirstRoundBuilder::new(data_length);
let res: OwnedTable<Curve25519Scalar> = ProvableQueryResult::from(ast.first_round_evaluate(
first_round_builder,
&alloc,
Expand Down

0 comments on commit f7b2992

Please sign in to comment.