Skip to content

Commit

Permalink
Remove unnecessary global metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
hratoanina committed Aug 27, 2024
1 parent 32a6ba7 commit e3c41e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
2 changes: 0 additions & 2 deletions evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ global init_access_lists:

// Reset access lists data.
PUSH 0 %mstore_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_DATA_COST)
PUSH 0 %mstore_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_RLP_LEN)
PUSH 0 %mstore_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_RLP_START)
// Store @U256_MAX at the beginning of the segment
PUSH @SEGMENT_ACCESSED_ADDRESSES // ctx == virt == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,8 @@

%macro decode_and_store_access_list
// stack: rlp_addr
DUP1 %mstore_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_RLP_START)
%decode_rlp_list_len
%stack (rlp_addr, len) -> (len, len, rlp_addr, %%after)
%jumpi(decode_and_store_access_list)
// stack: len, rlp_addr, %%after
POP SWAP1 POP
// stack: rlp_addr
%mload_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_RLP_START) DUP2 SUB %mstore_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_RLP_LEN)
%stack (rlp_addr) -> (rlp_addr, %%after)
%jump(decode_and_store_access_list)
%%after:
%endmacro

Expand All @@ -143,7 +137,6 @@

%macro decode_and_store_blob_versioned_hashes
// stack: rlp_addr
DUP1 %mstore_global_metadata(@GLOBAL_METADATA_BLOB_VERSIONED_HASHES_RLP_START)
%decode_rlp_list_len
%stack (rlp_addr, len) -> (len, len, rlp_addr, %%after)

Expand All @@ -164,8 +157,6 @@ global decode_and_store_blob_versioned_hashes:
// stack: len, rlp_addr
DUP2 ADD
// stack: end_rlp_addr, rlp_addr
// Store the RLP length.
%mload_global_metadata(@GLOBAL_METADATA_BLOB_VERSIONED_HASHES_RLP_START) DUP2 SUB %mstore_global_metadata(@GLOBAL_METADATA_BLOB_VERSIONED_HASHES_RLP_LEN)
// stack: end_rlp_addr, rlp_addr
PUSH @SEGMENT_TXN_BLOB_VERSIONED_HASHES // initial address to write to
SWAP2
Expand Down Expand Up @@ -231,11 +222,13 @@ decode_and_store_blob_versioned_hashes_finish:

// The access list is of the form `[[{20 bytes}, [{32 bytes}...]]...]`.
global decode_and_store_access_list:
// stack: rlp_addr
%decode_rlp_list_len
// stack: rlp_addr, len
SWAP1
// stack: len, rlp_addr
DUP2 ADD
// stack: end_rlp_addr, rlp_addr
// Store the RLP length.
%mload_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_RLP_START) DUP2 SUB %mstore_global_metadata(@GLOBAL_METADATA_ACCESS_LIST_RLP_LEN)
SWAP1
decode_and_store_access_list_loop:
// stack: rlp_addr, end_rlp_addr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ store_origin:
PUSH @SEGMENT_TXN_BLOB_VERSIONED_HASHES // ctx 0
%memset
// Reset the global metadata
PUSH 0 %mstore_global_metadata(@GLOBAL_METADATA_BLOB_VERSIONED_HASHES_RLP_LEN)
PUSH 0 %mstore_global_metadata(@GLOBAL_METADATA_BLOB_VERSIONED_HASHES_LEN)
// stack: (empty)
%endmacro
18 changes: 1 addition & 17 deletions evm_arithmetization/src/cpu/kernel/constants/global_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ pub(crate) enum GlobalMetadata {
TouchedAddressesLen,
// Gas cost for the access list in type-1 txns. See EIP-2930.
AccessListDataCost,
// Start of the access list in the RLP for type-1 txns.
AccessListRlpStart,
// Length of the access list in the RLP for type-1 txns.
AccessListRlpLen,
// Boolean flag indicating if the txn is a contract creation txn.
ContractCreation,
IsPrecompileFromEoa,
Expand Down Expand Up @@ -118,16 +114,12 @@ pub(crate) enum GlobalMetadata {
/// The length of the transient storage segment.
TransientStorageLen,

// Start of the blob versioned hashes in the RLP for type-3 txns.
BlobVersionedHashesRlpStart,
// Length of the blob versioned hashes in the RLP for type-3 txns.
BlobVersionedHashesRlpLen,
// Number of blob versioned hashes contained in the current type-3 transaction.
BlobVersionedHashesLen,
}

impl GlobalMetadata {
pub(crate) const COUNT: usize = 59;
pub(crate) const COUNT: usize = 55;

/// Unscales this virtual offset by their respective `Segment` value.
pub(crate) const fn unscale(&self) -> usize {
Expand Down Expand Up @@ -173,8 +165,6 @@ impl GlobalMetadata {
Self::CurrentCheckpoint,
Self::TouchedAddressesLen,
Self::AccessListDataCost,
Self::AccessListRlpStart,
Self::AccessListRlpLen,
Self::ContractCreation,
Self::IsPrecompileFromEoa,
Self::CallStackDepth,
Expand All @@ -192,8 +182,6 @@ impl GlobalMetadata {
Self::InitialAccountsLinkedListLen,
Self::InitialStorageLinkedListLen,
Self::TransientStorageLen,
Self::BlobVersionedHashesRlpStart,
Self::BlobVersionedHashesRlpLen,
Self::BlobVersionedHashesLen,
]
}
Expand Down Expand Up @@ -239,8 +227,6 @@ impl GlobalMetadata {
Self::CurrentCheckpoint => "GLOBAL_METADATA_CURRENT_CHECKPOINT",
Self::TouchedAddressesLen => "GLOBAL_METADATA_TOUCHED_ADDRESSES_LEN",
Self::AccessListDataCost => "GLOBAL_METADATA_ACCESS_LIST_DATA_COST",
Self::AccessListRlpStart => "GLOBAL_METADATA_ACCESS_LIST_RLP_START",
Self::AccessListRlpLen => "GLOBAL_METADATA_ACCESS_LIST_RLP_LEN",
Self::ContractCreation => "GLOBAL_METADATA_CONTRACT_CREATION",
Self::IsPrecompileFromEoa => "GLOBAL_METADATA_IS_PRECOMPILE_FROM_EOA",
Self::CallStackDepth => "GLOBAL_METADATA_CALL_STACK_DEPTH",
Expand All @@ -263,8 +249,6 @@ impl GlobalMetadata {
}
Self::InitialStorageLinkedListLen => "GLOBAL_METADATA_INITIAL_STORAGE_LINKED_LIST_LEN",
Self::TransientStorageLen => "GLOBAL_METADATA_TRANSIENT_STORAGE_LEN",
Self::BlobVersionedHashesRlpStart => "GLOBAL_METADATA_BLOB_VERSIONED_HASHES_RLP_START",
Self::BlobVersionedHashesRlpLen => "GLOBAL_METADATA_BLOB_VERSIONED_HASHES_RLP_LEN",
Self::BlobVersionedHashesLen => "GLOBAL_METADATA_BLOB_VERSIONED_HASHES_LEN",
}
}
Expand Down

0 comments on commit e3c41e2

Please sign in to comment.