Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
umadayal committed Jan 29, 2025
1 parent b9d55ca commit d1bcfb7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions crates/stark/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>> + Air<SymbolicAirBuilder<Val
);

// Count the number of constraints.
let num_constraints = get_symbolic_constraints(
let num_main_constraints = get_symbolic_constraints(
&chip.air,
chip.preprocessed_width(),
PROOF_MAX_NUM_PVS,
)
.len();

let permutation_constraints = count_permutation_constraints(
let num_permutation_constraints = count_permutation_constraints(
&chip.sends,
&chip.receives,
chip.logup_batch_size(),
Expand All @@ -232,7 +232,7 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>> + Air<SymbolicAirBuilder<Val

(
prep_trace.map(move |t| (chip.name(), chip.local_only(), t)),
(chip_name, num_constraints + permutation_constraints),
(chip_name, num_main_constraints + num_permutation_constraints),
)
})
.unzip()
Expand Down
9 changes: 5 additions & 4 deletions crates/stark/src/permutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,12 @@ pub fn count_permutation_constraints<F: Field>(
let local_sends = scoped_sends.get(&InteractionScope::Local).unwrap_or(&empty);
let local_receives = scoped_receives.get(&InteractionScope::Local).unwrap_or(&empty);

let local_permutation_width =
local_permutation_trace_width(local_sends.len() + local_receives.len(), batch_size);
let num_local_interactions = local_sends.len() + local_receives.len();

if !local_sends.is_empty() || !local_receives.is_empty() {
// Loop over local_permutation_width - 1 iterations with one assert per iteration.
if num_local_interactions > 0 {
let local_permutation_width =
local_permutation_trace_width(num_local_interactions, batch_size);
// We loop over (local_permutation_width - 1) iterations with one assert per iteration.
count += local_permutation_width - 1;

// One assert that cumulative sum is initialized to `phi_local` on the first row.
Expand Down
4 changes: 3 additions & 1 deletion crates/stark/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ where

// Compute the quotient values.
let alpha: SC::Challenge = challenger.sample_ext_element::<SC::Challenge>();

let parent_span = tracing::debug_span!("compute quotient values");
let quotient_values = parent_span.in_scope(|| {
quotient_domains
Expand All @@ -432,6 +431,9 @@ where
let chip_num_constraints =
pk.constraints_map.get(&chips[i].name()).unwrap();

// Calculate powers of alpha for constraint evaluation:
// 1. Generate sequence [α⁰, α¹, ..., α^(n-1)] where n = chip_num_constraints
// 2. Reverse to [α^(n-1), ..., α¹, α⁰] to align with Horner's method in the verifier
let powers_of_alpha =
alpha.powers().take(*chip_num_constraints).collect::<Vec<_>>();
let mut powers_of_alpha_rev = powers_of_alpha.clone();
Expand Down

0 comments on commit d1bcfb7

Please sign in to comment.