mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 14:23:07 +00:00
Merge pull request #915 from mir-protocol/fix_clone_account
Fix account cloning
This commit is contained in:
commit
2ac4fcdf84
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user