mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(op): simplify blob fields in newly built block header (#12035)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8279,7 +8279,6 @@ dependencies = [
|
||||
"reth-transaction-pool",
|
||||
"reth-trie",
|
||||
"revm",
|
||||
"revm-primitives",
|
||||
"sha2 0.10.8",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
|
||||
@ -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
|
||||
|
||||
@ -56,5 +55,4 @@ optimism = [
|
||||
"revm/optimism",
|
||||
"reth-execution-types/optimism",
|
||||
"reth-optimism-consensus/optimism",
|
||||
"revm-primitives/optimism"
|
||||
]
|
||||
|
||||
@ -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,
|
||||
@ -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::{
|
||||
@ -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,
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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,
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user