Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/circuit_common/src/component_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use circuits::eval;
use circuits::ivalue::IValue;
use circuits::ops::eq;
use circuits_stark_verifier::constraint_eval::*;
use stwo_cairo_common::preprocessed_columns::preprocessed_trace::MAX_SEQUENCE_LOG_SIZE;
use stwo_constraint_framework::preprocessed_columns::PreProcessedColumnId;

// Create a variable with the evaluation of seq_k where k is the log-height of
Expand All @@ -20,14 +21,14 @@ pub fn seq_of_component_size<Value: IValue>(
let mut sum_bits = context.zero();
let mut result = context.zero();

for log_size in 0..component_data.max_component_size_bits() {
for log_size in 0..=MAX_SEQUENCE_LOG_SIZE {
let seq_name = PreProcessedColumnId { id: format!("seq_{log_size}") };
let Some(seq_value) = preprocessed_columns.get(&seq_name) else {
// Our preprocessed trace doesn't contain a seq column of this size
continue;
};

let bit = component_data.get_n_instances_bit(context, log_size);
let bit = component_data.get_n_instances_bit(context, log_size.try_into().unwrap());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out-of-bounds instance bit index

High Severity

The loop now runs through MAX_SEQUENCE_LOG_SIZE, but when a matching seq_k column exists in preprocessed_columns for k at or above max_component_size_bits(), get_n_instances_bit indexes past the end of n_instances_bits (length log_trace_size + 1) and panics. The previous loop stopped at max_component_size_bits() and never hit those indices.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1c0fd5a. Configure here.


sum_bits = eval!(context, (sum_bits) + (bit));
result = eval!(context, (result) + ((bit) * (*seq_value)))
Expand Down
Loading