reth_optimism_evm/
config.rs

1pub use alloy_op_evm::{
2    spec as revm_spec, spec_by_timestamp_after_bedrock as revm_spec_by_timestamp_after_bedrock,
3};
4use op_alloy_rpc_types_engine::OpFlashblockPayloadBase;
5use revm::primitives::{Address, Bytes, B256};
6
7/// Context relevant for execution of a next block w.r.t OP.
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct OpNextBlockEnvAttributes {
10    /// The timestamp of the next block.
11    pub timestamp: u64,
12    /// The suggested fee recipient for the next block.
13    pub suggested_fee_recipient: Address,
14    /// The randomness value for the next block.
15    pub prev_randao: B256,
16    /// Block gas limit.
17    pub gas_limit: u64,
18    /// The parent beacon block root.
19    pub parent_beacon_block_root: Option<B256>,
20    /// Encoded EIP-1559 parameters to include into block's `extra_data` field.
21    pub extra_data: Bytes,
22}
23
24#[cfg(feature = "rpc")]
25impl<H: alloy_consensus::BlockHeader> reth_rpc_eth_api::helpers::pending_block::BuildPendingEnv<H>
26    for OpNextBlockEnvAttributes
27{
28    fn build_pending_env(parent: &crate::SealedHeader<H>) -> Self {
29        Self {
30            timestamp: parent.timestamp().saturating_add(12),
31            suggested_fee_recipient: parent.beneficiary(),
32            prev_randao: B256::random(),
33            gas_limit: parent.gas_limit(),
34            parent_beacon_block_root: parent.parent_beacon_block_root(),
35            extra_data: parent.extra_data().clone(),
36        }
37    }
38}
39
40impl From<OpFlashblockPayloadBase> for OpNextBlockEnvAttributes {
41    fn from(base: OpFlashblockPayloadBase) -> Self {
42        Self {
43            timestamp: base.timestamp,
44            suggested_fee_recipient: base.fee_recipient,
45            prev_randao: base.prev_randao,
46            gas_limit: base.gas_limit,
47            parent_beacon_block_root: Some(base.parent_beacon_block_root),
48            extra_data: base.extra_data,
49        }
50    }
51}