diff --git a/evm_arithmetization/src/memory/columns.rs b/evm_arithmetization/src/memory/columns.rs index 0051bbe5d..459554ea4 100644 --- a/evm_arithmetization/src/memory/columns.rs +++ b/evm_arithmetization/src/memory/columns.rs @@ -39,15 +39,22 @@ pub(crate) const SEGMENT_FIRST_CHANGE: usize = CONTEXT_FIRST_CHANGE + 1; pub(crate) const VIRTUAL_FIRST_CHANGE: usize = SEGMENT_FIRST_CHANGE + 1; // Used to lower the degree of the zero-initializing constraints. -// Contains `next_segment * addr_changed * next_is_read`. +// Contains `preinitialized_segments * addr_changed * next_is_read`. pub(crate) const INITIALIZE_AUX: usize = VIRTUAL_FIRST_CHANGE + 1; -// Used to allow pre-initialization of some context 0 segments. +// Used to allow pre-initialization of some segments. +// Contains `(next_segment - Segment::Code) * (next_segment - Segment::TrieData) +// * preinitialized_segments_aux`. pub(crate) const PREINITIALIZED_SEGMENTS: usize = INITIALIZE_AUX + 1; +// Used to allow pre-initialization of more segments. +// Contains `(next_segment - Segment::AccountsLinkedList) * (next_segment - +// Segment::StorageLinkedList)`. +pub(crate) const PREINITIALIZED_SEGMENTS_AUX: usize = PREINITIALIZED_SEGMENTS + 1; + // Contains `row_index` + 1 if and only if context `row_index` is stale, // and zero if not. -pub(crate) const STALE_CONTEXTS: usize = PREINITIALIZED_SEGMENTS + 1; +pub(crate) const STALE_CONTEXTS: usize = PREINITIALIZED_SEGMENTS_AUX + 1; // Flag indicating whether the current context needs to be pruned. It is set to // 1 when the value in `STALE_CONTEXTS` is non-zero. diff --git a/evm_arithmetization/src/memory/memory_stark.rs b/evm_arithmetization/src/memory/memory_stark.rs index 7b1415e12..21f57cb2c 100644 --- a/evm_arithmetization/src/memory/memory_stark.rs +++ b/evm_arithmetization/src/memory/memory_stark.rs @@ -20,7 +20,8 @@ use starky::lookup::{Column, Filter, Lookup}; use starky::stark::Stark; use super::columns::{ - MEM_AFTER_FILTER, PREINITIALIZED_SEGMENTS, STALE_CONTEXTS, STALE_CONTEXTS_FREQUENCIES, + MEM_AFTER_FILTER, PREINITIALIZED_SEGMENTS, PREINITIALIZED_SEGMENTS_AUX, STALE_CONTEXTS, + STALE_CONTEXTS_FREQUENCIES, }; use super::segments::Segment; use crate::all_stark::{EvmStarkFrame, Table}; @@ -184,14 +185,18 @@ pub(crate) fn generate_first_change_flags_and_rc( row[RANGE_CHECK] ); - let address_changed = - row[CONTEXT_FIRST_CHANGE] + row[SEGMENT_FIRST_CHANGE] + row[VIRTUAL_FIRST_CHANGE]; - row[INITIALIZE_AUX] = next_segment * address_changed * next_is_read; + row[PREINITIALIZED_SEGMENTS_AUX] = (next_segment + - F::from_canonical_usize(Segment::AccountsLinkedList.unscale())) + * (next_segment - F::from_canonical_usize(Segment::StorageLinkedList.unscale())); row[PREINITIALIZED_SEGMENTS] = (next_segment - - F::from_canonical_usize(Segment::TrieData.unscale())) - * (next_segment - F::from_canonical_usize(Segment::AccountsLinkedList.unscale())) - * (next_segment - F::from_canonical_usize(Segment::StorageLinkedList.unscale())) + - F::from_canonical_usize(Segment::Code.unscale())) + * (next_segment - F::from_canonical_usize(Segment::TrieData.unscale())) + * row[PREINITIALIZED_SEGMENTS_AUX]; + + let address_changed = + row[CONTEXT_FIRST_CHANGE] + row[SEGMENT_FIRST_CHANGE] + row[VIRTUAL_FIRST_CHANGE]; + row[INITIALIZE_AUX] = row[PREINITIALIZED_SEGMENTS] * address_changed * next_is_read; } } @@ -530,23 +535,30 @@ impl, const D: usize> Stark for MemoryStark, const D: usize> Stark for MemoryStark, const D: usize> Stark for MemoryStark, const D: usize> Stark for MemoryStark