mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 23:33:07 +00:00
Fix account cloning
This commit is contained in:
parent
994c54abe6
commit
8c692b72b0
@ -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.
|
// 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
|
// Pre stack: addr, amount, retdest
|
||||||
// Post stack: status (0 indicates success)
|
// 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:
|
global deduct_eth:
|
||||||
// stack: addr, amount, retdest
|
// stack: addr, amount, retdest
|
||||||
%mpt_read_state_trie
|
%mpt_read_state_trie
|
||||||
@ -73,7 +74,7 @@ global deduct_eth_insufficient_balance:
|
|||||||
|
|
||||||
// Pre stack: addr, amount, redest
|
// Pre stack: addr, amount, redest
|
||||||
// Post stack: (empty)
|
// 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:
|
global add_eth:
|
||||||
// stack: addr, amount, retdest
|
// stack: addr, amount, retdest
|
||||||
DUP1 %mpt_read_state_trie
|
DUP1 %mpt_read_state_trie
|
||||||
|
|||||||
@ -38,8 +38,8 @@ global make_account_copy:
|
|||||||
|
|
||||||
DUP2 %mload_trie_data %append_to_trie_data
|
DUP2 %mload_trie_data %append_to_trie_data
|
||||||
DUP2 %add_const(1) %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
|
DUP2 %add_const(2) %mload_trie_data %append_to_trie_data
|
||||||
SWAP1 %add_const(4) %mload_trie_data %append_to_trie_data
|
SWAP1 %add_const(3) %mload_trie_data %append_to_trie_data
|
||||||
|
|
||||||
// stack: new_account_ptr, retdest
|
// stack: new_account_ptr, retdest
|
||||||
SWAP1
|
SWAP1
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use eth_trie_utils::partial_trie::PartialTrie;
|
use eth_trie_utils::partial_trie::PartialTrie;
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub(crate) enum PartialTrieType {
|
pub(crate) enum PartialTrieType {
|
||||||
Empty = 0,
|
Empty = 0,
|
||||||
Hash = 1,
|
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)?);
|
timed!(timing, "simulate CPU", simulate_cpu(&mut state)?);
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
state.mpt_prover_inputs.is_empty(),
|
||||||
|
"All MPT data should have been consumed"
|
||||||
|
);
|
||||||
|
|
||||||
log::info!(
|
log::info!(
|
||||||
"Trace lengths (before padding): {:?}",
|
"Trace lengths (before padding): {:?}",
|
||||||
state.traces.checkpoint()
|
state.traces.checkpoint()
|
||||||
|
|||||||
@ -78,7 +78,7 @@ fn account_trie_record_to_output<F: Field>(
|
|||||||
.inputs
|
.inputs
|
||||||
.contract_code
|
.contract_code
|
||||||
.get(&account.code_hash)
|
.get(&account.code_hash)
|
||||||
.expect("Code not found")
|
.unwrap_or_else(|| panic!("Code not found: {:?}", account.code_hash))
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
AccountOutput {
|
AccountOutput {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ use crate::memory::segments::Segment;
|
|||||||
use crate::witness::memory::{MemoryAddress, MemoryState};
|
use crate::witness::memory::{MemoryAddress, MemoryState};
|
||||||
|
|
||||||
/// Account data as it's stored in the state trie, with a pointer to the storage trie.
|
/// 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) struct AccountTrieRecord {
|
||||||
pub(crate) nonce: u64,
|
pub(crate) nonce: u64,
|
||||||
pub(crate) balance: U256,
|
pub(crate) balance: U256,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user