Skip to content

Commit

Permalink
Add error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Jul 29, 2024
1 parent 9c7117a commit f44f9a4
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 6 deletions.
7 changes: 6 additions & 1 deletion evm_arithmetization/src/arithmetic/arithmetic_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ impl<F: RichField, const D: usize> ArithmeticStark<F, D> {
// to accommodate the range check columns. Also make sure the
// trace length is a power of two.
let padded_len = 1 << ALL_DEGREE_LOGS[TABLE_TO_SORTED_INDEX[*Table::Arithmetic]];
assert!(padded_len >= trace_rows.len());
assert!(
padded_len >= trace_rows.len(),
"Padded length {:?} is smaller than actual trace length {:?}",
padded_len,
trace_rows.len()
);
for _ in trace_rows.len()..std::cmp::max(padded_len, RANGE_MAX) {
trace_rows.push(vec![F::ZERO; columns::NUM_ARITH_COLUMNS]);
}
Expand Down
6 changes: 6 additions & 0 deletions evm_arithmetization/src/byte_packing/byte_packing_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ impl<F: RichField + Extendable<D>, const D: usize> BytePackingStark<F, D> {
}
}
assert!(num_rows >= rows.len());
assert!(
num_rows >= rows.len(),
"Padded length {:?} is smaller than actual trace length {:?}",
num_rows,
rows.len()
);

for _ in rows.len()..num_rows {
rows.push(self.generate_padding_row());
Expand Down
7 changes: 6 additions & 1 deletion evm_arithmetization/src/generation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,12 @@ fn simulate_cpu<F: Field>(
row.stack_len = F::from_canonical_usize(state.registers.stack_len);

let padded_len = 1 << ALL_DEGREE_LOGS[TABLE_TO_SORTED_INDEX[*Table::Cpu]];
assert!(padded_len >= state.traces.clock());
assert!(
padded_len >= state.traces.clock(),
"Padded length {:?} is smaller than actual trace length {:?}",
padded_len,
state.traces.clock()
);

loop {
// Padding.
Expand Down
8 changes: 7 additions & 1 deletion evm_arithmetization/src/keccak/keccak_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ impl<F: RichField + Extendable<D>, const D: usize> KeccakStark<F, D> {
rows.extend(rows_for_perm);
}

assert!(num_rows >= rows.len());
assert!(
num_rows >= rows.len(),
"Padded length {:?} is smaller than actual trace length {:?}",
num_rows,
rows.len()
);

while rows.len() < num_rows {
rows.push([F::ZERO; NUM_COLUMNS]);
}
Expand Down
7 changes: 6 additions & 1 deletion evm_arithmetization/src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ impl<F: RichField, const D: usize> LogicStark<F, D> {
) -> Vec<[F; NUM_COLUMNS]> {
let len = operations.len();
let padded_len = 1 << ALL_DEGREE_LOGS[TABLE_TO_SORTED_INDEX[*Table::Logic]];
assert!(padded_len >= len);
assert!(
padded_len >= len,
"Padded length {:?} is smaller than actual trace length {:?}",
padded_len,
len
);

let mut rows = Vec::with_capacity(padded_len);
for op in operations {
Expand Down
8 changes: 7 additions & 1 deletion evm_arithmetization/src/memory/memory_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,13 @@ impl<F: RichField + Extendable<D>, const D: usize> MemoryStark<F, D> {
// We want at least one padding row, so that the last real operation can have
// its flags set correctly.
let num_ops_padded = 1 << ALL_DEGREE_LOGS[TABLE_TO_SORTED_INDEX[*Table::Memory]];
assert!(num_ops_padded >= num_ops);
assert!(
num_ops_padded >= num_ops,
"Padded length {:?} is smaller than actual trace length {:?}",
num_ops_padded,
num_ops
);

for _ in num_ops..num_ops_padded {
memory_ops.push(padding_op);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ impl<F: RichField + Extendable<D>, const D: usize> MemoryContinuationStark<F, D>

let num_rows = rows.len();
let num_rows_padded = 1 << log_padded;
assert!(num_rows_padded >= num_rows);
assert!(
num_rows_padded >= num_rows,
"Padded length {:?} is smaller than actual trace length {:?}",
num_rows_padded,
num_rows
);

for _ in num_rows..num_rows_padded {
rows.push(vec![F::ZERO; NUM_COLUMNS]);
}
Expand Down

0 comments on commit f44f9a4

Please sign in to comment.