Fix account cloning

This commit is contained in:
Daniel Lubarov 2023-03-17 13:10:58 -07:00
parent 994c54abe6
commit 8c692b72b0
6 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -123,6 +123,11 @@ pub(crate) fn generate_traces<F: RichField + Extendable<D>, 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()

View File

@ -78,7 +78,7 @@ fn account_trie_record_to_output<F: Field>(
.inputs
.contract_code
.get(&account.code_hash)
.expect("Code not found")
.unwrap_or_else(|| panic!("Code not found: {:?}", account.code_hash))
.clone();
AccountOutput {

View File

@ -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,