chore: remove executed_block from EthBuiltPayload (#14017)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Dan Cline
2025-01-27 16:27:57 -05:00
committed by GitHub
parent e2c45f2b1f
commit ddc9375a60
9 changed files with 15 additions and 52 deletions

2
Cargo.lock generated
View File

@ -7363,7 +7363,6 @@ dependencies = [
"alloy-primitives",
"alloy-rlp",
"alloy-rpc-types-engine",
"reth-chain-state",
"reth-chainspec",
"reth-engine-primitives",
"reth-payload-primitives",
@ -7398,7 +7397,6 @@ dependencies = [
"alloy-eips",
"alloy-primitives",
"reth-basic-payload-builder",
"reth-chain-state",
"reth-chainspec",
"reth-errors",
"reth-evm",

View File

@ -126,6 +126,7 @@ impl TransactionTestContext {
}
/// Validates the sidecar of a given tx envelope and returns the versioned hashes
#[track_caller]
pub fn validate_sidecar(tx: TxEnvelope) -> Vec<B256> {
let proof_setting = EnvKzgSettings::Default;

View File

@ -18,7 +18,6 @@ reth-engine-primitives.workspace = true
reth-payload-primitives.workspace = true
reth-payload-validator.workspace = true
reth-rpc-types-compat.workspace = true
reth-chain-state.workspace = true
# alloy
alloy-primitives.workspace = true

View File

@ -9,7 +9,6 @@ use alloy_rpc_types_engine::{
ExecutionPayloadV1, PayloadAttributes, PayloadId,
};
use core::convert::Infallible;
use reth_chain_state::ExecutedBlockWithTrieUpdates;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::{EthPrimitives, SealedBlock};
use reth_rpc_types_compat::engine::payload::{
@ -27,8 +26,6 @@ pub struct EthBuiltPayload {
pub(crate) id: PayloadId,
/// The built block
pub(crate) block: Arc<SealedBlock>,
/// Block execution data for the payload, if any.
pub(crate) executed_block: Option<ExecutedBlockWithTrieUpdates>,
/// The fees of the block
pub(crate) fees: U256,
/// The blobs, proofs, and commitments in the block. If the block is pre-cancun, this will be
@ -48,10 +45,9 @@ impl EthBuiltPayload {
id: PayloadId,
block: Arc<SealedBlock>,
fees: U256,
executed_block: Option<ExecutedBlockWithTrieUpdates>,
requests: Option<Requests>,
) -> Self {
Self { id, block, executed_block, fees, sidecars: Vec::new(), requests }
Self { id, block, fees, sidecars: Vec::new(), requests }
}
/// Returns the identifier of the payload.
@ -100,10 +96,6 @@ impl BuiltPayload for EthBuiltPayload {
self.fees
}
fn executed_block(&self) -> Option<ExecutedBlockWithTrieUpdates> {
self.executed_block.clone()
}
fn requests(&self) -> Option<Requests> {
self.requests.clone()
}
@ -120,10 +112,6 @@ impl BuiltPayload for &EthBuiltPayload {
(**self).fees()
}
fn executed_block(&self) -> Option<ExecutedBlockWithTrieUpdates> {
self.executed_block.clone()
}
fn requests(&self) -> Option<Requests> {
self.requests.clone()
}

View File

@ -1,5 +1,4 @@
use crate::utils::eth_payload_attributes;
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
use alloy_genesis::Genesis;
use alloy_rpc_types_engine::PayloadStatusEnum;
use reth_chainspec::{ChainSpecBuilder, MAINNET};
@ -27,6 +26,7 @@ async fn can_handle_blobs() -> eyre::Result<()> {
.cancun_activated()
.build(),
);
let genesis_hash = chain_spec.genesis_hash();
let node_config = NodeConfig::test()
.with_chain(chain_spec)
.with_unused_ports()
@ -69,15 +69,12 @@ async fn can_handle_blobs() -> eyre::Result<()> {
let blob_block_hash =
node.engine_api.submit_payload(blob_payload, blob_attr, PayloadStatusEnum::Valid).await?;
let (_, _) = tokio::join!(
// send fcu with blob hash
node.engine_api.update_forkchoice(MAINNET_GENESIS_HASH, blob_block_hash),
// send fcu with normal hash
node.engine_api.update_forkchoice(MAINNET_GENESIS_HASH, payload.block().hash())
);
node.engine_api.update_forkchoice(genesis_hash, blob_block_hash).await?;
// submit normal payload
// submit normal payload (reorg)
let block_hash =
node.engine_api.submit_payload(payload, attributes, PayloadStatusEnum::Valid).await?;
node.engine_api.update_forkchoice(genesis_hash, block_hash).await?;
tokio::time::sleep(std::time::Duration::from_secs(3)).await;

View File

@ -26,7 +26,6 @@ reth-basic-payload-builder.workspace = true
reth-evm.workspace = true
reth-evm-ethereum.workspace = true
reth-errors.workspace = true
reth-chain-state.workspace = true
reth-chainspec.workspace = true
# ethereum

View File

@ -19,7 +19,6 @@ use reth_basic_payload_builder::{
commit_withdrawals, is_better_payload, BuildArguments, BuildOutcome, PayloadBuilder,
PayloadConfig,
};
use reth_chain_state::{ExecutedBlock, ExecutedBlockWithTrieUpdates};
use reth_chainspec::{ChainSpec, ChainSpecProvider};
use reth_errors::RethError;
use reth_evm::{
@ -31,8 +30,7 @@ use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes};
use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_primitives::{
Block, BlockBody, EthereumHardforks, InvalidTransactionError, Receipt, RecoveredBlock,
TransactionSigned,
Block, BlockBody, EthereumHardforks, InvalidTransactionError, Receipt, TransactionSigned,
};
use reth_primitives_traits::{
proofs::{self},
@ -192,7 +190,6 @@ where
let base_fee = evm_env.block_env.basefee.to::<u64>();
let mut executed_txs = Vec::new();
let mut executed_senders = Vec::new();
let mut best_txs = best_txs(BestTransactionsAttributes::new(
base_fee,
@ -340,8 +337,7 @@ where
tx.effective_tip_per_gas(base_fee).expect("fee is always valid; execution succeeded");
total_fees += U256::from(miner_fee) * U256::from(gas_used);
// append sender and transaction to the respective lists
executed_senders.push(tx.signer());
// append transaction to the block body
executed_txs.push(tx.into_tx());
}
@ -399,8 +395,8 @@ where
// calculate the state root
let hashed_state = db.database.db.hashed_post_state(execution_outcome.state());
let (state_root, trie_output) = {
db.database.inner().state_root_with_updates(hashed_state.clone()).inspect_err(|err| {
let (state_root, _) = {
db.database.inner().state_root_with_updates(hashed_state).inspect_err(|err| {
warn!(target: "payload_builder",
parent_hash=%parent_header.hash(),
%err,
@ -480,21 +476,7 @@ where
let sealed_block = Arc::new(block.seal_slow());
debug!(target: "payload_builder", id=%attributes.id, sealed_block_header = ?sealed_block.sealed_header(), "sealed built block");
// create the executed block data
let executed = ExecutedBlockWithTrieUpdates {
block: ExecutedBlock {
recovered_block: Arc::new(RecoveredBlock::new_sealed(
sealed_block.as_ref().clone(),
executed_senders,
)),
execution_output: Arc::new(execution_outcome),
hashed_state: Arc::new(hashed_state),
},
trie: Arc::new(trie_output),
};
let mut payload =
EthBuiltPayload::new(attributes.id, sealed_block, total_fees, Some(executed), requests);
let mut payload = EthBuiltPayload::new(attributes.id, sealed_block, total_fees, requests);
// extend the payload with the blob sidecars from the executed txs
payload.extend_sidecars(blob_sidecars.into_iter().map(Arc::unwrap_or_clone));

View File

@ -67,7 +67,7 @@
//! },
//! ..Default::default()
//! };
//! let payload = EthBuiltPayload::new(self.attributes.id, Arc::new(SealedBlock::seal_slow(block)), U256::ZERO, None, None);
//! let payload = EthBuiltPayload::new(self.attributes.id, Arc::new(SealedBlock::seal_slow(block)), U256::ZERO, None);
//! Ok(payload)
//! }
//!

View File

@ -6,7 +6,7 @@ use crate::{
};
use alloy_primitives::U256;
use reth_chain_state::{CanonStateNotification, ExecutedBlockWithTrieUpdates};
use reth_chain_state::CanonStateNotification;
use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::{PayloadKind, PayloadTypes};
use reth_primitives::Block;
@ -90,7 +90,6 @@ impl PayloadJob for TestPayloadJob {
self.attr.payload_id(),
Arc::new(Block::default().seal_slow()),
U256::ZERO,
Some(ExecutedBlockWithTrieUpdates::default()),
Some(Default::default()),
))
}