Skip to content

Commit

Permalink
refactor: get block number and timestamp from blockenv
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Aug 26, 2024
1 parent 6b86b5e commit 6bcb9f0
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
9 changes: 0 additions & 9 deletions crates/ethereum/payload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ where
.build();

let base_fee = initialized_block_env.basefee.to::<u64>();
let block_number = initialized_block_env.number.to::<u64>();
let block_gas_limit =
initialized_block_env.gas_limit.try_into().unwrap_or(chain_spec.max_gas_limit);

Expand All @@ -124,8 +123,6 @@ where
&chain_spec,
&initialized_cfg,
&initialized_block_env,
block_number,
attributes.timestamp,
attributes.parent_beacon_block_root,
)
.map_err(|err| {
Expand All @@ -144,8 +141,6 @@ where
&chain_spec,
&initialized_cfg,
&initialized_block_env,
block_number,
attributes.timestamp,
parent_block.hash(),
)
.map_err(|err| {
Expand Down Expand Up @@ -307,8 +302,6 @@ where
&chain_spec,
&initialized_cfg,
&initialized_block_env,
block_number,
attributes.timestamp,
attributes.parent_beacon_block_root,
)
.map_err(|err| {
Expand All @@ -327,8 +320,6 @@ where
&chain_spec,
&initialized_cfg,
&initialized_block_env,
block_number,
attributes.timestamp,
parent_block.hash(),
)
.map_err(|err| {
Expand Down
14 changes: 4 additions & 10 deletions crates/evm/src/system_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ use revm_primitives::{
///
/// This uses [`apply_blockhashes_contract_call`] to ultimately apply the blockhash contract state
/// change.
#[allow(clippy::too_many_arguments)]
pub fn pre_block_blockhashes_contract_call<EvmConfig, DB>(
db: &mut DB,
evm_config: &EvmConfig,
chain_spec: &ChainSpec,
initialized_cfg: &CfgEnvWithHandlerCfg,
initialized_block_env: &BlockEnv,
block_number: u64,
block_timestamp: u64,
parent_block_hash: B256,
) -> Result<(), BlockExecutionError>
where
Expand All @@ -60,8 +57,8 @@ where
apply_blockhashes_contract_call(
evm_config,
chain_spec,
block_timestamp,
block_number,
initialized_block_env.timestamp.to(),
initialized_block_env.number.to(),
parent_block_hash,
&mut evm_pre_block,
)
Expand Down Expand Up @@ -135,15 +132,12 @@ where
///
/// This uses [`apply_beacon_root_contract_call`] to ultimately apply the beacon root contract state
/// change.
#[allow(clippy::too_many_arguments)]
pub fn pre_block_beacon_root_contract_call<EvmConfig, DB>(
db: &mut DB,
evm_config: &EvmConfig,
chain_spec: &ChainSpec,
initialized_cfg: &CfgEnvWithHandlerCfg,
initialized_block_env: &BlockEnv,
block_number: u64,
block_timestamp: u64,
parent_beacon_block_root: Option<B256>,
) -> Result<(), BlockExecutionError>
where
Expand All @@ -165,8 +159,8 @@ where
apply_beacon_root_contract_call(
evm_config,
chain_spec,
block_timestamp,
block_number,
initialized_block_env.timestamp.to(),
initialized_block_env.number.to(),
parent_beacon_block_root,
&mut evm_pre_block,
)
Expand Down
5 changes: 0 additions & 5 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ where
.build();

let base_fee = initialized_block_env.basefee.to::<u64>();
let block_number = initialized_block_env.number.to::<u64>();
let block_gas_limit: u64 =
initialized_block_env.gas_limit.try_into().unwrap_or(chain_spec.max_gas_limit);

Expand All @@ -124,8 +123,6 @@ where
&chain_spec,
&initialized_cfg,
&initialized_block_env,
block_number,
attributes.payload_attributes.timestamp,
attributes.payload_attributes.parent_beacon_block_root,
)
.map_err(|err| {
Expand Down Expand Up @@ -289,8 +286,6 @@ where
&chain_spec,
&initialized_cfg,
&initialized_block_env,
block_number,
attributes.payload_attributes.timestamp,
attributes.payload_attributes.parent_beacon_block_root,
)
.map_err(|err| {
Expand Down
4 changes: 0 additions & 4 deletions crates/rpc/rpc-eth-api/src/helpers/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ pub trait LoadPendingBlock: EthApiTypes {
chain_spec.as_ref(),
&cfg,
&block_env,
block_number,
block_env.timestamp.to::<u64>(),
origin.header().parent_beacon_block_root,
)
.map_err(|err| EthApiError::Internal(err.into()))?;
Expand All @@ -268,8 +266,6 @@ pub trait LoadPendingBlock: EthApiTypes {
chain_spec.as_ref(),
&cfg,
&block_env,
block_number,
block_env.timestamp.to::<u64>(),
origin.header().hash(),
)
.map_err(|err| EthApiError::Internal(err.into()))?;
Expand Down
4 changes: 0 additions & 4 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,6 @@ where
&this.inner.provider.chain_spec(),
&cfg,
&block_env,
block.timestamp,
block.number,
block.parent_beacon_block_root,
)
.map_err(|err| EthApiError::Internal(err.into()))?;
Expand All @@ -604,8 +602,6 @@ where
&this.inner.provider.chain_spec(),
&cfg,
&block_env,
block.timestamp,
block.number,
block.parent_hash,
)
.map_err(|err| EthApiError::Internal(err.into()))?;
Expand Down

0 comments on commit 6bcb9f0

Please sign in to comment.