Skip to content

Commit

Permalink
Cherry pick what's left of Linked lists for the state trie (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Aug 9, 2024
1 parent fd0f7d5 commit 5455720
Show file tree
Hide file tree
Showing 36 changed files with 960 additions and 302 deletions.
130 changes: 130 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ axum = "0.7.5"
bitflags = "2.5.0"
bitvec = "1.0.1"
bytes = "1.6.0"
cargo_metadata = "0.18.1"
ciborium = "0.2.2"
ciborium-io = "0.2.2"
clap = { version = "4.5.7", features = ["derive", "env"] }
Expand Down Expand Up @@ -105,6 +106,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
u4 = "0.1.0"
uint = "0.9.5"
url = "2.5.2"
vergen = { version = "9.0.0", features = ["build", "rustc"] }
winnow = "0.6.13"

# local dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,4 @@ global remove_accessed_storage_keys:
// stack: next_next_ptr, next_ptr_ptr, addr, key, retdest
MSTORE_GENERAL
%pop2
JUMP
JUMP
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ revert_account_destroyed_contd:
// stack: address, prev_balance, retdest
%read_accounts_linked_list
// stack: account_payload_ptr, prev_balance, retdest
DUP1 %assert_nonzero
DUP1
%assert_nonzero
%increment
// stack: account_balance_payload_ptr, prev_balance, retdest
%mstore_trie_data
JUMP

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ global revert_nonce_change:
%mstore_trie_data
// stack: retdest
JUMP

9 changes: 2 additions & 7 deletions evm_arithmetization/src/cpu/kernel/asm/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,12 @@ global main:
// Encode constant nodes
%initialize_rlp_segment

// Initialize linked list and trie data constants.
// TODO: Validate them.
PROVER_INPUT(linked_list::accounts_linked_list_len)
%mstore_global_metadata(@GLOBAL_METADATA_ACCOUNTS_LINKED_LIST_LEN)
PROVER_INPUT(linked_list::storage_linked_list_len)
%mstore_global_metadata(@GLOBAL_METADATA_STORAGE_LINKED_LIST_LEN)
// Initialize trie data size.
PROVER_INPUT(trie_ptr::trie_data_size)
%mstore_global_metadata(@GLOBAL_METADATA_TRIE_DATA_SIZE)

global store_initial:
// Store the inital accounts and slots for hashing later
// Store the initial accounts and slots for hashing later
%store_initial_accounts
%store_initial_slots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ global delete_account:
%jump(delete_account)
%%after:
// stack: (empty)
%endmacro
%endmacro
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,3 @@ global encode_storage_value:
// stack: rlp_addr', cur_len, retdest
%stack (rlp_addr, cur_len, retdest) -> (retdest, rlp_addr, cur_len)
JUMP

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ after_insert_slot:
%jump(insert_all_slots)

// Delete all the accounts, referenced by the respective nodes in the linked list starting at
// `account_ptr_ptr`, which where deleted from the intial state. Delete also all slots of non-deleted accounts
// `account_ptr_ptr`, which where deleted from the initial state. Delete also all slots of non-deleted accounts
// deleted from the storage trie.
// Pre stack: account_ptr_ptr, root_ptr, storage_ptr_ptr, retdest
// Post stack: new_root_ptr.
Expand All @@ -100,7 +100,7 @@ global delete_removed_accounts:
// We assume that the size of the initial accounts linked list, containing the accounts
// of the initial state, was stored at `@GLOBAL_METADATA_INITIAL_ACCOUNTS_LINKED_LIST_LEN`.
%mload_global_metadata(@GLOBAL_METADATA_INITIAL_ACCOUNTS_LINKED_LIST_LEN)
// The inital accounts linked list was stored at addresses smaller than `@GLOBAL_METADATA_INITIAL_ACCOUNTS_LINKED_LIST_LEN`.
// The initial accounts linked list was stored at addresses smaller than `@GLOBAL_METADATA_INITIAL_ACCOUNTS_LINKED_LIST_LEN`.
// If we also know that `@SEGMENT_ACCOUNT_LINKED_LIST <= account_ptr_ptr`, for deleting node at `addr_ptr_ptr` it
// suffices to check that `account_ptr_ptr` != `@GLOBAL_METADATA_INITIAL_ACCOUNTS_LINKED_LIST_LEN`
EQ
Expand Down
Loading

0 comments on commit 5455720

Please sign in to comment.