use super::{HlEthApi, HlRpcNodeCore}; use crate::{node::evm::apply_precompiles, HlBlock}; use alloy_evm::Evm; use alloy_primitives::B256; use reth::rpc::server_types::eth::EthApiError; use reth_evm::{ConfigureEvm, Database, EvmEnvFor, TxEnvFor}; use reth_primitives::{NodePrimitives, Recovered}; use reth_primitives_traits::SignedTransaction; use reth_provider::{ProviderError, ProviderTx}; use reth_rpc_eth_api::{ helpers::{estimate::EstimateCall, Call, EthCall}, FromEvmError, RpcConvert, RpcNodeCore, }; use revm::DatabaseCommit; impl HlRpcNodeCore for N where N: RpcNodeCore> {} impl EthCall for HlEthApi where N: HlRpcNodeCore, EthApiError: FromEvmError, Rpc: RpcConvert>, { } impl EstimateCall for HlEthApi where N: HlRpcNodeCore, EthApiError: FromEvmError, Rpc: RpcConvert>, { } impl Call for HlEthApi where N: HlRpcNodeCore, EthApiError: FromEvmError, Rpc: RpcConvert>, { #[inline] fn call_gas_limit(&self) -> u64 { self.inner.eth_api.gas_cap() } #[inline] fn max_simulate_blocks(&self) -> u64 { self.inner.eth_api.max_simulate_blocks() } fn replay_transactions_until<'a, DB, I>( &self, db: &mut DB, evm_env: EvmEnvFor, transactions: I, target_tx_hash: B256, ) -> Result where DB: Database + DatabaseCommit + core::fmt::Debug, I: IntoIterator>>, { let block_number = evm_env.block_env().number; let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?; let mut evm = self.evm_config().evm_with_env(db, evm_env); apply_precompiles(&mut evm, &hl_extras); let mut index = 0; for tx in transactions { if *tx.tx_hash() == target_tx_hash { // reached the target transaction break; } let tx_env = self.evm_config().tx_env(tx); evm.transact_commit(tx_env).map_err(Self::Error::from_evm_err)?; index += 1; } Ok(index) } }