From 097e32441b74f18ad59ba9cf89abc0fa3cf22c4c Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Mon, 29 Jul 2024 19:37:33 -0400 Subject: [PATCH] Add error msg --- evm_arithmetization/src/arithmetic/arithmetic_stark.rs | 7 ++++++- .../src/byte_packing/byte_packing_stark.rs | 6 ++++++ evm_arithmetization/src/generation/mod.rs | 7 ++++++- evm_arithmetization/src/keccak/keccak_stark.rs | 8 +++++++- evm_arithmetization/src/logic.rs | 7 ++++++- evm_arithmetization/src/memory/memory_stark.rs | 8 +++++++- .../src/memory_continuation/memory_continuation_stark.rs | 8 +++++++- 7 files changed, 45 insertions(+), 6 deletions(-) diff --git a/evm_arithmetization/src/arithmetic/arithmetic_stark.rs b/evm_arithmetization/src/arithmetic/arithmetic_stark.rs index 76aee1b14..ea5224213 100644 --- a/evm_arithmetization/src/arithmetic/arithmetic_stark.rs +++ b/evm_arithmetization/src/arithmetic/arithmetic_stark.rs @@ -179,7 +179,12 @@ impl ArithmeticStark { // 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]); } diff --git a/evm_arithmetization/src/byte_packing/byte_packing_stark.rs b/evm_arithmetization/src/byte_packing/byte_packing_stark.rs index 0745f25f5..e9ed60d92 100644 --- a/evm_arithmetization/src/byte_packing/byte_packing_stark.rs +++ b/evm_arithmetization/src/byte_packing/byte_packing_stark.rs @@ -185,6 +185,12 @@ impl, const D: usize> BytePackingStark { } } 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()); diff --git a/evm_arithmetization/src/generation/mod.rs b/evm_arithmetization/src/generation/mod.rs index beaa8e693..9b0f56919 100644 --- a/evm_arithmetization/src/generation/mod.rs +++ b/evm_arithmetization/src/generation/mod.rs @@ -487,7 +487,12 @@ fn simulate_cpu( 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. diff --git a/evm_arithmetization/src/keccak/keccak_stark.rs b/evm_arithmetization/src/keccak/keccak_stark.rs index 931aafba4..85ddc8a6a 100644 --- a/evm_arithmetization/src/keccak/keccak_stark.rs +++ b/evm_arithmetization/src/keccak/keccak_stark.rs @@ -80,7 +80,13 @@ impl, const D: usize> KeccakStark { 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]); } diff --git a/evm_arithmetization/src/logic.rs b/evm_arithmetization/src/logic.rs index a1fe07073..6a470ee9d 100644 --- a/evm_arithmetization/src/logic.rs +++ b/evm_arithmetization/src/logic.rs @@ -221,7 +221,12 @@ impl LogicStark { ) -> 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 { diff --git a/evm_arithmetization/src/memory/memory_stark.rs b/evm_arithmetization/src/memory/memory_stark.rs index 129a1f88d..9fe8236bc 100644 --- a/evm_arithmetization/src/memory/memory_stark.rs +++ b/evm_arithmetization/src/memory/memory_stark.rs @@ -354,7 +354,13 @@ impl, const D: usize> MemoryStark { // 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); } diff --git a/evm_arithmetization/src/memory_continuation/memory_continuation_stark.rs b/evm_arithmetization/src/memory_continuation/memory_continuation_stark.rs index 98f87867b..539e04cb1 100644 --- a/evm_arithmetization/src/memory_continuation/memory_continuation_stark.rs +++ b/evm_arithmetization/src/memory_continuation/memory_continuation_stark.rs @@ -87,7 +87,13 @@ impl, const D: usize> MemoryContinuationStark let num_rows = rows.len(); let num_rows_padded = 1 << log_padded; - assert!(num_rows_padded >= num_rows); + assert!( + num_ops_padded >= num_rows, + "Padded length {:?} is smaller than actual trace length {:?}", + num_ops_padded, + num_rows + ); + for _ in num_rows..num_rows_padded { rows.push(vec![F::ZERO; NUM_COLUMNS]); }