diff --git a/evm/src/cpu/kernel/asm/core/transfer.asm b/evm/src/cpu/kernel/asm/core/transfer.asm index 05582e6e..8ae2d854 100644 --- a/evm/src/cpu/kernel/asm/core/transfer.asm +++ b/evm/src/cpu/kernel/asm/core/transfer.asm @@ -38,6 +38,7 @@ global transfer_eth_failure: // Returns 0 on success, or 1 if addr has insufficient balance. Panics if addr isn't found in the trie. // Pre stack: addr, amount, retdest // Post stack: status (0 indicates success) +// TODO: Should it be copy-on-write (with make_account_copy) instead of mutating the trie? global deduct_eth: // stack: addr, amount, retdest %mpt_read_state_trie @@ -73,7 +74,7 @@ global deduct_eth_insufficient_balance: // Pre stack: addr, amount, redest // Post stack: (empty) -// TODO: Should it be copy-on-write instead of mutating the trie? +// TODO: Should it be copy-on-write (with make_account_copy) instead of mutating the trie? global add_eth: // stack: addr, amount, retdest DUP1 %mpt_read_state_trie diff --git a/evm/src/cpu/kernel/asm/mpt/accounts.asm b/evm/src/cpu/kernel/asm/mpt/accounts.asm index 08291048..050dbb41 100644 --- a/evm/src/cpu/kernel/asm/mpt/accounts.asm +++ b/evm/src/cpu/kernel/asm/mpt/accounts.asm @@ -38,8 +38,8 @@ global make_account_copy: DUP2 %mload_trie_data %append_to_trie_data DUP2 %add_const(1) %mload_trie_data %append_to_trie_data - DUP2 %add_const(3) %mload_trie_data %append_to_trie_data - SWAP1 %add_const(4) %mload_trie_data %append_to_trie_data + DUP2 %add_const(2) %mload_trie_data %append_to_trie_data + SWAP1 %add_const(3) %mload_trie_data %append_to_trie_data // stack: new_account_ptr, retdest SWAP1 diff --git a/evm/src/cpu/kernel/constants/trie_type.rs b/evm/src/cpu/kernel/constants/trie_type.rs index 30f4802b..fc71c1f4 100644 --- a/evm/src/cpu/kernel/constants/trie_type.rs +++ b/evm/src/cpu/kernel/constants/trie_type.rs @@ -1,6 +1,6 @@ use eth_trie_utils::partial_trie::PartialTrie; -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub(crate) enum PartialTrieType { Empty = 0, Hash = 1, diff --git a/evm/src/generation/mod.rs b/evm/src/generation/mod.rs index aa17b9c9..2c786d8f 100644 --- a/evm/src/generation/mod.rs +++ b/evm/src/generation/mod.rs @@ -123,6 +123,11 @@ pub(crate) fn generate_traces, const D: usize>( timed!(timing, "simulate CPU", simulate_cpu(&mut state)?); + assert!( + state.mpt_prover_inputs.is_empty(), + "All MPT data should have been consumed" + ); + log::info!( "Trace lengths (before padding): {:?}", state.traces.checkpoint() diff --git a/evm/src/generation/outputs.rs b/evm/src/generation/outputs.rs index a197b1b6..b6da3576 100644 --- a/evm/src/generation/outputs.rs +++ b/evm/src/generation/outputs.rs @@ -78,7 +78,7 @@ fn account_trie_record_to_output( .inputs .contract_code .get(&account.code_hash) - .expect("Code not found") + .unwrap_or_else(|| panic!("Code not found: {:?}", account.code_hash)) .clone(); AccountOutput { diff --git a/evm/src/generation/trie_extractor.rs b/evm/src/generation/trie_extractor.rs index a7f01c97..66174419 100644 --- a/evm/src/generation/trie_extractor.rs +++ b/evm/src/generation/trie_extractor.rs @@ -10,6 +10,7 @@ use crate::memory::segments::Segment; use crate::witness::memory::{MemoryAddress, MemoryState}; /// Account data as it's stored in the state trie, with a pointer to the storage trie. +#[derive(Debug)] pub(crate) struct AccountTrieRecord { pub(crate) nonce: u64, pub(crate) balance: U256,