Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(op): simplify blob fields in newly built block header #12035

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions crates/optimism/payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true
op-alloy-rpc-types-engine.workspace = true
revm-primitives.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-consensus.workspace = true

Expand All @@ -56,5 +55,4 @@ optimism = [
"revm/optimism",
"reth-execution-types/optimism",
"reth-optimism-consensus/optimism",
"revm-primitives/optimism"
]
36 changes: 11 additions & 25 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use alloy_eips::merge::BEACON_NONCE;
use alloy_primitives::U256;
use reth_basic_payload_builder::*;
use reth_chain_state::ExecutedBlock;
use reth_chainspec::{ChainSpecProvider, EthereumHardforks};
use reth_chainspec::ChainSpecProvider;
use reth_evm::{system_calls::SystemCaller, ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
use reth_execution_types::ExecutionOutcome;
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_consensus::calculate_receipt_root_no_memo_optimism;
use reth_optimism_forks::OptimismHardfork;
use reth_optimism_forks::{OptimismHardfork, OptimismHardforks};
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError};
use reth_primitives::{
proofs,
Expand All @@ -30,7 +30,6 @@ use revm::{
primitives::{EVMError, EnvWithHandlerCfg, InvalidTransaction, ResultAndState},
DatabaseCommit,
};
use revm_primitives::calc_excess_blob_gas;
use tracing::{debug, trace, warn};

use crate::{
Expand Down Expand Up @@ -460,26 +459,16 @@ where
// create the block header
let transactions_root = proofs::calculate_transaction_root(&executed_txs);

// initialize empty blob sidecars. There are no blob transactions on L2.
let blob_sidecars = Vec::new();
let mut excess_blob_gas = None;
let mut blob_gas_used = None;

// only determine cancun fields when active
if chain_spec.is_cancun_active_at_timestamp(attributes.payload_attributes.timestamp) {
excess_blob_gas = if chain_spec.is_cancun_active_at_timestamp(parent_block.timestamp) {
let parent_excess_blob_gas = parent_block.excess_blob_gas.unwrap_or_default();
let parent_blob_gas_used = parent_block.blob_gas_used.unwrap_or_default();
Some(calc_excess_blob_gas(parent_excess_blob_gas, parent_blob_gas_used))
// OP doesn't support blobs/EIP-4844.
// https://specs.optimism.io/protocol/exec-engine.html#ecotone-disable-blob-transactions
// Need [Some] or [None] based on hardfork to match block hash.
let (excess_blob_gas, blob_gas_used) =
if chain_spec.is_ecotone_active_at_timestamp(attributes.payload_attributes.timestamp) {
(Some(0), Some(0))
} else {
// for the first post-fork block, both parent.blob_gas_used and
// parent.excess_blob_gas are evaluated as 0
Some(calc_excess_blob_gas(0, 0))
(None, None)
};

blob_gas_used = Some(0);
}

let header = Header {
parent_hash: parent_block.hash(),
ommers_hash: EMPTY_OMMER_ROOT_HASH,
Expand All @@ -500,7 +489,7 @@ where
extra_data,
parent_beacon_block_root: attributes.payload_attributes.parent_beacon_block_root,
blob_gas_used,
excess_blob_gas: excess_blob_gas.map(Into::into),
excess_blob_gas,
requests_hash: None,
};

Expand All @@ -524,7 +513,7 @@ where

let no_tx_pool = attributes.no_tx_pool;

let mut payload = OptimismBuiltPayload::new(
let payload = OptimismBuiltPayload::new(
attributes.payload_attributes.id,
sealed_block,
total_fees,
Expand All @@ -533,9 +522,6 @@ where
Some(executed),
);

// extend the payload with the blob sidecars from the executed txs
payload.extend_sidecars(blob_sidecars);

if no_tx_pool {
// if `no_tx_pool` is set only transactions from the payload attributes will be included in
// the payload. In other words, the payload is deterministic and we can freeze it once we've
Expand Down
Loading