mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: disable state root calculation for eth_simulateV1 (#12993)
This commit is contained in:
@ -201,7 +201,6 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock {
|
||||
parent_hash,
|
||||
total_difficulty,
|
||||
return_full_transactions,
|
||||
&db,
|
||||
this.tx_resp_builder(),
|
||||
)?;
|
||||
|
||||
|
||||
@ -12,16 +12,12 @@ use reth_primitives::{
|
||||
proofs::{calculate_receipt_root, calculate_transaction_root},
|
||||
BlockBody, BlockWithSenders, Receipt, TransactionSigned,
|
||||
};
|
||||
use reth_revm::database::StateProviderDatabase;
|
||||
use reth_rpc_server_types::result::rpc_err;
|
||||
use reth_rpc_types_compat::{block::from_block, TransactionCompat};
|
||||
use reth_storage_api::StateRootProvider;
|
||||
use reth_trie::{HashedPostState, HashedStorage};
|
||||
use revm::{db::CacheDB, Database};
|
||||
use revm_primitives::{keccak256, Address, BlockEnv, Bytes, ExecutionResult, TxKind, B256, U256};
|
||||
use revm::Database;
|
||||
use revm_primitives::{Address, BlockEnv, Bytes, ExecutionResult, TxKind, B256, U256};
|
||||
|
||||
use crate::{
|
||||
cache::db::StateProviderTraitObjWrapper,
|
||||
error::{api::FromEthApiError, ToRpcError},
|
||||
EthApiError, RevertError, RpcInvalidTransactionError,
|
||||
};
|
||||
@ -143,7 +139,6 @@ where
|
||||
}
|
||||
|
||||
/// Handles outputs of the calls execution and builds a [`SimulatedBlock`].
|
||||
#[expect(clippy::complexity)]
|
||||
pub fn build_block<T: TransactionCompat<Error: FromEthApiError>>(
|
||||
results: Vec<(Address, ExecutionResult)>,
|
||||
transactions: Vec<TransactionSigned>,
|
||||
@ -151,7 +146,6 @@ pub fn build_block<T: TransactionCompat<Error: FromEthApiError>>(
|
||||
parent_hash: B256,
|
||||
total_difficulty: U256,
|
||||
full_transactions: bool,
|
||||
db: &CacheDB<StateProviderDatabase<StateProviderTraitObjWrapper<'_>>>,
|
||||
tx_resp_builder: &T,
|
||||
) -> Result<SimulatedBlock<Block<T::Transaction>>, T::Error> {
|
||||
let mut calls: Vec<SimCallResult> = Vec::with_capacity(results.len());
|
||||
@ -229,24 +223,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()));
|
||||
// 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()));
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// 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 = 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,
|
||||
|
||||
Reference in New Issue
Block a user