Skip to content

Commit

Permalink
refactor: deprecate method num_quotients()
Browse files Browse the repository at this point in the history
Deprecate thin wrapper around a constant that can be used directly.
  • Loading branch information
jan-ferdinand committed Mar 14, 2024
1 parent 6bf3557 commit 363ae77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 7 additions & 4 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::proof_item::ProofItem;
use crate::proof_stream::ProofStream;
use crate::table::challenges::Challenges;
use crate::table::extension_table::Evaluable;
use crate::table::extension_table::Quotientable;
use crate::table::master_table::*;
use crate::table::QuotientSegments;

Expand Down Expand Up @@ -199,7 +200,8 @@ impl Stark {
// Create quotient codeword. This is a part of the combination codeword. To reduce the
// amount of hashing necessary, the quotient codeword is linearly summed instead of
// hashed prior to committing to it.
let quotient_combination_weights = proof_stream.sample_scalars(num_quotients());
let quotient_combination_weights =
proof_stream.sample_scalars(MasterExtTable::NUM_CONSTRAINTS);
let quotient_combination_weights = Array1::from(quotient_combination_weights);
assert_eq!(
quotient_combination_weights.len(),
Expand Down Expand Up @@ -716,7 +718,7 @@ impl Stark {
let extension_tree_merkle_root = proof_stream.dequeue()?.try_into_merkle_root()?;
// Sample weights for quotient codeword, which is a part of the combination codeword.
// See corresponding part in the prover for a more detailed explanation.
let quot_codeword_weights = proof_stream.sample_scalars(num_quotients());
let quot_codeword_weights = proof_stream.sample_scalars(MasterExtTable::NUM_CONSTRAINTS);
let quot_codeword_weights = Array1::from(quot_codeword_weights);
let quotient_codeword_merkle_root = proof_stream.dequeue()?.try_into_merkle_root()?;
prof_stop!(maybe_profiler, "Fiat-Shamir 1");
Expand Down Expand Up @@ -784,7 +786,7 @@ impl Stark {
prof_stop!(maybe_profiler, "evaluate AIR");

prof_start!(maybe_profiler, "divide");
let mut quotient_summands = Vec::with_capacity(num_quotients());
let mut quotient_summands = Vec::with_capacity(MasterExtTable::NUM_CONSTRAINTS);
for (evaluated_constraints_category, zerofier_inverse) in [
(evaluated_initial_constraints, initial_zerofier_inv),
(evaluated_consistency_constraints, consistency_zerofier_inv),
Expand Down Expand Up @@ -2485,7 +2487,8 @@ pub(crate) mod tests {
vm_state.run().unwrap();

let output_list_ptr = vm_state.op_stack.pop().unwrap().value();
Self::read_xfe_list_at_address(vm_state.ram, output_list_ptr, num_quotients())
let num_quotients = MasterExtTable::NUM_CONSTRAINTS;
Self::read_xfe_list_at_address(vm_state.ram, output_list_ptr, num_quotients)
}

fn tasm_constraint_evaluation_code(&self) -> Program {
Expand Down
7 changes: 6 additions & 1 deletion triton-vm/src/table/master_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,8 @@ pub fn all_quotients(
);

prof_start!(maybe_profiler, "malloc");
let mut quotient_table = Array2::uninit([quotient_domain.length, num_quotients()]);
let mut quotient_table =
Array2::uninit([quotient_domain.length, MasterExtTable::NUM_CONSTRAINTS]);
prof_stop!(maybe_profiler, "malloc");

let init_section_end = MasterExtTable::NUM_INITIAL_CONSTRAINTS;
Expand Down Expand Up @@ -1111,6 +1112,10 @@ pub fn all_quotients(
unsafe { quotient_table.assume_init() }
}

#[deprecated(
since = "0.39.0",
note = "use `MasterExtTable::NUM_CONSTRAINTS` directly instead"
)]
pub const fn num_quotients() -> usize {
MasterExtTable::NUM_CONSTRAINTS
}
Expand Down

0 comments on commit 363ae77

Please sign in to comment.