Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Sep 17, 2024
1 parent 5305504 commit 0375163
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions trace_decoder/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ fn middle<StateTrieT: StateTrie + Clone>(
|| (cfg!(feature = "polygon_pos")
// Include P256Verify for Polygon PoS
&& addr.compat()
== address!("0000000000000000000000000000000000000001"))
== address!("0000000000000000000000000000000000000100"))
}

if !is_precompile(addr) {
Expand Down Expand Up @@ -609,7 +609,7 @@ fn do_scalable_hook<StateTrieT: StateTrie + Clone>(
.context("missing scalable contract storage trie")?;
let scalable_trim = trim_storage.entry(ADDRESS_SCALABLE_L2).or_default();

let timestamp_slot_key = TrieKey::from_marker_slot(U256::from(TIMESTAMP_STORAGE_POS.1));
let timestamp_slot_key = TrieKey::from_slot_position(U256::from(TIMESTAMP_STORAGE_POS.1));

let timestamp = scalable_storage
.get(&timestamp_slot_key)
Expand All @@ -623,7 +623,7 @@ fn do_scalable_hook<StateTrieT: StateTrie + Clone>(
(U256::from(LAST_BLOCK_STORAGE_POS.1), block.block_number),
(U256::from(TIMESTAMP_STORAGE_POS.1), timestamp),
] {
let slot = TrieKey::from_marker_slot(ix);
let slot = TrieKey::from_slot_position(ix);
scalable_trim.insert(slot);

// These values are never 0.
Expand All @@ -637,7 +637,7 @@ fn do_scalable_hook<StateTrieT: StateTrie + Clone>(
let mut arr = [0; 64];
(block.block_number - 1).to_big_endian(&mut arr[0..32]);
U256::from(STATE_ROOT_STORAGE_POS.1).to_big_endian(&mut arr[32..64]);
let slot = TrieKey::from_hash(keccak_hash::keccak(&arr));
let slot = TrieKey::from_hash(keccak_hash::keccak(arr));

scalable_storage.insert(slot, alloy::rlp::encode(prev_block_root_hash.compat()))?;
scalable_trim.insert(slot);
Expand All @@ -663,7 +663,7 @@ fn do_scalable_hook<StateTrieT: StateTrie + Clone>(
let mut arr = [0; 64];
arr[0..32].copy_from_slice(&root.0);
U256::from(GLOBAL_EXIT_ROOT_STORAGE_POS.1).to_big_endian(&mut arr[32..64]);
let slot = TrieKey::from_hash(keccak_hash::keccak(&arr));
let slot = TrieKey::from_hash(keccak_hash::keccak(arr));

ger_storage.insert(slot, alloy::rlp::encode(l1blockhash.compat()))?;
ger_trim.insert(slot);
Expand Down Expand Up @@ -717,7 +717,7 @@ fn do_beacon_hook<StateTrieT: StateTrie + Clone>(
U256::from_big_endian(parent_beacon_block_root.as_bytes()),
),
] {
let slot = TrieKey::from_marker_slot(ix);
let slot = TrieKey::from_slot_position(ix);
beacon_trim.insert(slot);

match u.is_zero() {
Expand Down
4 changes: 2 additions & 2 deletions trace_decoder/src/typed_mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ impl TrieKey {
pub fn from_address(address: Address) -> Self {
Self::from_hash(keccak_hash::keccak(address))
}
pub fn from_marker_slot(slot: U256) -> Self {
pub fn from_slot_position(pos: U256) -> Self {
let mut bytes = [0; 32];
slot.to_big_endian(&mut bytes);
pos.to_big_endian(&mut bytes);
Self::from_hash(keccak_hash::keccak(bytes))
}
pub fn from_hash(H256(bytes): H256) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions zero/src/rpc/native/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn insert_beacon_roots_update(
) -> anyhow::Result<()> {
use alloy::primitives::U256;
use evm_arithmetization::testing_utils::{
BEACON_ROOTS_CONTRACT_STATE_KEY, HISTORY_BUFFER_LENGTH,
BEACON_ROOTS_CONTRACT_ADDRESS, HISTORY_BUFFER_LENGTH,
};

let timestamp = U256::from(block.header.timestamp);
Expand All @@ -107,7 +107,7 @@ fn insert_beacon_roots_update(
(timestamp % chunk).into(), // timestamp_idx
((timestamp % chunk) + chunk).into(), // root_idx
]);
state_access.insert(BEACON_ROOTS_CONTRACT_STATE_KEY.1.into(), keys);
state_access.insert(BEACON_ROOTS_CONTRACT_ADDRESS.0.into(), keys);

Ok(())
}
Expand Down

0 comments on commit 0375163

Please sign in to comment.