mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: remove executed_block from EthBuiltPayload (#14017)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -7363,7 +7363,6 @@ dependencies = [
|
|||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rlp",
|
"alloy-rlp",
|
||||||
"alloy-rpc-types-engine",
|
"alloy-rpc-types-engine",
|
||||||
"reth-chain-state",
|
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-engine-primitives",
|
"reth-engine-primitives",
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
@ -7398,7 +7397,6 @@ dependencies = [
|
|||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"reth-basic-payload-builder",
|
"reth-basic-payload-builder",
|
||||||
"reth-chain-state",
|
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-errors",
|
"reth-errors",
|
||||||
"reth-evm",
|
"reth-evm",
|
||||||
|
|||||||
@ -126,6 +126,7 @@ impl TransactionTestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Validates the sidecar of a given tx envelope and returns the versioned hashes
|
/// Validates the sidecar of a given tx envelope and returns the versioned hashes
|
||||||
|
#[track_caller]
|
||||||
pub fn validate_sidecar(tx: TxEnvelope) -> Vec<B256> {
|
pub fn validate_sidecar(tx: TxEnvelope) -> Vec<B256> {
|
||||||
let proof_setting = EnvKzgSettings::Default;
|
let proof_setting = EnvKzgSettings::Default;
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@ reth-engine-primitives.workspace = true
|
|||||||
reth-payload-primitives.workspace = true
|
reth-payload-primitives.workspace = true
|
||||||
reth-payload-validator.workspace = true
|
reth-payload-validator.workspace = true
|
||||||
reth-rpc-types-compat.workspace = true
|
reth-rpc-types-compat.workspace = true
|
||||||
reth-chain-state.workspace = true
|
|
||||||
|
|
||||||
# alloy
|
# alloy
|
||||||
alloy-primitives.workspace = true
|
alloy-primitives.workspace = true
|
||||||
|
|||||||
@ -9,7 +9,6 @@ use alloy_rpc_types_engine::{
|
|||||||
ExecutionPayloadV1, PayloadAttributes, PayloadId,
|
ExecutionPayloadV1, PayloadAttributes, PayloadId,
|
||||||
};
|
};
|
||||||
use core::convert::Infallible;
|
use core::convert::Infallible;
|
||||||
use reth_chain_state::ExecutedBlockWithTrieUpdates;
|
|
||||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
|
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
|
||||||
use reth_primitives::{EthPrimitives, SealedBlock};
|
use reth_primitives::{EthPrimitives, SealedBlock};
|
||||||
use reth_rpc_types_compat::engine::payload::{
|
use reth_rpc_types_compat::engine::payload::{
|
||||||
@ -27,8 +26,6 @@ pub struct EthBuiltPayload {
|
|||||||
pub(crate) id: PayloadId,
|
pub(crate) id: PayloadId,
|
||||||
/// The built block
|
/// The built block
|
||||||
pub(crate) block: Arc<SealedBlock>,
|
pub(crate) block: Arc<SealedBlock>,
|
||||||
/// Block execution data for the payload, if any.
|
|
||||||
pub(crate) executed_block: Option<ExecutedBlockWithTrieUpdates>,
|
|
||||||
/// The fees of the block
|
/// The fees of the block
|
||||||
pub(crate) fees: U256,
|
pub(crate) fees: U256,
|
||||||
/// The blobs, proofs, and commitments in the block. If the block is pre-cancun, this will be
|
/// 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,
|
id: PayloadId,
|
||||||
block: Arc<SealedBlock>,
|
block: Arc<SealedBlock>,
|
||||||
fees: U256,
|
fees: U256,
|
||||||
executed_block: Option<ExecutedBlockWithTrieUpdates>,
|
|
||||||
requests: Option<Requests>,
|
requests: Option<Requests>,
|
||||||
) -> Self {
|
) -> 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.
|
/// Returns the identifier of the payload.
|
||||||
@ -100,10 +96,6 @@ impl BuiltPayload for EthBuiltPayload {
|
|||||||
self.fees
|
self.fees
|
||||||
}
|
}
|
||||||
|
|
||||||
fn executed_block(&self) -> Option<ExecutedBlockWithTrieUpdates> {
|
|
||||||
self.executed_block.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requests(&self) -> Option<Requests> {
|
fn requests(&self) -> Option<Requests> {
|
||||||
self.requests.clone()
|
self.requests.clone()
|
||||||
}
|
}
|
||||||
@ -120,10 +112,6 @@ impl BuiltPayload for &EthBuiltPayload {
|
|||||||
(**self).fees()
|
(**self).fees()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn executed_block(&self) -> Option<ExecutedBlockWithTrieUpdates> {
|
|
||||||
self.executed_block.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requests(&self) -> Option<Requests> {
|
fn requests(&self) -> Option<Requests> {
|
||||||
self.requests.clone()
|
self.requests.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
use crate::utils::eth_payload_attributes;
|
use crate::utils::eth_payload_attributes;
|
||||||
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
|
|
||||||
use alloy_genesis::Genesis;
|
use alloy_genesis::Genesis;
|
||||||
use alloy_rpc_types_engine::PayloadStatusEnum;
|
use alloy_rpc_types_engine::PayloadStatusEnum;
|
||||||
use reth_chainspec::{ChainSpecBuilder, MAINNET};
|
use reth_chainspec::{ChainSpecBuilder, MAINNET};
|
||||||
@ -27,6 +26,7 @@ async fn can_handle_blobs() -> eyre::Result<()> {
|
|||||||
.cancun_activated()
|
.cancun_activated()
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
|
let genesis_hash = chain_spec.genesis_hash();
|
||||||
let node_config = NodeConfig::test()
|
let node_config = NodeConfig::test()
|
||||||
.with_chain(chain_spec)
|
.with_chain(chain_spec)
|
||||||
.with_unused_ports()
|
.with_unused_ports()
|
||||||
@ -69,15 +69,12 @@ async fn can_handle_blobs() -> eyre::Result<()> {
|
|||||||
let blob_block_hash =
|
let blob_block_hash =
|
||||||
node.engine_api.submit_payload(blob_payload, blob_attr, PayloadStatusEnum::Valid).await?;
|
node.engine_api.submit_payload(blob_payload, blob_attr, PayloadStatusEnum::Valid).await?;
|
||||||
|
|
||||||
let (_, _) = tokio::join!(
|
node.engine_api.update_forkchoice(genesis_hash, blob_block_hash).await?;
|
||||||
// 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())
|
|
||||||
);
|
|
||||||
|
|
||||||
// submit normal payload
|
// submit normal payload (reorg)
|
||||||
node.engine_api.submit_payload(payload, attributes, PayloadStatusEnum::Valid).await?;
|
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;
|
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,6 @@ reth-basic-payload-builder.workspace = true
|
|||||||
reth-evm.workspace = true
|
reth-evm.workspace = true
|
||||||
reth-evm-ethereum.workspace = true
|
reth-evm-ethereum.workspace = true
|
||||||
reth-errors.workspace = true
|
reth-errors.workspace = true
|
||||||
reth-chain-state.workspace = true
|
|
||||||
reth-chainspec.workspace = true
|
reth-chainspec.workspace = true
|
||||||
|
|
||||||
# ethereum
|
# ethereum
|
||||||
|
|||||||
@ -19,7 +19,6 @@ use reth_basic_payload_builder::{
|
|||||||
commit_withdrawals, is_better_payload, BuildArguments, BuildOutcome, PayloadBuilder,
|
commit_withdrawals, is_better_payload, BuildArguments, BuildOutcome, PayloadBuilder,
|
||||||
PayloadConfig,
|
PayloadConfig,
|
||||||
};
|
};
|
||||||
use reth_chain_state::{ExecutedBlock, ExecutedBlockWithTrieUpdates};
|
|
||||||
use reth_chainspec::{ChainSpec, ChainSpecProvider};
|
use reth_chainspec::{ChainSpec, ChainSpecProvider};
|
||||||
use reth_errors::RethError;
|
use reth_errors::RethError;
|
||||||
use reth_evm::{
|
use reth_evm::{
|
||||||
@ -31,8 +30,7 @@ use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes};
|
|||||||
use reth_payload_builder_primitives::PayloadBuilderError;
|
use reth_payload_builder_primitives::PayloadBuilderError;
|
||||||
use reth_payload_primitives::PayloadBuilderAttributes;
|
use reth_payload_primitives::PayloadBuilderAttributes;
|
||||||
use reth_primitives::{
|
use reth_primitives::{
|
||||||
Block, BlockBody, EthereumHardforks, InvalidTransactionError, Receipt, RecoveredBlock,
|
Block, BlockBody, EthereumHardforks, InvalidTransactionError, Receipt, TransactionSigned,
|
||||||
TransactionSigned,
|
|
||||||
};
|
};
|
||||||
use reth_primitives_traits::{
|
use reth_primitives_traits::{
|
||||||
proofs::{self},
|
proofs::{self},
|
||||||
@ -192,7 +190,6 @@ where
|
|||||||
let base_fee = evm_env.block_env.basefee.to::<u64>();
|
let base_fee = evm_env.block_env.basefee.to::<u64>();
|
||||||
|
|
||||||
let mut executed_txs = Vec::new();
|
let mut executed_txs = Vec::new();
|
||||||
let mut executed_senders = Vec::new();
|
|
||||||
|
|
||||||
let mut best_txs = best_txs(BestTransactionsAttributes::new(
|
let mut best_txs = best_txs(BestTransactionsAttributes::new(
|
||||||
base_fee,
|
base_fee,
|
||||||
@ -340,8 +337,7 @@ where
|
|||||||
tx.effective_tip_per_gas(base_fee).expect("fee is always valid; execution succeeded");
|
tx.effective_tip_per_gas(base_fee).expect("fee is always valid; execution succeeded");
|
||||||
total_fees += U256::from(miner_fee) * U256::from(gas_used);
|
total_fees += U256::from(miner_fee) * U256::from(gas_used);
|
||||||
|
|
||||||
// append sender and transaction to the respective lists
|
// append transaction to the block body
|
||||||
executed_senders.push(tx.signer());
|
|
||||||
executed_txs.push(tx.into_tx());
|
executed_txs.push(tx.into_tx());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,8 +395,8 @@ where
|
|||||||
|
|
||||||
// calculate the state root
|
// calculate the state root
|
||||||
let hashed_state = db.database.db.hashed_post_state(execution_outcome.state());
|
let hashed_state = db.database.db.hashed_post_state(execution_outcome.state());
|
||||||
let (state_root, trie_output) = {
|
let (state_root, _) = {
|
||||||
db.database.inner().state_root_with_updates(hashed_state.clone()).inspect_err(|err| {
|
db.database.inner().state_root_with_updates(hashed_state).inspect_err(|err| {
|
||||||
warn!(target: "payload_builder",
|
warn!(target: "payload_builder",
|
||||||
parent_hash=%parent_header.hash(),
|
parent_hash=%parent_header.hash(),
|
||||||
%err,
|
%err,
|
||||||
@ -480,21 +476,7 @@ where
|
|||||||
let sealed_block = Arc::new(block.seal_slow());
|
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");
|
debug!(target: "payload_builder", id=%attributes.id, sealed_block_header = ?sealed_block.sealed_header(), "sealed built block");
|
||||||
|
|
||||||
// create the executed block data
|
let mut payload = EthBuiltPayload::new(attributes.id, sealed_block, total_fees, requests);
|
||||||
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);
|
|
||||||
|
|
||||||
// extend the payload with the blob sidecars from the executed txs
|
// extend the payload with the blob sidecars from the executed txs
|
||||||
payload.extend_sidecars(blob_sidecars.into_iter().map(Arc::unwrap_or_clone));
|
payload.extend_sidecars(blob_sidecars.into_iter().map(Arc::unwrap_or_clone));
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
//! },
|
//! },
|
||||||
//! ..Default::default()
|
//! ..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)
|
//! Ok(payload)
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use alloy_primitives::U256;
|
use alloy_primitives::U256;
|
||||||
use reth_chain_state::{CanonStateNotification, ExecutedBlockWithTrieUpdates};
|
use reth_chain_state::CanonStateNotification;
|
||||||
use reth_payload_builder_primitives::PayloadBuilderError;
|
use reth_payload_builder_primitives::PayloadBuilderError;
|
||||||
use reth_payload_primitives::{PayloadKind, PayloadTypes};
|
use reth_payload_primitives::{PayloadKind, PayloadTypes};
|
||||||
use reth_primitives::Block;
|
use reth_primitives::Block;
|
||||||
@ -90,7 +90,6 @@ impl PayloadJob for TestPayloadJob {
|
|||||||
self.attr.payload_id(),
|
self.attr.payload_id(),
|
||||||
Arc::new(Block::default().seal_slow()),
|
Arc::new(Block::default().seal_slow()),
|
||||||
U256::ZERO,
|
U256::ZERO,
|
||||||
Some(ExecutedBlockWithTrieUpdates::default()),
|
|
||||||
Some(Default::default()),
|
Some(Default::default()),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user