Skip to content

Commit

Permalink
fix: disable state root calculations for eth_simulateV1
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Nov 28, 2024
1 parent 793fc23 commit 9db8dc5
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions crates/rpc/rpc-eth-types/src/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,24 +229,27 @@ pub fn build_block<T: TransactionCompat<Error: FromEthApiError>>(
calls.push(call);
}

let mut hashed_state = HashedPostState::default();
for (address, account) in &db.accounts {
let hashed_address = keccak256(address);
hashed_state.accounts.insert(hashed_address, Some(account.info.clone().into()));

let storage = hashed_state
.storages
.entry(hashed_address)
.or_insert_with(|| HashedStorage::new(account.account_state.is_storage_cleared()));

for (slot, value) in &account.storage {
let slot = B256::from(*slot);
let hashed_slot = keccak256(slot);
storage.storage.insert(hashed_slot, *value);
}
}

let state_root = db.db.state_root(hashed_state).map_err(T::Error::from_eth_err)?;
// TODO: uncomment once performance cost is acceptable
//
// let mut hashed_state = HashedPostState::default();
// for (address, account) in &db.accounts {
// let hashed_address = keccak256(address);
// hashed_state.accounts.insert(hashed_address, Some(account.info.clone().into()));

// let storage = hashed_state
// .storages
// .entry(hashed_address)
// .or_insert_with(|| HashedStorage::new(account.account_state.is_storage_cleared()));

// for (slot, value) in &account.storage {
// let slot = B256::from(*slot);
// let hashed_slot = keccak256(slot);
// storage.storage.insert(hashed_slot, *value);
// }
// }

// let state_root = db.db.state_root(hashed_state).map_err(T::Error::from_eth_err)?;
let state_root = B256::ZERO;

let header = alloy_consensus::Header {
beneficiary: block_env.coinbase,
Expand Down

0 comments on commit 9db8dc5

Please sign in to comment.