From 5ee9cbff5ebdd7772083b4ce3d3101111a764ee0 Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Tue, 17 Sep 2024 17:06:27 +0200 Subject: [PATCH 01/11] Add pointer btrees for access lists --- .../src/cpu/kernel/interpreter.rs | 4 +- .../src/cpu/kernel/tests/account_code.rs | 4 +- .../src/generation/linked_list.rs | 16 +++ .../src/generation/prover_input.rs | 102 +++++++++++++++--- .../src/generation/segments.rs | 4 +- evm_arithmetization/src/generation/state.rs | 36 +++---- 6 files changed, 128 insertions(+), 38 deletions(-) diff --git a/evm_arithmetization/src/cpu/kernel/interpreter.rs b/evm_arithmetization/src/cpu/kernel/interpreter.rs index 10af8d495..6c581be64 100644 --- a/evm_arithmetization/src/cpu/kernel/interpreter.rs +++ b/evm_arithmetization/src/cpu/kernel/interpreter.rs @@ -235,8 +235,8 @@ impl Interpreter { // Initialize the MPT's pointers. let (trie_root_ptrs, state_leaves, storage_leaves, trie_data) = load_linked_lists_and_txn_and_receipt_mpts( - &mut self.generation_state.accounts_pointers, - &mut self.generation_state.storage_pointers, + &mut self.generation_state.state_ptrs.accounts_ptrs, + &mut self.generation_state.state_ptrs.storage_ptrs, &inputs.tries, ) .expect("Invalid MPT data for preinitialization"); diff --git a/evm_arithmetization/src/cpu/kernel/tests/account_code.rs b/evm_arithmetization/src/cpu/kernel/tests/account_code.rs index ff4dba48e..2de81c514 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/account_code.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/account_code.rs @@ -32,8 +32,8 @@ pub(crate) fn initialize_mpts( // Load all MPTs. let (mut trie_root_ptrs, state_leaves, storage_leaves, trie_data) = load_linked_lists_and_txn_and_receipt_mpts( - &mut interpreter.generation_state.accounts_pointers, - &mut interpreter.generation_state.storage_pointers, + &mut interpreter.generation_state.state_ptrs.accounts_ptrs, + &mut interpreter.generation_state.state_ptrs.storage_ptrs, trie_inputs, ) .expect("Invalid MPT data for preinitialization"); diff --git a/evm_arithmetization/src/generation/linked_list.rs b/evm_arithmetization/src/generation/linked_list.rs index fbe0e4965..f44b8159c 100644 --- a/evm_arithmetization/src/generation/linked_list.rs +++ b/evm_arithmetization/src/generation/linked_list.rs @@ -1,8 +1,10 @@ +use std::collections::BTreeMap; use std::fmt; use std::marker::PhantomData; use anyhow::Result; use ethereum_types::U256; +use serde::{Deserialize, Serialize}; use crate::memory::segments::Segment; use crate::util::u256_to_usize; @@ -42,6 +44,20 @@ where _marker: PhantomData, } +// Provides quick access to pointers that reference the memory location +// of a storage or accounts linked list node, containing a specific key. +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +pub(crate) struct LinkedListPtrs { + /// Each entry contains the pair (key, ptr) where key is the (hashed) key + /// of an account in the accounts linked list, and ptr is the respective + /// node address in memory. + pub(crate) accounts_ptrs: BTreeMap, + /// Each entry contains the pair ((account_key, slot_key), ptr) where + /// account_key is the (hashed) key of an account, slot_key is the slot + /// key, and ptr is the respective node address in memory. + pub(crate) storage_ptrs: BTreeMap<(U256, U256), usize>, +} + pub(crate) fn empty_list_mem(segment: Segment) -> [Option; N] { std::array::from_fn(|i| { if i == 0 { diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index 16c1e5310..3d288f42a 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -410,8 +410,26 @@ impl GenerationState { /// Returns a pointer to an element in the list whose value is such that /// `value <= addr < next_value` and `addr` is the top of the stack. - fn run_next_addresses_insert(&self) -> Result { + fn run_next_addresses_insert(&mut self) -> Result { let addr = stack_peek(self, 0)?; + + let (&pred_addr, &pred_ptr) = self + .access_lists_ptrs + .accounts_ptrs + .range(..=addr) + .next_back() + .unwrap_or((&U256::MAX, &(Segment::AccessedAddresses as usize))); + + if pred_addr != addr { + self.access_lists_ptrs.accounts_ptrs.insert( + addr, + u256_to_usize( + self.memory + .read_global_metadata(GlobalMetadata::AccessedAddressesLen), + )?, + ); + } + if let Some((([_, ptr], _), _)) = self .get_addresses_access_list()? .zip(self.get_addresses_access_list()?.skip(1)) @@ -420,6 +438,7 @@ impl GenerationState { (prev_addr <= addr || prev_addr == U256::MAX) && addr < next_addr }) { + assert_eq!(U256::from(pred_ptr), ptr); Ok(ptr / U256::from(2)) } else { Ok((Segment::AccessedAddresses as usize).into()) @@ -429,13 +448,26 @@ impl GenerationState { /// Returns a pointer to an element in the list whose value is such that /// `value < addr == next_value` and addr is the top of the stack. /// If the element is not in the list, it loops forever - fn run_next_addresses_remove(&self) -> Result { + fn run_next_addresses_remove(&mut self) -> Result { let addr = stack_peek(self, 0)?; + + let (_, &other_ptr) = self + .access_lists_ptrs + .accounts_ptrs + .range(..addr) + .next_back() + .unwrap_or((&U256::MAX, &(Segment::AccountsLinkedList as usize))); + self.access_lists_ptrs + .accounts_ptrs + .remove(&addr) + .ok_or(ProgramError::ProverInputError(InvalidInput))?; + if let Some(([_, ptr], _)) = self .get_addresses_access_list()? .zip(self.get_addresses_access_list()?.skip(2)) .find(|&(_, [next_addr, _])| next_addr == addr) { + assert_eq!(U256::from(other_ptr), ptr); Ok(ptr / U256::from(2)) } else { Ok((Segment::AccessedAddresses as usize).into()) @@ -444,9 +476,29 @@ impl GenerationState { /// Returns a pointer to the predecessor of the top of the stack in the /// accessed storage keys list. - fn run_next_storage_insert(&self) -> Result { + fn run_next_storage_insert(&mut self) -> Result { let addr = stack_peek(self, 0)?; let key = stack_peek(self, 1)?; + + let (&(pred_addr, pred_slot_key), &pred_ptr) = self + .access_lists_ptrs + .storage_ptrs + .range(..=(addr, key)) + .next_back() + .unwrap_or(( + &(U256::MAX, U256::zero()), + &(Segment::AccessedStorageKeys as usize), + )); + if (pred_addr != addr || pred_slot_key != key) { + self.access_lists_ptrs.storage_ptrs.insert( + (addr, key), + u256_to_usize( + self.memory + .read_global_metadata(GlobalMetadata::AccessedStorageKeysLen), + )?, + ); + } + if let Some((([.., ptr], _), _)) = self .get_storage_keys_access_list()? .zip(self.get_storage_keys_access_list()?.skip(1)) @@ -461,6 +513,7 @@ impl GenerationState { }, ) { + assert_eq!(U256::from(pred_ptr), ptr); Ok(ptr / U256::from(4)) } else { Ok((Segment::AccessedStorageKeys as usize).into()) @@ -469,14 +522,30 @@ impl GenerationState { /// Returns a pointer to the predecessor of the top of the stack in the /// accessed storage keys list. - fn run_next_storage_remove(&self) -> Result { + fn run_next_storage_remove(&mut self) -> Result { let addr = stack_peek(self, 0)?; let key = stack_peek(self, 1)?; + + let (_, &other_ptr) = self + .access_lists_ptrs + .storage_ptrs + .range(..(addr, key)) + .next_back() + .unwrap_or(( + &(U256::MAX, U256::zero()), + &(Segment::AccessedStorageKeys as usize), + )); + self.access_lists_ptrs + .storage_ptrs + .remove(&(addr, key)) + .ok_or(ProgramError::ProverInputError(InvalidInput))?; + if let Some(([.., ptr], _)) = self .get_storage_keys_access_list()? .zip(self.get_storage_keys_access_list()?.skip(2)) .find(|&(_, [next_addr, next_key, ..])| (next_addr == addr && next_key == key)) { + assert_eq!(U256::from(other_ptr), ptr); Ok(ptr / U256::from(4)) } else { Ok((Segment::AccessedStorageKeys as usize).into()) @@ -489,13 +558,14 @@ impl GenerationState { let addr = stack_peek(self, 0)?; let (&pred_addr, &pred_ptr) = self - .accounts_pointers + .state_ptrs + .accounts_ptrs .range(..=addr) .next_back() .unwrap_or((&U256::MAX, &(Segment::AccountsLinkedList as usize))); if pred_addr != addr && input_fn.0[1].as_str() == "insert_account" { - self.accounts_pointers.insert( + self.state_ptrs.accounts_ptrs.insert( addr, u256_to_usize( self.memory @@ -516,7 +586,8 @@ impl GenerationState { let key = stack_peek(self, 1)?; let (&(pred_addr, pred_slot_key), &pred_ptr) = self - .storage_pointers + .state_ptrs + .storage_ptrs .range(..=(addr, key)) .next_back() .unwrap_or(( @@ -524,7 +595,7 @@ impl GenerationState { &(Segment::StorageLinkedList as usize), )); if (pred_addr != addr || pred_slot_key != key) && input_fn.0[1] == "insert_slot" { - self.storage_pointers.insert( + self.state_ptrs.storage_ptrs.insert( (addr, key), u256_to_usize( self.memory @@ -544,11 +615,13 @@ impl GenerationState { let addr = stack_peek(self, 0)?; let (_, &ptr) = self - .accounts_pointers + .state_ptrs + .accounts_ptrs .range(..addr) .next_back() .unwrap_or((&U256::MAX, &(Segment::AccountsLinkedList as usize))); - self.accounts_pointers + self.state_ptrs + .accounts_ptrs .remove(&addr) .ok_or(ProgramError::ProverInputError(InvalidInput))?; @@ -564,14 +637,16 @@ impl GenerationState { let key = stack_peek(self, 1)?; let (_, &ptr) = self - .storage_pointers + .state_ptrs + .storage_ptrs .range(..(addr, key)) .next_back() .unwrap_or(( &(U256::MAX, U256::zero()), &(Segment::StorageLinkedList as usize), )); - self.storage_pointers + self.state_ptrs + .storage_ptrs .remove(&(addr, key)) .ok_or(ProgramError::ProverInputError(InvalidInput))?; @@ -588,7 +663,8 @@ impl GenerationState { let addr = stack_peek(self, 0)?; let (_, &pred_ptr) = self - .storage_pointers + .state_ptrs + .storage_ptrs .range(..(addr, U256::zero())) .next_back() .unwrap_or(( diff --git a/evm_arithmetization/src/generation/segments.rs b/evm_arithmetization/src/generation/segments.rs index 7f123aa10..40ba2a00b 100644 --- a/evm_arithmetization/src/generation/segments.rs +++ b/evm_arithmetization/src/generation/segments.rs @@ -74,8 +74,8 @@ fn build_segment_data( trie_root_ptrs: interpreter.generation_state.trie_root_ptrs.clone(), jumpdest_table: interpreter.generation_state.jumpdest_table.clone(), next_txn_index: interpreter.generation_state.next_txn_index, - accounts: interpreter.generation_state.accounts_pointers.clone(), - storage: interpreter.generation_state.storage_pointers.clone(), + accounts: interpreter.generation_state.state_ptrs.accounts_ptrs.clone(), + storage: interpreter.generation_state.state_ptrs.storage_ptrs.clone(), }, } } diff --git a/evm_arithmetization/src/generation/state.rs b/evm_arithmetization/src/generation/state.rs index b094c15f9..7e986c93b 100644 --- a/evm_arithmetization/src/generation/state.rs +++ b/evm_arithmetization/src/generation/state.rs @@ -8,7 +8,7 @@ use keccak_hash::keccak; use log::Level; use plonky2::hash::hash_types::RichField; -use super::linked_list::{AccountsLinkedList, StorageLinkedList}; +use super::linked_list::{AccountsLinkedList, LinkedList, LinkedListPtrs, StorageLinkedList}; use super::mpt::TrieRootPtrs; use super::segments::GenerationSegmentData; use super::{TrieInputs, TrimmedGenerationInputs, NUM_EXTRA_CYCLES_AFTER}; @@ -376,15 +376,13 @@ pub struct GenerationState { /// j in [i, i+32] it holds that code[j] < 0x7f - j + i. pub(crate) jumpdest_table: Option>>, - /// Each entry contains the pair (key, ptr) where key is the (hashed) key - /// of an account in the accounts linked list, and ptr is the respective - /// node address in memory. - pub(crate) accounts_pointers: BTreeMap, + // Provides quick access to pointers that reference the memory location + // of an accounts or storage access list node containing a specific key. + pub(crate) access_lists_ptrs: LinkedListPtrs, - /// Each entry contains the pair ((account_key, slot_key), ptr) where - /// account_key is the (hashed) key of an account, slot_key is the slot - /// key, and ptr is the respective node address in memory. - pub(crate) storage_pointers: BTreeMap<(U256, U256), usize>, + // Provides quick access to pointers that reference the memory location + // of a accounts or storage linked list node containing a specific key. + pub(crate) state_ptrs: LinkedListPtrs, } impl GenerationState { @@ -395,8 +393,8 @@ impl GenerationState { let generation_state = self.get_mut_generation_state(); let (trie_roots_ptrs, state_leaves, storage_leaves, trie_data) = load_linked_lists_and_txn_and_receipt_mpts( - &mut generation_state.accounts_pointers, - &mut generation_state.storage_pointers, + &mut generation_state.state_ptrs.accounts_ptrs, + &mut generation_state.state_ptrs.storage_ptrs, trie_inputs, ) .expect("Invalid MPT data for preinitialization"); @@ -447,8 +445,8 @@ impl GenerationState { receipt_root_ptr: 0, }, jumpdest_table: None, - accounts_pointers: BTreeMap::new(), - storage_pointers: BTreeMap::new(), + access_lists_ptrs: LinkedListPtrs::default(), + state_ptrs: LinkedListPtrs::default(), ger_prover_inputs, }; let trie_root_ptrs = @@ -564,8 +562,8 @@ impl GenerationState { receipt_root_ptr: 0, }, jumpdest_table: None, - accounts_pointers: self.accounts_pointers.clone(), - storage_pointers: self.storage_pointers.clone(), + access_lists_ptrs: self.access_lists_ptrs.clone(), + state_ptrs: self.state_ptrs.clone(), } } @@ -582,9 +580,9 @@ impl GenerationState { .clone_from(&segment_data.extra_data.trie_root_ptrs); self.jumpdest_table .clone_from(&segment_data.extra_data.jumpdest_table); - self.accounts_pointers + self.state_ptrs.accounts_ptrs .clone_from(&segment_data.extra_data.accounts); - self.storage_pointers + self.state_ptrs.storage_ptrs .clone_from(&segment_data.extra_data.storage); self.next_txn_index = segment_data.extra_data.next_txn_index; self.registers = RegistersState { @@ -600,7 +598,7 @@ impl GenerationState { /// the accounts `BtreeMap`. pub(crate) fn insert_all_slots_in_memory(&mut self) { let storage_mem = self.memory.get_preinit_memory(Segment::StorageLinkedList); - self.storage_pointers.extend( + self.state_ptrs.storage_ptrs.extend( StorageLinkedList::from_mem_and_segment(&storage_mem, Segment::StorageLinkedList) .expect("There must be at least an empty storage linked list") .tuple_windows() @@ -622,7 +620,7 @@ impl GenerationState { pub(crate) fn insert_all_accounts_in_memory(&mut self) { let accounts_mem = self.memory.get_preinit_memory(Segment::AccountsLinkedList); - self.accounts_pointers.extend( + self.state_ptrs.accounts_ptrs.extend( AccountsLinkedList::from_mem_and_segment(&accounts_mem, Segment::AccountsLinkedList) .expect("There must be at least an empty accounts linked list") .tuple_windows() From 306443b9718c39eaf72beb77ff01c1a45902d13d Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Wed, 18 Sep 2024 14:45:37 +0200 Subject: [PATCH 02/11] Debugging block 4 --- .../src/generation/linked_list.rs | 2 +- .../src/generation/prover_input.rs | 14 +++++++++++++- evm_arithmetization/src/witness/transition.rs | 3 +++ trace_decoder/tests/simulate-execution.rs | 16 ++++++++++++---- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/evm_arithmetization/src/generation/linked_list.rs b/evm_arithmetization/src/generation/linked_list.rs index f44b8159c..40b8a84b1 100644 --- a/evm_arithmetization/src/generation/linked_list.rs +++ b/evm_arithmetization/src/generation/linked_list.rs @@ -82,7 +82,7 @@ impl<'a, const N: usize, T: LinkedListType> LinkedList<'a, N, T> { mem: &'a [Option], segment: Segment, ) -> Result { - if mem.is_empty() { + if mem.is_empty() || mem.len() % N != 0 { return Err(ProgramError::ProverInputError(InvalidInput)); } Ok(Self { diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index 3d288f42a..a21d2858a 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -322,6 +322,8 @@ impl GenerationState { /// Generates either the next used jump address or the proof for the last /// jump address. fn run_access_lists(&mut self, input_fn: &ProverInputFn) -> Result { + log::debug!("la ll = {:?}", self.get_addresses_access_list()); + log::debug!("el bt = {:?}", self.access_lists_ptrs.accounts_ptrs); match input_fn.0[1].as_str() { "address_insert" => self.run_next_addresses_insert(), "storage_insert" => self.run_next_storage_insert(), @@ -421,6 +423,12 @@ impl GenerationState { .unwrap_or((&U256::MAX, &(Segment::AccessedAddresses as usize))); if pred_addr != addr { + log::debug!( + "adding {:?} at {:?}", + addr, + self.memory + .read_global_metadata(GlobalMetadata::AccessedAddressesLen) + ); self.access_lists_ptrs.accounts_ptrs.insert( addr, u256_to_usize( @@ -430,6 +438,10 @@ impl GenerationState { ); } + log::debug!("la addr = {:?}", addr); + log::debug!("la ll = {:?}", self.get_addresses_access_list()); + log::debug!("el bt = {:?}", self.access_lists_ptrs.accounts_ptrs); + if let Some((([_, ptr], _), _)) = self .get_addresses_access_list()? .zip(self.get_addresses_access_list()?.skip(1)) @@ -456,7 +468,7 @@ impl GenerationState { .accounts_ptrs .range(..addr) .next_back() - .unwrap_or((&U256::MAX, &(Segment::AccountsLinkedList as usize))); + .unwrap_or((&U256::MAX, &(Segment::AccessedAddresses as usize))); self.access_lists_ptrs .accounts_ptrs .remove(&addr) diff --git a/evm_arithmetization/src/witness/transition.rs b/evm_arithmetization/src/witness/transition.rs index fa66bee5b..d2533600e 100644 --- a/evm_arithmetization/src/witness/transition.rs +++ b/evm_arithmetization/src/witness/transition.rs @@ -307,6 +307,9 @@ pub(crate) fn log_kernel_instruction>(state: &mut S, o state.get_generation_state().stack(), ), ); + if let Ok(ll) = state.get_generation_state().get_addresses_access_list() && state.get_clock() >= 62435{ + state.log(level, format!("la ll = {:?}", ll)); + } assert!(pc < KERNEL.code.len(), "Kernel PC is out of range: {}", pc); } diff --git a/trace_decoder/tests/simulate-execution.rs b/trace_decoder/tests/simulate-execution.rs index c4cbe53b2..21905930a 100644 --- a/trace_decoder/tests/simulate-execution.rs +++ b/trace_decoder/tests/simulate-execution.rs @@ -6,10 +6,12 @@ mod common; use anyhow::Context as _; use common::{cases, Case}; +use evm_arithmetization::testing_utils::init_logger; use libtest_mimic::{Arguments, Trial}; use plonky2::field::goldilocks_field::GoldilocksField; fn main() -> anyhow::Result<()> { + init_logger(); let mut trials = vec![]; for batch_size in [1, 3] { for Case { @@ -22,14 +24,20 @@ fn main() -> anyhow::Result<()> { let gen_inputs = trace_decoder::entrypoint(trace, other, batch_size).context( format!("error in `trace_decoder` for {name} at batch size {batch_size}"), )?; - for (ix, gi) in gen_inputs.into_iter().enumerate() { + for (ix, gi) in gen_inputs.into_iter().enumerate() + { + let other_name = name.clone(); trials.push(Trial::test( format!("{name}@{batch_size}/{ix}"), move || { - evm_arithmetization::prover::testing::simulate_execution_all_segments::< + if other_name == "b4_dev" && batch_size == 3 && ix == 1 + { + evm_arithmetization::prover::testing::simulate_execution_all_segments::< GoldilocksField, - >(gi, 19) - .map_err(|e| format!("{e:?}"))?; // get the full error chain + >(gi, 19) + .map_err(|e| format!("{e:?}"))?; // get the full error + // chain + } Ok(()) }, )) From e8e0e4c2e6bc12f9355b636416669515c3995ecc Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Wed, 18 Sep 2024 17:20:04 +0200 Subject: [PATCH 03/11] Reset access lists ptrs on init_access_lists --- .../src/cpu/kernel/interpreter.rs | 6 ++++-- .../src/generation/prover_input.rs | 6 ------ evm_arithmetization/src/generation/state.rs | 7 +++++++ evm_arithmetization/src/witness/transition.rs | 3 --- trace_decoder/tests/simulate-execution.rs | 16 ++++------------ 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/evm_arithmetization/src/cpu/kernel/interpreter.rs b/evm_arithmetization/src/cpu/kernel/interpreter.rs index 6c581be64..e5b58af28 100644 --- a/evm_arithmetization/src/cpu/kernel/interpreter.rs +++ b/evm_arithmetization/src/cpu/kernel/interpreter.rs @@ -86,6 +86,8 @@ pub(crate) fn simulate_cpu_and_get_user_jumps( log::debug!("Simulating CPU for jumpdest analysis."); + log::debug!("el bt = {:?}", interpreter.generation_state.access_lists_ptrs.accounts_ptrs); + let _ = interpreter.run(); log::trace!("jumpdest table = {:?}", interpreter.jumpdest_table); @@ -699,9 +701,9 @@ impl State for Interpreter { } fn log(&self, level: Level, msg: String) { - if !self.is_jumpdest_analysis { + // if !self.is_jumpdest_analysis { log::log!(level, "{}", msg); - } + // } } } diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index a21d2858a..abe86d91e 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -322,8 +322,6 @@ impl GenerationState { /// Generates either the next used jump address or the proof for the last /// jump address. fn run_access_lists(&mut self, input_fn: &ProverInputFn) -> Result { - log::debug!("la ll = {:?}", self.get_addresses_access_list()); - log::debug!("el bt = {:?}", self.access_lists_ptrs.accounts_ptrs); match input_fn.0[1].as_str() { "address_insert" => self.run_next_addresses_insert(), "storage_insert" => self.run_next_storage_insert(), @@ -438,10 +436,6 @@ impl GenerationState { ); } - log::debug!("la addr = {:?}", addr); - log::debug!("la ll = {:?}", self.get_addresses_access_list()); - log::debug!("el bt = {:?}", self.access_lists_ptrs.accounts_ptrs); - if let Some((([_, ptr], _), _)) = self .get_addresses_access_list()? .zip(self.get_addresses_access_list()?.skip(1)) diff --git a/evm_arithmetization/src/generation/state.rs b/evm_arithmetization/src/generation/state.rs index 7e986c93b..b15fd005a 100644 --- a/evm_arithmetization/src/generation/state.rs +++ b/evm_arithmetization/src/generation/state.rs @@ -196,6 +196,13 @@ pub(crate) trait State { let registers = self.get_registers(); let pc = registers.program_counter; + // If we reached init_access_lists, we need to clear the pointers + let init_access_lists = KERNEL.global_labels["init_access_lists"]; + if running && pc == init_access_lists && registers.is_kernel { + let gen_state = self.get_mut_generation_state(); + gen_state.access_lists_ptrs = LinkedListPtrs::default(); + } + let halt_final = registers.is_kernel && halt_offsets.contains(&pc); if running && (self.at_halt() || self.at_end_segment(cycle_limit)) { running = false; diff --git a/evm_arithmetization/src/witness/transition.rs b/evm_arithmetization/src/witness/transition.rs index d2533600e..fa66bee5b 100644 --- a/evm_arithmetization/src/witness/transition.rs +++ b/evm_arithmetization/src/witness/transition.rs @@ -307,9 +307,6 @@ pub(crate) fn log_kernel_instruction>(state: &mut S, o state.get_generation_state().stack(), ), ); - if let Ok(ll) = state.get_generation_state().get_addresses_access_list() && state.get_clock() >= 62435{ - state.log(level, format!("la ll = {:?}", ll)); - } assert!(pc < KERNEL.code.len(), "Kernel PC is out of range: {}", pc); } diff --git a/trace_decoder/tests/simulate-execution.rs b/trace_decoder/tests/simulate-execution.rs index 21905930a..c4cbe53b2 100644 --- a/trace_decoder/tests/simulate-execution.rs +++ b/trace_decoder/tests/simulate-execution.rs @@ -6,12 +6,10 @@ mod common; use anyhow::Context as _; use common::{cases, Case}; -use evm_arithmetization::testing_utils::init_logger; use libtest_mimic::{Arguments, Trial}; use plonky2::field::goldilocks_field::GoldilocksField; fn main() -> anyhow::Result<()> { - init_logger(); let mut trials = vec![]; for batch_size in [1, 3] { for Case { @@ -24,20 +22,14 @@ fn main() -> anyhow::Result<()> { let gen_inputs = trace_decoder::entrypoint(trace, other, batch_size).context( format!("error in `trace_decoder` for {name} at batch size {batch_size}"), )?; - for (ix, gi) in gen_inputs.into_iter().enumerate() - { - let other_name = name.clone(); + for (ix, gi) in gen_inputs.into_iter().enumerate() { trials.push(Trial::test( format!("{name}@{batch_size}/{ix}"), move || { - if other_name == "b4_dev" && batch_size == 3 && ix == 1 - { - evm_arithmetization::prover::testing::simulate_execution_all_segments::< + evm_arithmetization::prover::testing::simulate_execution_all_segments::< GoldilocksField, - >(gi, 19) - .map_err(|e| format!("{e:?}"))?; // get the full error - // chain - } + >(gi, 19) + .map_err(|e| format!("{e:?}"))?; // get the full error chain Ok(()) }, )) From 71221df092c1c187dd562154b6406a8615e68724 Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Wed, 18 Sep 2024 17:34:09 +0200 Subject: [PATCH 04/11] Remove linked list use --- .../src/generation/prover_input.rs | 76 +++---------------- evm_arithmetization/src/generation/state.rs | 2 +- 2 files changed, 13 insertions(+), 65 deletions(-) diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index abe86d91e..d725c66a2 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -44,7 +44,9 @@ use crate::witness::util::{current_context_peek, stack_peek}; #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)] pub struct ProverInputFn(Vec); +#[allow(dead_code)] pub const ADDRESSES_ACCESS_LIST_LEN: usize = 2; +#[allow(dead_code)] pub const STORAGE_KEYS_ACCESS_LIST_LEN: usize = 4; impl From> for ProverInputFn { @@ -413,7 +415,7 @@ impl GenerationState { fn run_next_addresses_insert(&mut self) -> Result { let addr = stack_peek(self, 0)?; - let (&pred_addr, &pred_ptr) = self + let (&pred_addr, &ptr) = self .access_lists_ptrs .accounts_ptrs .range(..=addr) @@ -421,12 +423,6 @@ impl GenerationState { .unwrap_or((&U256::MAX, &(Segment::AccessedAddresses as usize))); if pred_addr != addr { - log::debug!( - "adding {:?} at {:?}", - addr, - self.memory - .read_global_metadata(GlobalMetadata::AccessedAddressesLen) - ); self.access_lists_ptrs.accounts_ptrs.insert( addr, u256_to_usize( @@ -435,20 +431,7 @@ impl GenerationState { )?, ); } - - if let Some((([_, ptr], _), _)) = self - .get_addresses_access_list()? - .zip(self.get_addresses_access_list()?.skip(1)) - .zip(self.get_addresses_access_list()?.skip(2)) - .find(|&((_, [prev_addr, _]), [next_addr, _])| { - (prev_addr <= addr || prev_addr == U256::MAX) && addr < next_addr - }) - { - assert_eq!(U256::from(pred_ptr), ptr); - Ok(ptr / U256::from(2)) - } else { - Ok((Segment::AccessedAddresses as usize).into()) - } + Ok(U256::from(ptr / 2)) } /// Returns a pointer to an element in the list whose value is such that @@ -457,7 +440,7 @@ impl GenerationState { fn run_next_addresses_remove(&mut self) -> Result { let addr = stack_peek(self, 0)?; - let (_, &other_ptr) = self + let (_, &ptr) = self .access_lists_ptrs .accounts_ptrs .range(..addr) @@ -468,16 +451,7 @@ impl GenerationState { .remove(&addr) .ok_or(ProgramError::ProverInputError(InvalidInput))?; - if let Some(([_, ptr], _)) = self - .get_addresses_access_list()? - .zip(self.get_addresses_access_list()?.skip(2)) - .find(|&(_, [next_addr, _])| next_addr == addr) - { - assert_eq!(U256::from(other_ptr), ptr); - Ok(ptr / U256::from(2)) - } else { - Ok((Segment::AccessedAddresses as usize).into()) - } + Ok(U256::from(ptr / 2)) } /// Returns a pointer to the predecessor of the top of the stack in the @@ -486,7 +460,7 @@ impl GenerationState { let addr = stack_peek(self, 0)?; let key = stack_peek(self, 1)?; - let (&(pred_addr, pred_slot_key), &pred_ptr) = self + let (&(pred_addr, pred_slot_key), &ptr) = self .access_lists_ptrs .storage_ptrs .range(..=(addr, key)) @@ -504,26 +478,7 @@ impl GenerationState { )?, ); } - - if let Some((([.., ptr], _), _)) = self - .get_storage_keys_access_list()? - .zip(self.get_storage_keys_access_list()?.skip(1)) - .zip(self.get_storage_keys_access_list()?.skip(2)) - .find( - |&((_, [prev_addr, prev_key, ..]), [next_addr, next_key, ..])| { - let prev_is_less_or_equal = (prev_addr < addr || prev_addr == U256::MAX) - || (prev_addr == addr && prev_key <= key); - let next_is_strictly_larger = - next_addr > addr || (next_addr == addr && next_key > key); - prev_is_less_or_equal && next_is_strictly_larger - }, - ) - { - assert_eq!(U256::from(pred_ptr), ptr); - Ok(ptr / U256::from(4)) - } else { - Ok((Segment::AccessedStorageKeys as usize).into()) - } + Ok(U256::from(ptr / 4)) } /// Returns a pointer to the predecessor of the top of the stack in the @@ -532,7 +487,7 @@ impl GenerationState { let addr = stack_peek(self, 0)?; let key = stack_peek(self, 1)?; - let (_, &other_ptr) = self + let (_, &ptr) = self .access_lists_ptrs .storage_ptrs .range(..(addr, key)) @@ -546,16 +501,7 @@ impl GenerationState { .remove(&(addr, key)) .ok_or(ProgramError::ProverInputError(InvalidInput))?; - if let Some(([.., ptr], _)) = self - .get_storage_keys_access_list()? - .zip(self.get_storage_keys_access_list()?.skip(2)) - .find(|&(_, [next_addr, next_key, ..])| (next_addr == addr && next_key == key)) - { - assert_eq!(U256::from(other_ptr), ptr); - Ok(ptr / U256::from(4)) - } else { - Ok((Segment::AccessedStorageKeys as usize).into()) - } + Ok(U256::from(ptr / 4)) } /// Returns a pointer to a node in the list such that @@ -902,6 +848,7 @@ impl GenerationState { } } + #[allow(dead_code)] pub(crate) fn get_addresses_access_list( &self, ) -> Result, ProgramError> { @@ -914,6 +861,7 @@ impl GenerationState { ) } + #[allow(dead_code)] pub(crate) fn get_storage_keys_access_list( &self, ) -> Result, ProgramError> { diff --git a/evm_arithmetization/src/generation/state.rs b/evm_arithmetization/src/generation/state.rs index b15fd005a..65fa71d34 100644 --- a/evm_arithmetization/src/generation/state.rs +++ b/evm_arithmetization/src/generation/state.rs @@ -8,7 +8,7 @@ use keccak_hash::keccak; use log::Level; use plonky2::hash::hash_types::RichField; -use super::linked_list::{AccountsLinkedList, LinkedList, LinkedListPtrs, StorageLinkedList}; +use super::linked_list::{AccountsLinkedList, LinkedListPtrs, StorageLinkedList}; use super::mpt::TrieRootPtrs; use super::segments::GenerationSegmentData; use super::{TrieInputs, TrimmedGenerationInputs, NUM_EXTRA_CYCLES_AFTER}; From bc0d67bf508b38be93fc18642f3c50ae914f28a8 Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Wed, 18 Sep 2024 17:40:11 +0200 Subject: [PATCH 05/11] Clean code --- evm_arithmetization/src/cpu/kernel/interpreter.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evm_arithmetization/src/cpu/kernel/interpreter.rs b/evm_arithmetization/src/cpu/kernel/interpreter.rs index e5b58af28..09a96a4ce 100644 --- a/evm_arithmetization/src/cpu/kernel/interpreter.rs +++ b/evm_arithmetization/src/cpu/kernel/interpreter.rs @@ -701,9 +701,9 @@ impl State for Interpreter { } fn log(&self, level: Level, msg: String) { - // if !self.is_jumpdest_analysis { + if !self.is_jumpdest_analysis { log::log!(level, "{}", msg); - // } + } } } From 8a6a253879ee2eb7b7470731b0062121745c887c Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Thu, 19 Sep 2024 11:16:19 +0200 Subject: [PATCH 06/11] Address review --- .../src/cpu/kernel/interpreter.rs | 6 +-- .../src/cpu/kernel/tests/account_code.rs | 4 +- .../src/generation/linked_list.rs | 4 +- .../src/generation/prover_input.rs | 38 +++++++++---------- .../src/generation/segments.rs | 4 +- evm_arithmetization/src/generation/state.rs | 14 +++---- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/evm_arithmetization/src/cpu/kernel/interpreter.rs b/evm_arithmetization/src/cpu/kernel/interpreter.rs index 09a96a4ce..e77f20ae9 100644 --- a/evm_arithmetization/src/cpu/kernel/interpreter.rs +++ b/evm_arithmetization/src/cpu/kernel/interpreter.rs @@ -86,7 +86,7 @@ pub(crate) fn simulate_cpu_and_get_user_jumps( log::debug!("Simulating CPU for jumpdest analysis."); - log::debug!("el bt = {:?}", interpreter.generation_state.access_lists_ptrs.accounts_ptrs); + log::debug!("el bt = {:?}", interpreter.generation_state.access_lists_ptrs.accounts); let _ = interpreter.run(); @@ -237,8 +237,8 @@ impl Interpreter { // Initialize the MPT's pointers. let (trie_root_ptrs, state_leaves, storage_leaves, trie_data) = load_linked_lists_and_txn_and_receipt_mpts( - &mut self.generation_state.state_ptrs.accounts_ptrs, - &mut self.generation_state.state_ptrs.storage_ptrs, + &mut self.generation_state.state_ptrs.accounts, + &mut self.generation_state.state_ptrs.storage, &inputs.tries, ) .expect("Invalid MPT data for preinitialization"); diff --git a/evm_arithmetization/src/cpu/kernel/tests/account_code.rs b/evm_arithmetization/src/cpu/kernel/tests/account_code.rs index 2de81c514..bafcce513 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/account_code.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/account_code.rs @@ -32,8 +32,8 @@ pub(crate) fn initialize_mpts( // Load all MPTs. let (mut trie_root_ptrs, state_leaves, storage_leaves, trie_data) = load_linked_lists_and_txn_and_receipt_mpts( - &mut interpreter.generation_state.state_ptrs.accounts_ptrs, - &mut interpreter.generation_state.state_ptrs.storage_ptrs, + &mut interpreter.generation_state.state_ptrs.accounts, + &mut interpreter.generation_state.state_ptrs.storage, trie_inputs, ) .expect("Invalid MPT data for preinitialization"); diff --git a/evm_arithmetization/src/generation/linked_list.rs b/evm_arithmetization/src/generation/linked_list.rs index 40b8a84b1..ca0257aa5 100644 --- a/evm_arithmetization/src/generation/linked_list.rs +++ b/evm_arithmetization/src/generation/linked_list.rs @@ -51,11 +51,11 @@ pub(crate) struct LinkedListPtrs { /// Each entry contains the pair (key, ptr) where key is the (hashed) key /// of an account in the accounts linked list, and ptr is the respective /// node address in memory. - pub(crate) accounts_ptrs: BTreeMap, + pub(crate) accounts: BTreeMap, /// Each entry contains the pair ((account_key, slot_key), ptr) where /// account_key is the (hashed) key of an account, slot_key is the slot /// key, and ptr is the respective node address in memory. - pub(crate) storage_ptrs: BTreeMap<(U256, U256), usize>, + pub(crate) storage: BTreeMap<(U256, U256), usize>, } pub(crate) fn empty_list_mem(segment: Segment) -> [Option; N] { diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index d725c66a2..ce65f8409 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -417,13 +417,13 @@ impl GenerationState { let (&pred_addr, &ptr) = self .access_lists_ptrs - .accounts_ptrs + .accounts .range(..=addr) .next_back() .unwrap_or((&U256::MAX, &(Segment::AccessedAddresses as usize))); if pred_addr != addr { - self.access_lists_ptrs.accounts_ptrs.insert( + self.access_lists_ptrs.accounts.insert( addr, u256_to_usize( self.memory @@ -442,12 +442,12 @@ impl GenerationState { let (_, &ptr) = self .access_lists_ptrs - .accounts_ptrs + .accounts .range(..addr) .next_back() .unwrap_or((&U256::MAX, &(Segment::AccessedAddresses as usize))); self.access_lists_ptrs - .accounts_ptrs + .accounts .remove(&addr) .ok_or(ProgramError::ProverInputError(InvalidInput))?; @@ -462,15 +462,15 @@ impl GenerationState { let (&(pred_addr, pred_slot_key), &ptr) = self .access_lists_ptrs - .storage_ptrs + .storage .range(..=(addr, key)) .next_back() .unwrap_or(( &(U256::MAX, U256::zero()), &(Segment::AccessedStorageKeys as usize), )); - if (pred_addr != addr || pred_slot_key != key) { - self.access_lists_ptrs.storage_ptrs.insert( + if pred_addr != addr || pred_slot_key != key { + self.access_lists_ptrs.storage.insert( (addr, key), u256_to_usize( self.memory @@ -489,7 +489,7 @@ impl GenerationState { let (_, &ptr) = self .access_lists_ptrs - .storage_ptrs + .storage .range(..(addr, key)) .next_back() .unwrap_or(( @@ -497,7 +497,7 @@ impl GenerationState { &(Segment::AccessedStorageKeys as usize), )); self.access_lists_ptrs - .storage_ptrs + .storage .remove(&(addr, key)) .ok_or(ProgramError::ProverInputError(InvalidInput))?; @@ -511,13 +511,13 @@ impl GenerationState { let (&pred_addr, &pred_ptr) = self .state_ptrs - .accounts_ptrs + .accounts .range(..=addr) .next_back() .unwrap_or((&U256::MAX, &(Segment::AccountsLinkedList as usize))); if pred_addr != addr && input_fn.0[1].as_str() == "insert_account" { - self.state_ptrs.accounts_ptrs.insert( + self.state_ptrs.accounts.insert( addr, u256_to_usize( self.memory @@ -539,7 +539,7 @@ impl GenerationState { let (&(pred_addr, pred_slot_key), &pred_ptr) = self .state_ptrs - .storage_ptrs + .storage .range(..=(addr, key)) .next_back() .unwrap_or(( @@ -547,7 +547,7 @@ impl GenerationState { &(Segment::StorageLinkedList as usize), )); if (pred_addr != addr || pred_slot_key != key) && input_fn.0[1] == "insert_slot" { - self.state_ptrs.storage_ptrs.insert( + self.state_ptrs.storage.insert( (addr, key), u256_to_usize( self.memory @@ -568,12 +568,12 @@ impl GenerationState { let (_, &ptr) = self .state_ptrs - .accounts_ptrs + .accounts .range(..addr) .next_back() .unwrap_or((&U256::MAX, &(Segment::AccountsLinkedList as usize))); self.state_ptrs - .accounts_ptrs + .accounts .remove(&addr) .ok_or(ProgramError::ProverInputError(InvalidInput))?; @@ -590,7 +590,7 @@ impl GenerationState { let (_, &ptr) = self .state_ptrs - .storage_ptrs + .storage .range(..(addr, key)) .next_back() .unwrap_or(( @@ -598,7 +598,7 @@ impl GenerationState { &(Segment::StorageLinkedList as usize), )); self.state_ptrs - .storage_ptrs + .storage .remove(&(addr, key)) .ok_or(ProgramError::ProverInputError(InvalidInput))?; @@ -616,7 +616,7 @@ impl GenerationState { let (_, &pred_ptr) = self .state_ptrs - .storage_ptrs + .storage .range(..(addr, U256::zero())) .next_back() .unwrap_or(( @@ -861,7 +861,7 @@ impl GenerationState { ) } - #[allow(dead_code)] + #[allow(dead_code)]git co pub(crate) fn get_storage_keys_access_list( &self, ) -> Result, ProgramError> { diff --git a/evm_arithmetization/src/generation/segments.rs b/evm_arithmetization/src/generation/segments.rs index 40ba2a00b..6ae1321d2 100644 --- a/evm_arithmetization/src/generation/segments.rs +++ b/evm_arithmetization/src/generation/segments.rs @@ -74,8 +74,8 @@ fn build_segment_data( trie_root_ptrs: interpreter.generation_state.trie_root_ptrs.clone(), jumpdest_table: interpreter.generation_state.jumpdest_table.clone(), next_txn_index: interpreter.generation_state.next_txn_index, - accounts: interpreter.generation_state.state_ptrs.accounts_ptrs.clone(), - storage: interpreter.generation_state.state_ptrs.storage_ptrs.clone(), + accounts: interpreter.generation_state.state_ptrs.accounts.clone(), + storage: interpreter.generation_state.state_ptrs.storage.clone(), }, } } diff --git a/evm_arithmetization/src/generation/state.rs b/evm_arithmetization/src/generation/state.rs index 65fa71d34..94617fda0 100644 --- a/evm_arithmetization/src/generation/state.rs +++ b/evm_arithmetization/src/generation/state.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, HashMap}; +use std::collections::HashMap; use std::mem::size_of; use anyhow::{anyhow, bail}; @@ -400,8 +400,8 @@ impl GenerationState { let generation_state = self.get_mut_generation_state(); let (trie_roots_ptrs, state_leaves, storage_leaves, trie_data) = load_linked_lists_and_txn_and_receipt_mpts( - &mut generation_state.state_ptrs.accounts_ptrs, - &mut generation_state.state_ptrs.storage_ptrs, + &mut generation_state.state_ptrs.accounts, + &mut generation_state.state_ptrs.storage, trie_inputs, ) .expect("Invalid MPT data for preinitialization"); @@ -587,9 +587,9 @@ impl GenerationState { .clone_from(&segment_data.extra_data.trie_root_ptrs); self.jumpdest_table .clone_from(&segment_data.extra_data.jumpdest_table); - self.state_ptrs.accounts_ptrs + self.state_ptrs.accounts .clone_from(&segment_data.extra_data.accounts); - self.state_ptrs.storage_ptrs + self.state_ptrs.storage .clone_from(&segment_data.extra_data.storage); self.next_txn_index = segment_data.extra_data.next_txn_index; self.registers = RegistersState { @@ -605,7 +605,7 @@ impl GenerationState { /// the accounts `BtreeMap`. pub(crate) fn insert_all_slots_in_memory(&mut self) { let storage_mem = self.memory.get_preinit_memory(Segment::StorageLinkedList); - self.state_ptrs.storage_ptrs.extend( + self.state_ptrs.storage.extend( StorageLinkedList::from_mem_and_segment(&storage_mem, Segment::StorageLinkedList) .expect("There must be at least an empty storage linked list") .tuple_windows() @@ -627,7 +627,7 @@ impl GenerationState { pub(crate) fn insert_all_accounts_in_memory(&mut self) { let accounts_mem = self.memory.get_preinit_memory(Segment::AccountsLinkedList); - self.state_ptrs.accounts_ptrs.extend( + self.state_ptrs.accounts.extend( AccountsLinkedList::from_mem_and_segment(&accounts_mem, Segment::AccountsLinkedList) .expect("There must be at least an empty accounts linked list") .tuple_windows() From 58220118ad2e6b25588717352b96ff8ffcf67b02 Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Thu, 19 Sep 2024 11:17:08 +0200 Subject: [PATCH 07/11] Minor --- evm_arithmetization/src/generation/prover_input.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index ce65f8409..fd02d0a7b 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -861,7 +861,7 @@ impl GenerationState { ) } - #[allow(dead_code)]git co + #[allow(dead_code)] pub(crate) fn get_storage_keys_access_list( &self, ) -> Result, ProgramError> { From a9be74726c8eaff9c73b3d0686561933829576f6 Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Thu, 19 Sep 2024 11:52:44 +0200 Subject: [PATCH 08/11] Reset access lists pointers using PROVER_INPUT --- .../src/cpu/kernel/asm/core/access_lists.asm | 5 +++++ evm_arithmetization/src/generation/prover_input.rs | 8 +++++++- evm_arithmetization/src/generation/state.rs | 7 ------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm b/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm index eda8c4fdd..0c5e5bcde 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm @@ -45,6 +45,11 @@ global init_access_lists: // Store the segment scaled length %increment %mstore_global_metadata(@GLOBAL_METADATA_ACCESSED_STORAGE_KEYS_LEN) + + // Reset the access lists pointers in the `GenerationState` + PROVER_INPUT(access_lists::reset) + POP // reset pushed a 0 + JUMP %macro init_access_lists diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index fd02d0a7b..3b6b0e165 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -11,7 +11,7 @@ use plonky2::hash::hash_types::RichField; use serde::{Deserialize, Serialize}; use super::linked_list::{ - LinkedList, ACCOUNTS_LINKED_LIST_NODE_SIZE, STORAGE_LINKED_LIST_NODE_SIZE, + LinkedList, LinkedListPtrs, ACCOUNTS_LINKED_LIST_NODE_SIZE, STORAGE_LINKED_LIST_NODE_SIZE }; use super::mpt::load_state_mpt; use crate::cpu::kernel::cancun_constants::KZG_VERSIONED_HASH; @@ -329,6 +329,7 @@ impl GenerationState { "storage_insert" => self.run_next_storage_insert(), "address_remove" => self.run_next_addresses_remove(), "storage_remove" => self.run_next_storage_remove(), + "reset" => self.run_reset(), _ => Err(ProgramError::ProverInputError(InvalidInput)), } } @@ -504,6 +505,11 @@ impl GenerationState { Ok(U256::from(ptr / 4)) } + fn run_reset(&mut self) -> Result { + self.access_lists_ptrs = LinkedListPtrs::default(); + Ok(U256::zero()) + } + /// Returns a pointer to a node in the list such that /// `node[0] <= addr < next_node[0]` and `addr` is the top of the stack. fn run_next_insert_account(&mut self, input_fn: &ProverInputFn) -> Result { diff --git a/evm_arithmetization/src/generation/state.rs b/evm_arithmetization/src/generation/state.rs index 94617fda0..5c783d158 100644 --- a/evm_arithmetization/src/generation/state.rs +++ b/evm_arithmetization/src/generation/state.rs @@ -196,13 +196,6 @@ pub(crate) trait State { let registers = self.get_registers(); let pc = registers.program_counter; - // If we reached init_access_lists, we need to clear the pointers - let init_access_lists = KERNEL.global_labels["init_access_lists"]; - if running && pc == init_access_lists && registers.is_kernel { - let gen_state = self.get_mut_generation_state(); - gen_state.access_lists_ptrs = LinkedListPtrs::default(); - } - let halt_final = registers.is_kernel && halt_offsets.contains(&pc); if running && (self.at_halt() || self.at_end_segment(cycle_limit)) { running = false; From 42c64813645aa3aeaeb2e5fbd65623824ec2b4a0 Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Mon, 23 Sep 2024 11:10:38 -0400 Subject: [PATCH 09/11] Rustfmt --- evm_arithmetization/src/cpu/kernel/interpreter.rs | 2 -- evm_arithmetization/src/generation/prover_input.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/evm_arithmetization/src/cpu/kernel/interpreter.rs b/evm_arithmetization/src/cpu/kernel/interpreter.rs index c113e749d..78e11206e 100644 --- a/evm_arithmetization/src/cpu/kernel/interpreter.rs +++ b/evm_arithmetization/src/cpu/kernel/interpreter.rs @@ -87,8 +87,6 @@ pub(crate) fn simulate_cpu_and_get_user_jumps( log::debug!("Simulating CPU for jumpdest analysis."); - log::debug!("el bt = {:?}", interpreter.generation_state.access_lists_ptrs.accounts); - let _ = interpreter.run(); log::trace!("jumpdest table = {:?}", interpreter.jumpdest_table); diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index 57b827762..251911082 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -11,7 +11,7 @@ use plonky2::hash::hash_types::RichField; use serde::{Deserialize, Serialize}; use super::linked_list::{ - LinkedList, LinkedListsPtrs, ACCOUNTS_LINKED_LIST_NODE_SIZE, STORAGE_LINKED_LIST_NODE_SIZE + LinkedList, LinkedListsPtrs, ACCOUNTS_LINKED_LIST_NODE_SIZE, STORAGE_LINKED_LIST_NODE_SIZE, }; use super::mpt::load_state_mpt; use crate::cpu::kernel::cancun_constants::KZG_VERSIONED_HASH; From 3c0e72307579d8da71892881e3cbb1dec848d82e Mon Sep 17 00:00:00 2001 From: Alonso Gonzalez Date: Thu, 26 Sep 2024 15:08:45 +0200 Subject: [PATCH 10/11] Address reviews --- .../src/generation/linked_list.rs | 24 +++++- .../src/generation/prover_input.rs | 73 ++++++------------- evm_arithmetization/src/generation/state.rs | 8 +- 3 files changed, 48 insertions(+), 57 deletions(-) diff --git a/evm_arithmetization/src/generation/linked_list.rs b/evm_arithmetization/src/generation/linked_list.rs index 48a4d910c..6ff9e039b 100644 --- a/evm_arithmetization/src/generation/linked_list.rs +++ b/evm_arithmetization/src/generation/linked_list.rs @@ -1,29 +1,45 @@ use std::collections::BTreeMap; +#[cfg(test)] use std::fmt; +#[cfg(test)] use std::marker::PhantomData; +#[cfg(test)] use anyhow::Result; use ethereum_types::U256; use serde::{Deserialize, Serialize}; use crate::memory::segments::Segment; +#[cfg(test)] use crate::util::u256_to_usize; +#[cfg(test)] use crate::witness::errors::ProgramError; +#[cfg(test)] use crate::witness::errors::ProverInputError::InvalidInput; pub const ACCOUNTS_LINKED_LIST_NODE_SIZE: usize = 4; pub const STORAGE_LINKED_LIST_NODE_SIZE: usize = 5; +#[cfg(test)] +pub const ADDRESSES_ACCESS_LIST_LEN: usize = 2; + +pub const DUMMYHEAD: (U256, U256) = (U256::MAX, U256::zero()); + +#[cfg(test)] pub(crate) trait LinkedListType {} #[derive(Clone)] /// A linked list that starts from the first node after the special node and /// iterates forever. +#[cfg(test)] pub(crate) struct Cyclic; #[derive(Clone)] /// A linked list that starts from the special node and iterates until the last /// node. +#[cfg(test)] pub(crate) struct Bounded; +#[cfg(test)] impl LinkedListType for Cyclic {} +#[cfg(test)] impl LinkedListType for Bounded {} // A linked list implemented using a vector `access_list_mem`. @@ -31,6 +47,7 @@ impl LinkedListType for Bounded {} // `access_list_mem[i..i + node_size - 1]`, and `access_list_mem[i + node_size - // 1]` holds the address of the next node, where i = node_size * j. #[derive(Clone)] +#[cfg(test)] pub(crate) struct LinkedList<'a, const N: usize, T = Cyclic> where T: LinkedListType, @@ -67,6 +84,7 @@ pub(crate) fn empty_list_mem(segment: Segment) -> [Option; }) } +#[cfg(test)] impl<'a, const N: usize, T: LinkedListType> LinkedList<'a, N, T> { pub fn from_mem_and_segment( mem: &'a [Option], @@ -79,7 +97,7 @@ impl<'a, const N: usize, T: LinkedListType> LinkedList<'a, N, T> { mem: &'a [Option], segment: Segment, ) -> Result { - if mem.is_empty() || mem.len() % N != 0 { + if mem.len() % N != 0 { return Err(ProgramError::ProverInputError(InvalidInput)); } Ok(Self { @@ -91,6 +109,7 @@ impl<'a, const N: usize, T: LinkedListType> LinkedList<'a, N, T> { } } +#[cfg(test)] impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "Linked List {{")?; @@ -105,6 +124,7 @@ impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N> { } } +#[cfg(test)] impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N, Bounded> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "Linked List {{")?; @@ -116,6 +136,7 @@ impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N, Bounded> { } } +#[cfg(test)] impl<'a, const N: usize> Iterator for LinkedList<'a, N> { type Item = [U256; N]; @@ -132,6 +153,7 @@ impl<'a, const N: usize> Iterator for LinkedList<'a, N> { } } +#[cfg(test)] impl<'a, const N: usize> Iterator for LinkedList<'a, N, Bounded> { type Item = [U256; N]; diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index 251911082..25af055e8 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -10,8 +10,10 @@ use num_bigint::BigUint; use plonky2::hash::hash_types::RichField; use serde::{Deserialize, Serialize}; +#[cfg(test)] +use super::linked_list::{LinkedList, ADDRESSES_ACCESS_LIST_LEN}; use super::linked_list::{ - LinkedList, LinkedListsPtrs, ACCOUNTS_LINKED_LIST_NODE_SIZE, STORAGE_LINKED_LIST_NODE_SIZE, + LinkedListsPtrs, ACCOUNTS_LINKED_LIST_NODE_SIZE, DUMMYHEAD, STORAGE_LINKED_LIST_NODE_SIZE, }; use super::mpt::load_state_mpt; use crate::cpu::kernel::cancun_constants::KZG_VERSIONED_HASH; @@ -44,11 +46,6 @@ use crate::witness::util::{current_context_peek, stack_peek}; #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)] pub struct ProverInputFn(Vec); -#[allow(dead_code)] -pub const ADDRESSES_ACCESS_LIST_LEN: usize = 2; -#[allow(dead_code)] -pub const STORAGE_KEYS_ACCESS_LIST_LEN: usize = 4; - impl From> for ProverInputFn { fn from(v: Vec) -> Self { Self(v) @@ -466,10 +463,7 @@ impl GenerationState { .storage .range(..=(addr, key)) .next_back() - .unwrap_or(( - &(U256::MAX, U256::zero()), - &(Segment::AccessedStorageKeys as usize), - )); + .unwrap_or((&DUMMYHEAD, &(Segment::AccessedStorageKeys as usize))); if pred_addr != addr || pred_slot_key != key { self.access_lists_ptrs.storage.insert( (addr, key), @@ -493,10 +487,7 @@ impl GenerationState { .storage .range(..(addr, key)) .next_back() - .unwrap_or(( - &(U256::MAX, U256::zero()), - &(Segment::AccessedStorageKeys as usize), - )); + .unwrap_or((&DUMMYHEAD, &(Segment::AccessedStorageKeys as usize))); self.access_lists_ptrs .storage .remove(&(addr, key)) @@ -548,10 +539,7 @@ impl GenerationState { .storage .range(..=(addr, key)) .next_back() - .unwrap_or(( - &(U256::MAX, U256::zero()), - &(Segment::StorageLinkedList as usize), - )); + .unwrap_or((&DUMMYHEAD, &(Segment::StorageLinkedList as usize))); if (pred_addr != addr || pred_slot_key != key) && input_fn.0[1] == "insert_slot" { self.state_ptrs.storage.insert( (addr, key), @@ -599,10 +587,7 @@ impl GenerationState { .storage .range(..(addr, key)) .next_back() - .unwrap_or(( - &(U256::MAX, U256::zero()), - &(Segment::StorageLinkedList as usize), - )); + .unwrap_or((&DUMMYHEAD, &(Segment::StorageLinkedList as usize))); self.state_ptrs .storage .remove(&(addr, key)) @@ -625,16 +610,26 @@ impl GenerationState { .storage .range(..(addr, U256::zero())) .next_back() - .unwrap_or(( - &(U256::MAX, U256::zero()), - &(Segment::StorageLinkedList as usize), - )); + .unwrap_or((&DUMMYHEAD, &(Segment::StorageLinkedList as usize))); Ok(U256::from( (pred_ptr - Segment::StorageLinkedList as usize) / STORAGE_LINKED_LIST_NODE_SIZE, )) } + #[cfg(test)] + pub(crate) fn get_addresses_access_list( + &self, + ) -> Result, ProgramError> { + // `GlobalMetadata::AccessedAddressesLen` stores the value of the next available + // virtual address in the segment. In order to get the length we need + // to substract `Segment::AccessedAddresses` as usize. + LinkedList::from_mem_and_segment( + &self.memory.contexts[0].segments[Segment::AccessedAddresses.unscale()].content, + Segment::AccessedAddresses, + ) + } + /// Returns the first part of the KZG precompile output. fn run_kzg_point_eval(&mut self) -> Result { let versioned_hash = stack_peek(self, 0)?; @@ -853,32 +848,6 @@ impl GenerationState { } } } - - #[allow(dead_code)] - pub(crate) fn get_addresses_access_list( - &self, - ) -> Result, ProgramError> { - // `GlobalMetadata::AccessedAddressesLen` stores the value of the next available - // virtual address in the segment. In order to get the length we need - // to substract `Segment::AccessedAddresses` as usize. - LinkedList::from_mem_and_segment( - &self.memory.contexts[0].segments[Segment::AccessedAddresses.unscale()].content, - Segment::AccessedAddresses, - ) - } - - #[allow(dead_code)] - pub(crate) fn get_storage_keys_access_list( - &self, - ) -> Result, ProgramError> { - // GlobalMetadata::AccessedStorageKeysLen stores the value of the next available - // virtual address in the segment. In order to get the length we need - // to substract `Segment::AccessedStorageKeys` as usize. - LinkedList::from_mem_and_segment( - &self.memory.contexts[0].segments[Segment::AccessedStorageKeys.unscale()].content, - Segment::AccessedStorageKeys, - ) - } } /// For all address in `jumpdest_table` smaller than `largest_address`, diff --git a/evm_arithmetization/src/generation/state.rs b/evm_arithmetization/src/generation/state.rs index 6b25e8186..1ea87bd0c 100644 --- a/evm_arithmetization/src/generation/state.rs +++ b/evm_arithmetization/src/generation/state.rs @@ -376,12 +376,12 @@ pub struct GenerationState { /// j in [i, i+32] it holds that code[j] < 0x7f - j + i. pub(crate) jumpdest_table: Option>>, - // Provides quick access to pointers that reference the memory location - // of an accounts or storage access list node containing a specific key. + /// Provides quick access to pointers that reference the location + /// of either and account or a slot in the respective access list. pub(crate) access_lists_ptrs: LinkedListsPtrs, - // Provides quick access to pointers that reference the memory location - // of a accounts or storage linked list node containing a specific key. + /// Provides quick access to pointers that reference the memory location of + /// either and account or a slot in the respective access list. pub(crate) state_ptrs: LinkedListsPtrs, } From b36443a87bf586e0a348d191c170cfa793d42763 Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Thu, 26 Sep 2024 10:51:25 -0400 Subject: [PATCH 11/11] Refactor cfg(test) --- .../src/cpu/kernel/tests/mpt/linked_list.rs | 2 +- .../src/generation/linked_list.rs | 204 +++++++++--------- .../src/generation/prover_input.rs | 2 +- 3 files changed, 98 insertions(+), 110 deletions(-) diff --git a/evm_arithmetization/src/cpu/kernel/tests/mpt/linked_list.rs b/evm_arithmetization/src/cpu/kernel/tests/mpt/linked_list.rs index d80baae61..b31c05233 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/mpt/linked_list.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/mpt/linked_list.rs @@ -12,7 +12,7 @@ use rand::{thread_rng, Rng}; use crate::cpu::kernel::aggregator::KERNEL; use crate::cpu::kernel::constants::global_metadata::GlobalMetadata; use crate::cpu::kernel::interpreter::Interpreter; -use crate::generation::linked_list::LinkedList; +use crate::generation::linked_list::testing::LinkedList; use crate::generation::linked_list::ACCOUNTS_LINKED_LIST_NODE_SIZE; use crate::generation::linked_list::STORAGE_LINKED_LIST_NODE_SIZE; use crate::memory::segments::Segment; diff --git a/evm_arithmetization/src/generation/linked_list.rs b/evm_arithmetization/src/generation/linked_list.rs index 6ff9e039b..b2465bb88 100644 --- a/evm_arithmetization/src/generation/linked_list.rs +++ b/evm_arithmetization/src/generation/linked_list.rs @@ -1,63 +1,15 @@ use std::collections::BTreeMap; -#[cfg(test)] -use std::fmt; -#[cfg(test)] -use std::marker::PhantomData; -#[cfg(test)] -use anyhow::Result; use ethereum_types::U256; use serde::{Deserialize, Serialize}; use crate::memory::segments::Segment; -#[cfg(test)] -use crate::util::u256_to_usize; -#[cfg(test)] -use crate::witness::errors::ProgramError; -#[cfg(test)] -use crate::witness::errors::ProverInputError::InvalidInput; pub const ACCOUNTS_LINKED_LIST_NODE_SIZE: usize = 4; pub const STORAGE_LINKED_LIST_NODE_SIZE: usize = 5; -#[cfg(test)] -pub const ADDRESSES_ACCESS_LIST_LEN: usize = 2; - pub const DUMMYHEAD: (U256, U256) = (U256::MAX, U256::zero()); -#[cfg(test)] -pub(crate) trait LinkedListType {} -#[derive(Clone)] -/// A linked list that starts from the first node after the special node and -/// iterates forever. -#[cfg(test)] -pub(crate) struct Cyclic; -#[derive(Clone)] -/// A linked list that starts from the special node and iterates until the last -/// node. -#[cfg(test)] -pub(crate) struct Bounded; -#[cfg(test)] -impl LinkedListType for Cyclic {} -#[cfg(test)] -impl LinkedListType for Bounded {} - -// A linked list implemented using a vector `access_list_mem`. -// In this representation, the values of nodes are stored in the range -// `access_list_mem[i..i + node_size - 1]`, and `access_list_mem[i + node_size - -// 1]` holds the address of the next node, where i = node_size * j. -#[derive(Clone)] -#[cfg(test)] -pub(crate) struct LinkedList<'a, const N: usize, T = Cyclic> -where - T: LinkedListType, -{ - mem: &'a [Option], - offset: usize, - pos: usize, - _marker: PhantomData, -} - // Provides quick access to pointers that reference the memory location // of a storage or accounts linked list node, containing a specific key. #[derive(Debug, Clone, Default, Serialize, Deserialize)] @@ -85,80 +37,98 @@ pub(crate) fn empty_list_mem(segment: Segment) -> [Option; } #[cfg(test)] -impl<'a, const N: usize, T: LinkedListType> LinkedList<'a, N, T> { - pub fn from_mem_and_segment( +pub(crate) mod testing { + use std::fmt; + use std::marker::PhantomData; + + use anyhow::Result; + + use super::*; + use crate::util::u256_to_usize; + use crate::witness::errors::ProgramError; + use crate::witness::errors::ProverInputError::InvalidInput; + + pub const ADDRESSES_ACCESS_LIST_LEN: usize = 2; + pub(crate) trait LinkedListType {} + #[derive(Clone)] + /// A linked list that starts from the first node after the special node and + /// iterates forever. + pub(crate) struct Cyclic; + #[derive(Clone)] + /// A linked list that starts from the special node and iterates until the + /// last node. + pub(crate) struct Bounded; + impl LinkedListType for Cyclic {} + impl LinkedListType for Bounded {} + + // A linked list implemented using a vector `access_list_mem`. + // In this representation, the values of nodes are stored in the range + // `access_list_mem[i..i + node_size - 1]`, and `access_list_mem[i + node_size - + // 1]` holds the address of the next node, where i = node_size * j. + #[derive(Clone)] + pub(crate) struct LinkedList<'a, const N: usize, T = Cyclic> + where + T: LinkedListType, + { mem: &'a [Option], - segment: Segment, - ) -> Result { - Self::from_mem_len_and_segment(mem, segment) + offset: usize, + pos: usize, + _marker: PhantomData, } - pub fn from_mem_len_and_segment( - mem: &'a [Option], - segment: Segment, - ) -> Result { - if mem.len() % N != 0 { - return Err(ProgramError::ProverInputError(InvalidInput)); + impl<'a, const N: usize, T: LinkedListType> LinkedList<'a, N, T> { + pub fn from_mem_and_segment( + mem: &'a [Option], + segment: Segment, + ) -> Result { + Self::from_mem_len_and_segment(mem, segment) } - Ok(Self { - mem, - offset: segment as usize, - pos: 0, - _marker: PhantomData, - }) - } -} -#[cfg(test)] -impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - writeln!(f, "Linked List {{")?; - let cloned_list = self.clone(); - for (i, node) in cloned_list.enumerate() { - if i > 0 && node[0] == U256::MAX { - break; + pub fn from_mem_len_and_segment( + mem: &'a [Option], + segment: Segment, + ) -> Result { + if mem.len() % N != 0 { + return Err(ProgramError::ProverInputError(InvalidInput)); } - writeln!(f, "{:?} ->", node)?; + Ok(Self { + mem, + offset: segment as usize, + pos: 0, + _marker: PhantomData, + }) } - write!(f, "}}") } -} -#[cfg(test)] -impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N, Bounded> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - writeln!(f, "Linked List {{")?; - let cloned_list = self.clone(); - for node in cloned_list { - writeln!(f, "{:?} ->", node)?; + impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + writeln!(f, "Linked List {{")?; + let cloned_list = self.clone(); + for (i, node) in cloned_list.enumerate() { + if i > 0 && node[0] == U256::MAX { + break; + } + writeln!(f, "{:?} ->", node)?; + } + write!(f, "}}") } - write!(f, "}}") } -} -#[cfg(test)] -impl<'a, const N: usize> Iterator for LinkedList<'a, N> { - type Item = [U256; N]; - - fn next(&mut self) -> Option { - let node = Some(std::array::from_fn(|i| { - self.mem[self.pos + i].unwrap_or_default() - })); - if let Ok(new_pos) = u256_to_usize(self.mem[self.pos + N - 1].unwrap_or_default()) { - self.pos = new_pos - self.offset; - node - } else { - None + impl<'a, const N: usize> fmt::Debug for LinkedList<'a, N, Bounded> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + writeln!(f, "Linked List {{")?; + let cloned_list = self.clone(); + for node in cloned_list { + writeln!(f, "{:?} ->", node)?; + } + write!(f, "}}") } } -} -#[cfg(test)] -impl<'a, const N: usize> Iterator for LinkedList<'a, N, Bounded> { - type Item = [U256; N]; + impl<'a, const N: usize> Iterator for LinkedList<'a, N> { + type Item = [U256; N]; - fn next(&mut self) -> Option { - if self.mem[self.pos] != Some(U256::MAX) { + fn next(&mut self) -> Option { let node = Some(std::array::from_fn(|i| { self.mem[self.pos + i].unwrap_or_default() })); @@ -168,8 +138,26 @@ impl<'a, const N: usize> Iterator for LinkedList<'a, N, Bounded> { } else { None } - } else { - None + } + } + + impl<'a, const N: usize> Iterator for LinkedList<'a, N, Bounded> { + type Item = [U256; N]; + + fn next(&mut self) -> Option { + if self.mem[self.pos] != Some(U256::MAX) { + let node = Some(std::array::from_fn(|i| { + self.mem[self.pos + i].unwrap_or_default() + })); + if let Ok(new_pos) = u256_to_usize(self.mem[self.pos + N - 1].unwrap_or_default()) { + self.pos = new_pos - self.offset; + node + } else { + None + } + } else { + None + } } } } diff --git a/evm_arithmetization/src/generation/prover_input.rs b/evm_arithmetization/src/generation/prover_input.rs index 25af055e8..704e2f4c6 100644 --- a/evm_arithmetization/src/generation/prover_input.rs +++ b/evm_arithmetization/src/generation/prover_input.rs @@ -11,7 +11,7 @@ use plonky2::hash::hash_types::RichField; use serde::{Deserialize, Serialize}; #[cfg(test)] -use super::linked_list::{LinkedList, ADDRESSES_ACCESS_LIST_LEN}; +use super::linked_list::testing::{LinkedList, ADDRESSES_ACCESS_LIST_LEN}; use super::linked_list::{ LinkedListsPtrs, ACCOUNTS_LINKED_LIST_NODE_SIZE, DUMMYHEAD, STORAGE_LINKED_LIST_NODE_SIZE, };