Skip to content

Commit

Permalink
use SystemCaller in rpc-eth-api pending block
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Sep 29, 2024
1 parent c063c44 commit 557521a
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions crates/rpc/rpc-eth-api/src/helpers/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
use std::time::{Duration, Instant};

use crate::{EthApiTypes, FromEthApiError, FromEvmError};

use alloy_primitives::{BlockNumber, B256, U256};
use alloy_rpc_types::BlockNumberOrTag;
use futures::Future;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_evm::{
system_calls::{pre_block_beacon_root_contract_call, pre_block_blockhashes_contract_call},
ConfigureEvm, ConfigureEvmEnv,
};
use reth_evm::{system_calls::SystemCaller, ConfigureEvm, ConfigureEvmEnv};
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{
constants::{eip4844::MAX_DATA_GAS_PER_BLOCK, BEACON_NONCE, EMPTY_ROOT_HASH},
Expand Down Expand Up @@ -262,31 +260,27 @@ pub trait LoadPendingBlock: EthApiTypes {

let chain_spec = self.provider().chain_spec();

let evm_config = self.evm_config().clone();
let mut system_caller = SystemCaller::new(&evm_config, chain_spec.clone());

let parent_beacon_block_root = if origin.is_actual_pending() {
// apply eip-4788 pre block contract call if we got the block from the CL with the real
// parent beacon block root
pre_block_beacon_root_contract_call(
&mut db,
self.evm_config(),
chain_spec.as_ref(),
&cfg,
&block_env,
origin.header().parent_beacon_block_root,
)
.map_err(|err| EthApiError::Internal(err.into()))?;
system_caller
.pre_block_beacon_root_contract_call(
&mut db,
&cfg,
&block_env,
origin.header().parent_beacon_block_root,
)
.map_err(|err| EthApiError::Internal(err.into()))?;
origin.header().parent_beacon_block_root
} else {
None
};
pre_block_blockhashes_contract_call(
&mut db,
self.evm_config(),
chain_spec.as_ref(),
&cfg,
&block_env,
origin.header().hash(),
)
.map_err(|err| EthApiError::Internal(err.into()))?;
system_caller
.pre_block_blockhashes_contract_call(&mut db, &cfg, &block_env, origin.header().hash())
.map_err(|err| EthApiError::Internal(err.into()))?;

let mut receipts = Vec::new();

Expand Down

0 comments on commit 557521a

Please sign in to comment.