Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(continuations): write storage values directly in linked lists #433

Merged
merged 141 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
a50e2db
[WIP] add account to linked list
4l0n50 May 3, 2024
52dc55d
Add account linked list and some unit tests
4l0n50 May 3, 2024
d242757
Modify tests for insetions and fix bugs
4l0n50 May 6, 2024
4558a38
Fix deletion test
4l0n50 May 6, 2024
c369aa5
[WIP] Getting trie data without leaves
4l0n50 May 7, 2024
ecf0e86
[WIP] changes during the flights
4l0n50 May 22, 2024
65773d8
Fix storage ll error
4l0n50 May 24, 2024
c9e3b4f
Add missing file
4l0n50 May 24, 2024
ba87c79
[WIP] checking consistency between linked list and state trie
4l0n50 May 24, 2024
6fc8c22
[WIP] addr 0x798c6047767c10f653ca157a7f66a592a1d6ca550cae352912be0b07…
4l0n50 May 27, 2024
31a850f
[WIP] add missing nibbles to key
4l0n50 May 27, 2024
d1df4c5
Fix accounts insertions
4l0n50 May 28, 2024
7689629
Check storage reads
4l0n50 May 28, 2024
29b79b1
Add segments to preinitialization
hratoanina May 29, 2024
edfc137
[WIP] Unreasonable offset
4l0n50 May 29, 2024
796087b
[WIP] Erc721 error
4l0n50 May 29, 2024
566ccb5
[WIP] uncomment ll reads
4l0n50 May 29, 2024
12e63ea
[WIP] Fixing iterator
4l0n50 May 30, 2024
c1f47dd
Fix unit tests
4l0n50 May 31, 2024
9a9323d
Fix erc721 error
4l0n50 May 31, 2024
6c93057
mend
4l0n50 May 31, 2024
48d1cfe
Remove debug info
May 31, 2024
c938cad
mend
May 31, 2024
dba0967
[WIP] hashing
4l0n50 Jun 3, 2024
8a386f9
Provide constants non-deterministically
hratoanina Jun 3, 2024
5deb97d
Update journaling
LindaGuiga Jun 4, 2024
fbb216b
Update search_account and read_accounts_linked_lists
LindaGuiga Jun 4, 2024
8c3ac79
Constraint state and storage leaves
Jun 4, 2024
1232b9a
Update slot and account search methods in linked_lists and update rev…
LindaGuiga Jun 4, 2024
5d43ff4
Fix asm
LindaGuiga Jun 5, 2024
bd1215d
Some fixes and debugging
LindaGuiga Jun 7, 2024
c4f410d
Fix hash mismatch
Jun 7, 2024
f650e8a
Fix bug while setting storage payloads
Jun 7, 2024
55255f6
Merge remote-tracking branch 'refs/remotes/origin/linked_lists' into …
Jun 7, 2024
128f614
Add functions for updating final trie
Jun 10, 2024
95e3001
[WIP] eliminating trie call
4l0n50 Jun 11, 2024
660a4f4
[WIP] Fix kexit_data issue
4l0n50 Jun 11, 2024
b9e2307
Merge with journaling branch
4l0n50 Jun 11, 2024
287cddd
Merge with journaling branch
4l0n50 Jun 11, 2024
9915fed
[WIP] set final tries
4l0n50 Jun 11, 2024
9a28eb5
Mutate storage payload on insertions
4l0n50 Jun 12, 2024
09a03b2
Fix deletions in final trie computation
4l0n50 Jun 12, 2024
7661bce
Remove double hashing of the initial state trie
4l0n50 Jun 12, 2024
2b666db
Merge branch 'develop' into linked_lists
Nashtare Jun 12, 2024
a144892
Misc
Nashtare Jun 12, 2024
dbc5a6a
trace_decoder/Cargo.toml
4l0n50 Jun 13, 2024
6bea276
Fix return from read_storage_linked_list_w_addr
Nashtare Jun 13, 2024
7660051
[WIP] debugging unit tests
4l0n50 Jun 13, 2024
67fd5cb
Merge remote-tracking branch 'refs/remotes/origin/linked_lists' into …
4l0n50 Jun 13, 2024
f0068aa
Fix set_payload_storage_extension and bring back final gas check
Nashtare Jun 13, 2024
885fe35
Merge remote-tracking branch 'refs/remotes/origin/linked_lists' into …
4l0n50 Jun 13, 2024
a4c3f91
Fix failing shanghai blocks
4l0n50 Jun 14, 2024
3922c06
Fix run_next_addresses_remove and some revertions
LindaGuiga Jun 21, 2024
24e6e6b
Some journaling fixes
LindaGuiga Jun 24, 2024
4355a51
FIx revert_storage_change and revert_account_created
LindaGuiga Jun 24, 2024
33235a9
Fix delete account
4l0n50 Jun 24, 2024
f54864a
[WIP] fixing LoopCallsDepthThenRevert3_d0g0v0_Shanghai.json
4l0n50 Jun 24, 2024
8945002
Add an overwrite version of account insertion and use it for mpt_inse…
LindaGuiga Jun 25, 2024
87b0c63
Fix final state trie hash mismatch
4l0n50 Jun 25, 2024
ef231c0
Fix insert_new_slot_with_value
LindaGuiga Jun 25, 2024
44e316e
Debugging variedContext_d10g0v0_Shanghai.json
4l0n50 Jun 26, 2024
29ca9df
Fix variedContext_d10g0v0_Shanghai
4l0n50 Jun 26, 2024
bf91f44
[WIP] Fixing vitalikTransactionTestParis_d0g0v0_Shanghai
4l0n50 Jun 26, 2024
c7ac311
Merge with develop
4l0n50 Jun 26, 2024
bc7341d
Merge remote-tracking branch 'origin/develop' into linked_lists
4l0n50 Jun 26, 2024
f34c4ed
Merge remote-tracking branch 'origin/develop' into linked_lists
Nashtare Jun 27, 2024
b83871d
Delete all associated slots when an account is deleted
LindaGuiga Jun 27, 2024
c6fed71
Fix run_next_remove_address_slots
LindaGuiga Jun 27, 2024
268604e
Copy initial accounts and slots
4l0n50 Jun 27, 2024
7e99b14
Fix find condition in run_next_remove_address_slots
LindaGuiga Jun 27, 2024
f769fa6
Fix erc721
4l0n50 Jul 1, 2024
cc71c4b
Deep copy of accounts and slots
4l0n50 Jul 1, 2024
5d4737d
Merge remote-tracking branch 'origin/linked_lists' into linked_lists_…
4l0n50 Jul 2, 2024
8111883
[WIP] Testing evm test suite
4l0n50 Jul 2, 2024
05d75ab
Fix most unit tests and fix revert_account_created
LindaGuiga Jul 2, 2024
f35c2c8
FIx linked list test and a bit of cleanup
LindaGuiga Jul 2, 2024
9bed611
Start merge
LindaGuiga Jul 2, 2024
244c9a8
[WIP] Debugging /stExample/basefeeExample_d0g0v0_Shanghai
4l0n50 Jul 3, 2024
54b360a
Fix merge and add batch sizes to the benchmark
LindaGuiga Jul 3, 2024
da7902b
Fix test_only in zero_bin
LindaGuiga Jul 3, 2024
1f8d853
Merge branch 'develop' into merge-continuations-develop
LindaGuiga Jul 3, 2024
ca490c1
Fix rlp pointers error
4l0n50 Jul 3, 2024
a9dc130
Minor
4l0n50 Jul 3, 2024
c07c4a4
Remove panic
Nashtare Jul 3, 2024
cb93551
Remove outdated counter update in insert_account_with_overwrite
4l0n50 Jul 3, 2024
53708dd
Merge remote-tracking branch 'refs/remotes/origin/linked_lists_late_h…
4l0n50 Jul 4, 2024
c1d8b4c
[WIP] Debugging InitCollisionParis_d2g0v0_Shanghai
4l0n50 Jul 4, 2024
eaddcc1
[WIP] Debugging stCallCodes/callcallcodecallcode_011_SuicideEnd_d0g0v…
4l0n50 Jul 4, 2024
29c23a9
Fix remove_all_slots
LindaGuiga Jul 4, 2024
9c2a58b
Merge Linda's callcallcodecallcode_011_SuicideEnd_d0g0v0_Shanghai
4l0n50 Jul 4, 2024
d1a647e
Merge remote-tracking branch 'refs/remotes/origin/linked_lists_late_h…
4l0n50 Jul 4, 2024
71e3eee
Clean code
4l0n50 Jul 4, 2024
352767f
Fix account code initialize mpts
4l0n50 Jul 4, 2024
a31692a
Apply comments and fix CI.
LindaGuiga Jul 4, 2024
2ce9465
Improve remove_all_slots_loop
LindaGuiga Jul 4, 2024
9d6072b
Fix stack comment
Nashtare Jul 5, 2024
899d471
Misc, faster get_valid_slot_ptr
Nashtare Jul 5, 2024
c9ad38e
[WIP] Debugging erc20
4l0n50 Jul 5, 2024
e4adcb0
Remove counter update and cold_access
Nashtare Jul 5, 2024
5717dbc
Merge branch 'merge-continuations-develop' into linked_lists_continua…
LindaGuiga Jul 5, 2024
bb4e2d2
Fix log_opcode circuit sizes
LindaGuiga Jul 5, 2024
99d0b8a
Fix stack comment and remove ctr update
Nashtare Jul 5, 2024
e59e282
Fix preinitialization
LindaGuiga Jul 8, 2024
ac6f85e
Fix unit tests
4l0n50 Jul 9, 2024
74c55a6
Debugging stShift/shr01_d0g0v0_Shanghai
4l0n50 Jul 10, 2024
6aeb8d3
Fixing shiftSignedCombinations_d0g0v0_Shanghai
4l0n50 Jul 10, 2024
6a10adc
Remove counter assertions from linked_lists tests
LindaGuiga Jul 11, 2024
af1c2c0
Merge branch 'linked_lists' into linked_lists_late_hash
LindaGuiga Jul 11, 2024
e395474
Merge branch 'linked_lists_continuations' into linked_lists_late_hash
LindaGuiga Jul 11, 2024
5074895
Fix preinitialization and start cleanup
LindaGuiga Jul 11, 2024
6e043f9
Fix test_process_receipt
LindaGuiga Jul 11, 2024
09a4967
Merge remote-tracking branch 'origin/feat/continuations' into late_ha…
Nashtare Jul 11, 2024
439b4a0
Fix MPT insert tests
Nashtare Jul 11, 2024
d3dd09a
Add check in mpt_insert tests
LindaGuiga Jul 12, 2024
b9b8c5c
Additional fixes
LindaGuiga Jul 12, 2024
9d994c1
Pass preinitialized_segments when necessary
LindaGuiga Jul 15, 2024
1756b03
Fix all unit tests
LindaGuiga Jul 15, 2024
19aa264
Cleanup
LindaGuiga Jul 16, 2024
e725678
More comments cleanup
LindaGuiga Jul 16, 2024
6436d12
Do not store memory content as vec
Nashtare Jul 13, 2024
dcf0575
Prevent needless conversion
Nashtare Jul 13, 2024
97b21af
Remove needless copy
Nashtare Jul 13, 2024
94a61e7
Remove needless checks
Nashtare Jul 13, 2024
3c915f3
Use tuple_windows instead
Nashtare Jul 13, 2024
526c456
Typo
Nashtare Jul 14, 2024
b992e9e
Remove leftover
Nashtare Jul 16, 2024
d9840d4
Remove unrelated changes
Nashtare Jul 16, 2024
b0c4248
Fix clone_slot
LindaGuiga Jul 16, 2024
80212ae
Remove assert 0 from clone_slot
LindaGuiga Jul 16, 2024
7445d53
Fix next_node_ok_with_value
LindaGuiga Jul 16, 2024
b46da0e
Apply comments and cleanup
LindaGuiga Jul 18, 2024
04ab8f7
Fix next_node_ok_with_value and tiny cleanup
LindaGuiga Jul 22, 2024
90cb9d1
Start addressing comments
LindaGuiga Jul 23, 2024
f92c4eb
Remove unnecessary linked_lists methods and payload_ptr
LindaGuiga Jul 23, 2024
7ebae47
Store storage value in linked list
LindaGuiga Jul 17, 2024
e1e1fca
Fix Clippy and cleanup
LindaGuiga Jul 23, 2024
b52acc2
Apply comments
LindaGuiga Jul 26, 2024
d7dfec4
Only write to TrieData if value nonzero
LindaGuiga Aug 1, 2024
6ffd490
Merge branch 'feat/continuations' into late_hash_continuations_storag…
LindaGuiga Aug 2, 2024
f2b29b2
Fix comments and name changed in merge
LindaGuiga Aug 2, 2024
d201a1f
Apply comments
LindaGuiga Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ global revert_storage_change:
DUP3 ISZERO %jumpi(delete)
// stack: address, slot, prev_value, retdest
%insert_slot_with_value
// stack: value_ptr
POP
JUMP

delete:
Expand Down
4 changes: 4 additions & 0 deletions evm_arithmetization/src/cpu/kernel/asm/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ global perform_final_checks:
PROVER_INPUT(trie_ptr::state)

%mstore_global_metadata(@GLOBAL_METADATA_STATE_TRIE_ROOT)

PROVER_INPUT(trie_ptr::trie_data_size)
%mstore_global_metadata(@GLOBAL_METADATA_TRIE_DATA_SIZE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this needs a comment saying that is not unsound to simply guess the size. I think it's because the values in the storage linked lists are already non det. advice, so it doesn't matter from where you are reading them.


%set_initial_tries
%get_trie_data_size
%mpt_hash_state_trie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ insert_next_slot:
DUP2
%increment
MLOAD_GENERAL
// key, addr, storage_ptr_ptr, root_ptr, retdest
// stack: key, addr, storage_ptr_ptr, root_ptr, retdest
DUP3
%add_const(2)
MLOAD_GENERAL
// stack: payload_ptr, key, addr, storage_ptr_ptr, root_ptr, retdest
// stack: value, key, addr, storage_ptr_ptr, root_ptr, retdest
// If the value is 0, then payload_ptr = 0, and we don't need to insert a value in the `TrieData` segment.
DUP1 ISZERO %jumpi(insert_with_payload_ptr)
%get_trie_data_size // payload_ptr
SWAP1 %append_to_trie_data // append the value to the trie data segment
insert_with_payload_ptr:
%stack (payload_ptr, key, addr, storage_ptr_ptr, root_ptr) -> (root_ptr, 64, key, payload_ptr, after_insert_slot, storage_ptr_ptr, addr)
%jump(mpt_insert)
after_insert_slot:
Expand Down Expand Up @@ -112,7 +117,7 @@ global delete_removed_accounts:
// stack: key, account_ptr_ptr, root_ptr, storage_ptr_ptr, retdest
DUP2
%add_const(2)
MLOAD_GENERAL // get intitial payload_ptr
MLOAD_GENERAL // get initial payload_ptr
%add_const(2) // storage_root_ptr_ptr = payload_ptr + 2
%mload_trie_data
// stack: storage_root_ptr, key, account_ptr_ptr, root_ptr, storage_ptr_ptr, retdest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ skip:
%macro set_initial_tries
PUSH %%after
PUSH @SEGMENT_STORAGE_LINKED_LIST
%add_const(8) // The first node is the special node, of size 5, so the first payload is at position 5 + 3.
%add_const(8) // The first node is the special node, of size 5, so the first value is at position 5 + 3.
PUSH @SEGMENT_ACCOUNTS_LINKED_LIST
%add_const(6) // The first node is the special node, of size 4, so the first payload is at position 4 + 2.
%mload_global_metadata(@GLOBAL_METADATA_STATE_TRIE_ROOT)
Expand Down Expand Up @@ -175,10 +175,19 @@ after_set_storage_payload:
set_payload_storage_leaf:
// stack: node_type, after_node_type, storage_ptr_ptr, retdest
POP
// stack: after_node_type, storage_ptr_ptr, retdest
// stack: after_node_type, storage_ptr_ptr, retdest
%add_const(2) // The value pointer starts at index 3, after num_nibbles and packed_nibbles.
DUP2
MLOAD_GENERAL
// stack: value_ptr_ptr, storage_ptr_ptr, retdest
DUP2 MLOAD_GENERAL
// stack: value, value_ptr_ptr, storage_ptr_ptr, retdest
// If value == 0, then value_ptr = 0, and we don't need to append the value to the `TrieData` segment.
DUP1 ISZERO %jumpi(set_payload_storage_leaf_end)
%get_trie_data_size
// stack: value_ptr, value, value_ptr_ptr, storage_ptr_ptr, retdest
SWAP1
%append_to_trie_data
set_payload_storage_leaf_end:
// stack: value_ptr, value_ptr_ptr, storage_ptr_ptr, retdest
SWAP1
%mstore_trie_data
// stack: storage_ptr_ptr, retdest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,20 @@ global store_initial_slots:

loop_store_initial_slots:
// stack: current_node_ptr, cur_len, retdest
%get_trie_data_size
DUP2
DUP1
MLOAD_GENERAL
// stack: current_addr_key, cpy_ptr, current_node_ptr, cur_len, retdest
// stack: current_addr_key, current_node_ptr, cur_len, retdest
%eq_const(@U256_MAX)
%jumpi(store_initial_slots_end)
DUP2
DUP1
%add_const(2)
MLOAD_GENERAL
// stack: payload_ptr, cpy_ptr, current_node_ptr, cur_len, retdest
%mload_trie_data
%append_to_trie_data
// stack: cpy_ptr, current_node_ptr, cur_len, retdest
// stack: value, current_node_ptr, cur_len, retdest
DUP2
%add_const(@STORAGE_COPY_PAYLOAD_PTR)
// stack: cpy_value_ptr, value, current_node_ptr, cur_len, retdest
SWAP1
MSTORE_GENERAL // Store cpy_ptr
MSTORE_GENERAL // Store cpy_value
// stack: current_node_ptr, cur_len, retdest
SWAP1 PUSH @STORAGE_LINKED_LISTS_NODE_SIZE
ADD
Expand All @@ -361,7 +358,7 @@ loop_store_initial_slots:
%jump(loop_store_initial_slots)

store_initial_slots_end:
%pop2
POP
// stack: cur_len, retdest
%mstore_global_metadata(@GLOBAL_METADATA_STORAGE_LINKED_LIST_NEXT_AVAILABLE)
JUMP
Expand All @@ -376,7 +373,6 @@ store_initial_slots_end:

%macro insert_slot_no_return
%insert_slot
POP
%endmacro

// Multiplies the value at the top of the stack, denoted by ptr/5, by 5
Expand All @@ -402,7 +398,6 @@ store_initial_slots_end:

/// Inserts the pair (address_key, storage_key) and a new payload pointer into the linked list if it is not already present,
/// or modifies its payload if it was already present.
/// Returns `new_payload_ptr` if the storage key was inserted, `original_ptr` if it was already present.
global insert_slot_with_value:
// stack: addr_key, key, value, retdest
PROVER_INPUT(linked_list::insert_slot)
Expand Down Expand Up @@ -505,43 +500,33 @@ next_node_ok_with_value:
DUP5
MSTORE_GENERAL
// stack: new_ptr + 1, next_ptr, addr_key, key, value, retdest
// Append the value to `TrieDataSegment` and write the resulting payload_ptr.
// Write the value in the linked list.
%increment
DUP1
%get_trie_data_size
// stack: new_payload_ptr, new_ptr+2, new_ptr+2, next_ptr, addr_key, key, value, retdest
%stack (new_payload_ptr, new_payload_ptr_ptr, new_payload_ptr_ptr, next_ptr, addr_key, key, value, retdest)
-> (value, new_payload_ptr, new_payload_ptr_ptr, new_payload_ptr_ptr, next_ptr, new_payload_ptr, retdest)
%append_to_trie_data
MSTORE_GENERAL

// stack: new_ptr + 2, next_ptr, new_payload_ptr, retdest
// Store the payload ptr copy
%increment
DUP1
DUP4
%clone_slot
MSTORE_GENERAL
// stack: new_ptr + 3, next_ptr, new_payload_ptr, retdest
DUP1 %increment
// stack: new_ptr+3, new_value_ptr, next_ptr, addr_key, key, value, retdest
%stack (new_cloned_value_ptr, new_value_ptr, next_ptr, addr_key, key, value, retdest)
-> (value, new_cloned_value_ptr, value, new_value_ptr, new_cloned_value_ptr, next_ptr, retdest)
MSTORE_GENERAL // Store copied value.
MSTORE_GENERAL // Store value.

// stack: new_ptr + 3, next_ptr, retdest
%increment
DUP1
// stack: new_next_ptr, new_next_ptr, next_ptr, new_payload_ptr, retdest
// stack: new_next_ptr_ptr, new_next_ptr_ptr, next_ptr, retdest
SWAP2
MSTORE_GENERAL
// stack: new_next_ptr, new_payload_ptr, retdest
// stack: new_next_ptr_ptr, retdest
%increment
%mstore_global_metadata(@GLOBAL_METADATA_STORAGE_LINKED_LIST_NEXT_AVAILABLE)
// stack: new_payload_ptr, retdest
SWAP1
// stack: retdest
JUMP

slot_found_write_value:
// stack: pred_ptr, addr_key, key, value, retdest
%add_const(2) MLOAD_GENERAL
%stack (payload_ptr, addr_key, key, value) -> (payload_ptr, value, payload_ptr)
%mstore_trie_data
// stack: payload_ptr, retdest
%stack (payload_ptr, retdest) -> (retdest, payload_ptr)
%add_const(2)
%stack (payload_ptr, addr_key, key, value) -> (value, payload_ptr)
MSTORE_GENERAL
// stack: retdest
JUMP

%macro insert_slot_with_value
Expand All @@ -552,7 +537,6 @@ slot_found_write_value:
%stack (slot_key, addr_key, value) -> (addr_key, slot_key, value, %%after)
%jump(insert_slot_with_value)
%%after:
// stack: value_ptr
%endmacro

/// Inserts the pair (address_key, storage_key) and payload pointer into the linked list if it is not already present,
Expand Down Expand Up @@ -758,8 +742,8 @@ slot_found_no_write:
// Load the the payload pointer and access counter
%add_const(2)
MLOAD_GENERAL
// stack: orig_payload_ptr, addr_key, key, payload_ptr, retdest
%stack (orig_payload_ptr, addr_key, key, payload_ptr, retdest) -> (retdest, orig_payload_ptr)
// stack: orig_value, addr_key, key, payload_ptr, retdest
%stack (orig_value, addr_key, key, payload_ptr, retdest) -> (retdest, orig_value)
JUMP


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,10 @@ sstore_after_refund:
// stack: slot, value, kexit_info
DUP2 ISZERO %jumpi(sstore_delete)

// First we write the value to MPT data, and get a pointer to it.
%get_trie_data_size
// stack: value_ptr, slot, value, kexit_info
SWAP2
// stack: value, slot, value_ptr, kexit_info
%append_to_trie_data
// stack: slot, value_ptr, kexit_info

%slot_to_storage_key
// stack: slot, value, kexit_info
%address
%addr_to_state_key
%insert_slot_no_return
%insert_slot_with_value

EXIT_KERNEL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@ sload_with_addr:

// Storage key not found. Return default value_ptr = 0,
// which derefs to 0 since @SEGMENT_TRIE_DATA[0] = 0.
%stack (value_ptr, retdest) -> (retdest, 0)
%stack (value, retdest) -> (retdest, 0)

JUMP

global storage_key_exists:
// stack: value_ptr, retdest
%mload_trie_data
// stack: value, retdest
SWAP1
JUMP
1 change: 1 addition & 0 deletions evm_arithmetization/src/cpu/kernel/tests/mpt/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ fn test_state_trie(
interpreter.generation_state.registers.program_counter = KERNEL.global_labels["store_initial"];
interpreter.run();

assert_eq!(interpreter.stack(), vec![]);
// Set initial tries.
interpreter
.push(0xDEADBEEFu32.into())
Expand Down
33 changes: 11 additions & 22 deletions evm_arithmetization/src/generation/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ associated storage trie hash"
empty_nibbles(),
storage_trie,
storage_leaves,
trie_data,
&parse_storage_value,
)?;

Expand All @@ -425,7 +424,6 @@ pub(crate) fn get_storage_leaves<F>(
key: Nibbles,
trie: &HashedPartialTrie,
storage_leaves: &mut Vec<Option<U256>>,
trie_data: &mut Vec<Option<U256>>,
parse_value: &F,
) -> Result<(), ProgramError>
where
Expand All @@ -439,29 +437,15 @@ where
count: 1,
packed: i.into(),
});
get_storage_leaves(
address,
extended_key,
child,
storage_leaves,
trie_data,
parse_value,
)?;
get_storage_leaves(address, extended_key, child, storage_leaves, parse_value)?;
}

Ok(())
}

Node::Extension { nibbles, child } => {
let extended_key = key.merge_nibbles(nibbles);
get_storage_leaves(
address,
extended_key,
child,
storage_leaves,
trie_data,
parse_value,
)?;
get_storage_leaves(address, extended_key, child, storage_leaves, parse_value)?;

Ok(())
}
Expand All @@ -481,15 +465,20 @@ where
.map_err(|_| ProgramError::IntegerTooLarge)?,
));
// Write `value_ptr_ptr`.
storage_leaves.push(Some((trie_data.len()).into()));
let leaves = parse_value(value)?
.into_iter()
.map(Some)
.collect::<Vec<_>>();
let leaf = match leaves.len() {
1 => leaves[0],
_ => panic!("Slot can only store exactly one value."),
};
storage_leaves.push(leaf);
// Write the counter.
storage_leaves.push(Some(0.into()));
// Set the next node as the initial node.
storage_leaves.push(Some((Segment::StorageLinkedList as usize).into()));

let leaf = parse_value(value)?.into_iter().map(Some);
trie_data.extend(leaf);

Ok(())
}
_ => Ok(()),
Expand Down
Loading