feat: split reth-payload-primitives (#12600)

This commit is contained in:
Federico Gimenez
2024-11-16 18:36:57 +01:00
committed by GitHub
parent 735eb4b97c
commit bf92a5fb59
42 changed files with 302 additions and 223 deletions

View File

@ -52,6 +52,7 @@ exclude_crates=(
reth-optimism-payload-builder reth-optimism-payload-builder
reth-optimism-rpc reth-optimism-rpc
reth-payload-builder reth-payload-builder
reth-payload-builder-primitives
reth-payload-primitives reth-payload-primitives
reth-rpc reth-rpc
reth-rpc-api reth-rpc-api

39
Cargo.lock generated
View File

@ -2867,7 +2867,6 @@ dependencies = [
"reth-node-core", "reth-node-core",
"reth-node-ethereum", "reth-node-ethereum",
"reth-payload-builder", "reth-payload-builder",
"reth-primitives",
"reth-tracing", "reth-tracing",
"reth-trie-db", "reth-trie-db",
"serde", "serde",
@ -6436,6 +6435,7 @@ dependencies = [
"reth-evm", "reth-evm",
"reth-metrics", "reth-metrics",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-primitives", "reth-primitives",
"reth-primitives-traits", "reth-primitives-traits",
@ -6480,6 +6480,7 @@ dependencies = [
"reth-network-p2p", "reth-network-p2p",
"reth-node-types", "reth-node-types",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-payload-validator", "reth-payload-validator",
"reth-primitives", "reth-primitives",
@ -7103,6 +7104,7 @@ dependencies = [
"reth-network-peers", "reth-network-peers",
"reth-node-builder", "reth-node-builder",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-provider", "reth-provider",
"reth-rpc-layer", "reth-rpc-layer",
@ -7164,6 +7166,7 @@ dependencies = [
"reth-ethereum-engine-primitives", "reth-ethereum-engine-primitives",
"reth-evm", "reth-evm",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-payload-validator", "reth-payload-validator",
"reth-provider", "reth-provider",
@ -7185,6 +7188,7 @@ dependencies = [
"futures", "futures",
"reth-errors", "reth-errors",
"reth-execution-types", "reth-execution-types",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-primitives", "reth-primitives",
"reth-trie", "reth-trie",
@ -7250,6 +7254,7 @@ dependencies = [
"reth-metrics", "reth-metrics",
"reth-network-p2p", "reth-network-p2p",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-payload-validator", "reth-payload-validator",
"reth-primitives", "reth-primitives",
@ -7456,6 +7461,7 @@ dependencies = [
"reth-evm-ethereum", "reth-evm-ethereum",
"reth-execution-types", "reth-execution-types",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-primitives", "reth-primitives",
"reth-provider", "reth-provider",
@ -7936,6 +7942,7 @@ dependencies = [
"reth-network-api", "reth-network-api",
"reth-node-core", "reth-node-core",
"reth-node-types", "reth-node-types",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-provider", "reth-provider",
"reth-tasks", "reth-tasks",
@ -7983,7 +7990,6 @@ dependencies = [
"reth-node-events", "reth-node-events",
"reth-node-metrics", "reth-node-metrics",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-primitives",
"reth-payload-validator", "reth-payload-validator",
"reth-primitives", "reth-primitives",
"reth-provider", "reth-provider",
@ -8360,6 +8366,7 @@ dependencies = [
"reth-optimism-evm", "reth-optimism-evm",
"reth-optimism-forks", "reth-optimism-forks",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-payload-util", "reth-payload-util",
"reth-primitives", "reth-primitives",
@ -8459,6 +8466,7 @@ dependencies = [
"reth-chain-state", "reth-chain-state",
"reth-ethereum-engine-primitives", "reth-ethereum-engine-primitives",
"reth-metrics", "reth-metrics",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-primitives", "reth-primitives",
"revm", "revm",
@ -8467,6 +8475,24 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "reth-payload-builder-primitives"
version = "1.1.1"
dependencies = [
"alloy-primitives",
"alloy-rpc-types-engine",
"async-trait",
"pin-project",
"reth-errors",
"reth-payload-primitives",
"reth-transaction-pool",
"revm-primitives",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
]
[[package]] [[package]]
name = "reth-payload-primitives" name = "reth-payload-primitives"
version = "1.1.1" version = "1.1.1"
@ -8474,20 +8500,12 @@ dependencies = [
"alloy-eips", "alloy-eips",
"alloy-primitives", "alloy-primitives",
"alloy-rpc-types-engine", "alloy-rpc-types-engine",
"async-trait",
"op-alloy-rpc-types-engine", "op-alloy-rpc-types-engine",
"pin-project",
"reth-chain-state", "reth-chain-state",
"reth-chainspec", "reth-chainspec",
"reth-errors",
"reth-primitives", "reth-primitives",
"reth-transaction-pool",
"revm-primitives",
"serde", "serde",
"thiserror 1.0.69", "thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
] ]
[[package]] [[package]]
@ -8887,6 +8905,7 @@ dependencies = [
"reth-evm", "reth-evm",
"reth-metrics", "reth-metrics",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-primitives", "reth-primitives",
"reth-provider", "reth-provider",

View File

@ -80,6 +80,7 @@ members = [
"crates/optimism/storage", "crates/optimism/storage",
"crates/payload/basic/", "crates/payload/basic/",
"crates/payload/builder/", "crates/payload/builder/",
"crates/payload/builder-primitives/",
"crates/payload/primitives/", "crates/payload/primitives/",
"crates/payload/validator/", "crates/payload/validator/",
"crates/payload/util/", "crates/payload/util/",
@ -380,6 +381,7 @@ reth-optimism-primitives = { path = "crates/optimism/primitives" }
reth-optimism-rpc = { path = "crates/optimism/rpc" } reth-optimism-rpc = { path = "crates/optimism/rpc" }
reth-optimism-storage = { path = "crates/optimism/storage" } reth-optimism-storage = { path = "crates/optimism/storage" }
reth-payload-builder = { path = "crates/payload/builder" } reth-payload-builder = { path = "crates/payload/builder" }
reth-payload-builder-primitives = { path = "crates/payload/builder-primitives" }
reth-payload-primitives = { path = "crates/payload/primitives" } reth-payload-primitives = { path = "crates/payload/primitives" }
reth-payload-validator = { path = "crates/payload/validator" } reth-payload-validator = { path = "crates/payload/validator" }
reth-payload-util = { path = "crates/payload/util" } reth-payload-util = { path = "crates/payload/util" }

View File

@ -20,6 +20,7 @@ reth-errors.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
reth-tasks.workspace = true reth-tasks.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-payload-validator.workspace = true reth-payload-validator.workspace = true
reth-prune.workspace = true reth-prune.workspace = true

View File

@ -23,7 +23,8 @@ use reth_network_p2p::{
}; };
use reth_node_types::NodeTypesWithEngine; use reth_node_types::NodeTypesWithEngine;
use reth_payload_builder::PayloadBuilderHandle; use reth_payload_builder::PayloadBuilderHandle;
use reth_payload_primitives::{PayloadAttributes, PayloadBuilder, PayloadBuilderAttributes}; use reth_payload_builder_primitives::PayloadBuilder;
use reth_payload_primitives::{PayloadAttributes, PayloadBuilderAttributes};
use reth_payload_validator::ExecutionPayloadValidator; use reth_payload_validator::ExecutionPayloadValidator;
use reth_primitives::{Head, SealedBlock, SealedHeader}; use reth_primitives::{Head, SealedBlock, SealedHeader};
use reth_provider::{ use reth_provider::{

View File

@ -17,6 +17,7 @@ reth-tracing.workspace = true
reth-db = { workspace = true, features = ["test-utils"] } reth-db = { workspace = true, features = ["test-utils"] }
reth-rpc-layer.workspace = true reth-rpc-layer.workspace = true
reth-payload-builder = { workspace = true, features = ["test-utils"] } reth-payload-builder = { workspace = true, features = ["test-utils"] }
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
reth-node-builder = { workspace = true, features = ["test-utils"] } reth-node-builder = { workspace = true, features = ["test-utils"] }

View File

@ -1,7 +1,8 @@
use futures_util::StreamExt; use futures_util::StreamExt;
use reth::api::{BuiltPayload, PayloadBuilderAttributes}; use reth::api::BuiltPayload;
use reth_payload_builder::{PayloadBuilderHandle, PayloadId}; use reth_payload_builder::{PayloadBuilderHandle, PayloadId};
use reth_payload_primitives::{Events, PayloadBuilder, PayloadTypes}; use reth_payload_builder_primitives::{Events, PayloadBuilder};
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadTypes};
use tokio_stream::wrappers::BroadcastStream; use tokio_stream::wrappers::BroadcastStream;
/// Helper for payload operations /// Helper for payload operations

View File

@ -19,6 +19,7 @@ reth-engine-tree.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-ethereum-engine-primitives.workspace = true reth-ethereum-engine-primitives.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-payload-validator.workspace = true reth-payload-validator.workspace = true
reth-provider.workspace = true reth-provider.workspace = true

View File

@ -7,9 +7,8 @@ use futures_util::{stream::Fuse, StreamExt};
use reth_chainspec::EthereumHardforks; use reth_chainspec::EthereumHardforks;
use reth_engine_primitives::{BeaconEngineMessage, EngineApiMessageVersion, EngineTypes}; use reth_engine_primitives::{BeaconEngineMessage, EngineApiMessageVersion, EngineTypes};
use reth_payload_builder::PayloadBuilderHandle; use reth_payload_builder::PayloadBuilderHandle;
use reth_payload_primitives::{ use reth_payload_builder_primitives::PayloadBuilder;
BuiltPayload, PayloadAttributesBuilder, PayloadBuilder, PayloadKind, PayloadTypes, use reth_payload_primitives::{BuiltPayload, PayloadAttributesBuilder, PayloadKind, PayloadTypes};
};
use reth_provider::{BlockReader, ChainSpecProvider}; use reth_provider::{BlockReader, ChainSpecProvider};
use reth_rpc_types_compat::engine::payload::block_to_payload; use reth_rpc_types_compat::engine::payload::block_to_payload;
use reth_transaction_pool::TransactionPool; use reth_transaction_pool::TransactionPool;

View File

@ -14,6 +14,7 @@ workspace = true
# reth # reth
reth-execution-types.workspace = true reth-execution-types.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-payload-builder-primitives.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-trie.workspace = true reth-trie.workspace = true
reth-errors.workspace = true reth-errors.workspace = true

View File

@ -5,7 +5,7 @@ use alloy_rpc_types_engine::{
}; };
use futures::{future::Either, FutureExt}; use futures::{future::Either, FutureExt};
use reth_errors::RethResult; use reth_errors::RethResult;
use reth_payload_primitives::PayloadBuilderError; use reth_payload_builder_primitives::PayloadBuilderError;
use std::{ use std::{
fmt::Display, fmt::Display,
future::Future, future::Future,

View File

@ -23,6 +23,7 @@ reth-errors.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-network-p2p.workspace = true reth-network-p2p.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-payload-validator.workspace = true reth-payload-validator.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true

View File

@ -33,7 +33,8 @@ use reth_engine_primitives::{
use reth_errors::{ConsensusError, ProviderResult}; use reth_errors::{ConsensusError, ProviderResult};
use reth_evm::execute::BlockExecutorProvider; use reth_evm::execute::BlockExecutorProvider;
use reth_payload_builder::PayloadBuilderHandle; use reth_payload_builder::PayloadBuilderHandle;
use reth_payload_primitives::{PayloadAttributes, PayloadBuilder, PayloadBuilderAttributes}; use reth_payload_builder_primitives::PayloadBuilder;
use reth_payload_primitives::{PayloadAttributes, PayloadBuilderAttributes};
use reth_payload_validator::ExecutionPayloadValidator; use reth_payload_validator::ExecutionPayloadValidator;
use reth_primitives::{Block, GotExpected, SealedBlock, SealedBlockWithSenders, SealedHeader}; use reth_primitives::{Block, GotExpected, SealedBlock, SealedBlockWithSenders, SealedHeader};
use reth_provider::{ use reth_provider::{

View File

@ -18,6 +18,7 @@ reth-revm.workspace = true
reth-transaction-pool.workspace = true reth-transaction-pool.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-execution-types.workspace = true reth-execution-types.workspace = true
reth-basic-payload-builder.workspace = true reth-basic-payload-builder.workspace = true

View File

@ -23,7 +23,8 @@ use reth_evm::{system_calls::SystemCaller, ConfigureEvm, NextBlockEnvAttributes}
use reth_evm_ethereum::{eip6110::parse_deposits_from_receipts, EthEvmConfig}; use reth_evm_ethereum::{eip6110::parse_deposits_from_receipts, EthEvmConfig};
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes}; use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes};
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError}; use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_primitives::{ use reth_primitives::{
proofs::{self}, proofs::{self},
Block, BlockBody, EthereumHardforks, Receipt, Block, BlockBody, EthereumHardforks, Receipt,

View File

@ -18,6 +18,7 @@ reth-evm.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
reth-engine-primitives.workspace = true reth-engine-primitives.workspace = true
reth-transaction-pool.workspace = true reth-transaction-pool.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-tasks.workspace = true reth-tasks.workspace = true
reth-network-api.workspace = true reth-network-api.workspace = true

View File

@ -16,6 +16,10 @@ pub use reth_engine_primitives::*;
pub use reth_payload_primitives as payload; pub use reth_payload_primitives as payload;
pub use reth_payload_primitives::*; pub use reth_payload_primitives::*;
/// Traits and helper types used to abstract over payload builder types.
pub use reth_payload_builder_primitives as payload_builder;
pub use reth_payload_builder_primitives::*;
/// Traits and helper types used to abstract over EVM methods and types. /// Traits and helper types used to abstract over EVM methods and types.
pub use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes}; pub use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};

View File

@ -9,7 +9,7 @@ use reth_evm::execute::BlockExecutorProvider;
use reth_network_api::FullNetwork; use reth_network_api::FullNetwork;
use reth_node_core::node_config::NodeConfig; use reth_node_core::node_config::NodeConfig;
use reth_node_types::{NodeTypes, NodeTypesWithDB, NodeTypesWithEngine}; use reth_node_types::{NodeTypes, NodeTypesWithDB, NodeTypesWithEngine};
use reth_payload_primitives::PayloadBuilder; use reth_payload_builder_primitives::PayloadBuilder;
use reth_provider::FullProvider; use reth_provider::FullProvider;
use reth_tasks::TaskExecutor; use reth_tasks::TaskExecutor;
use reth_transaction_pool::TransactionPool; use reth_transaction_pool::TransactionPool;

View File

@ -41,7 +41,6 @@ reth-node-core.workspace = true
reth-node-events.workspace = true reth-node-events.workspace = true
reth-node-metrics.workspace = true reth-node-metrics.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-primitives.workspace = true
reth-payload-validator.workspace = true reth-payload-validator.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-provider.workspace = true reth-provider.workspace = true

View File

@ -19,7 +19,8 @@ use reth_exex::ExExManagerHandle;
use reth_network::{NetworkSyncUpdater, SyncState}; use reth_network::{NetworkSyncUpdater, SyncState};
use reth_network_api::{BlockDownloaderProvider, NetworkEventListenerProvider}; use reth_network_api::{BlockDownloaderProvider, NetworkEventListenerProvider};
use reth_node_api::{ use reth_node_api::{
BuiltPayload, FullNodeTypes, NodeTypesWithEngine, PayloadAttributesBuilder, PayloadTypes, BuiltPayload, FullNodeTypes, NodeTypesWithEngine, PayloadAttributesBuilder, PayloadBuilder,
PayloadTypes,
}; };
use reth_node_core::{ use reth_node_core::{
dirs::{ChainPath, DataDirPath}, dirs::{ChainPath, DataDirPath},
@ -27,7 +28,6 @@ use reth_node_core::{
primitives::Head, primitives::Head,
}; };
use reth_node_events::{cl::ConsensusLayerHealthEvents, node}; use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
use reth_payload_primitives::PayloadBuilder;
use reth_primitives::EthereumHardforks; use reth_primitives::EthereumHardforks;
use reth_provider::providers::{BlockchainProvider2, ProviderNodeTypes}; use reth_provider::providers::{BlockchainProvider2, ProviderNodeTypes};
use reth_tasks::TaskExecutor; use reth_tasks::TaskExecutor;

View File

@ -11,13 +11,13 @@ use alloy_rpc_types::engine::ClientVersionV1;
use futures::TryFutureExt; use futures::TryFutureExt;
use reth_node_api::{ use reth_node_api::{
AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, NodeTypes, NodeTypesWithEngine, AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, NodeTypes, NodeTypesWithEngine,
PayloadBuilder,
}; };
use reth_node_core::{ use reth_node_core::{
node_config::NodeConfig, node_config::NodeConfig,
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA}, version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
}; };
use reth_payload_builder::PayloadStore; use reth_payload_builder::PayloadStore;
use reth_payload_primitives::PayloadBuilder;
use reth_provider::providers::ProviderNodeTypes; use reth_provider::providers::ProviderNodeTypes;
use reth_rpc::{ use reth_rpc::{
eth::{EthApiTypes, FullEthApiServer}, eth::{EthApiTypes, FullEthApiServer},

View File

@ -22,6 +22,7 @@ reth-rpc-types-compat.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-execution-types.workspace = true reth-execution-types.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-util.workspace = true reth-payload-util.workspace = true
reth-payload-primitives = { workspace = true, features = ["op"] } reth-payload-primitives = { workspace = true, features = ["op"] }
reth-basic-payload-builder.workspace = true reth-basic-payload-builder.workspace = true

View File

@ -15,7 +15,8 @@ use reth_execution_types::ExecutionOutcome;
use reth_optimism_chainspec::OpChainSpec; use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_consensus::calculate_receipt_root_no_memo_optimism; use reth_optimism_consensus::calculate_receipt_root_no_memo_optimism;
use reth_optimism_forks::OpHardforks; use reth_optimism_forks::OpHardforks;
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError}; use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_payload_util::PayloadTransactions; use reth_payload_util::PayloadTransactions;
use reth_primitives::{proofs, Block, BlockBody, Receipt, SealedHeader, TransactionSigned, TxType}; use reth_primitives::{proofs, Block, BlockBody, Receipt, SealedHeader, TransactionSigned, TxType};
use reth_provider::{ProviderError, StateProofProvider, StateProviderFactory, StateRootProvider}; use reth_provider::{ProviderError, StateProofProvider, StateProviderFactory, StateRootProvider};

View File

@ -19,6 +19,7 @@ reth-primitives-traits.workspace = true
reth-transaction-pool.workspace = true reth-transaction-pool.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-tasks.workspace = true reth-tasks.workspace = true
reth-evm.workspace = true reth-evm.workspace = true

View File

@ -17,9 +17,8 @@ use futures_util::FutureExt;
use reth_chainspec::EthereumHardforks; use reth_chainspec::EthereumHardforks;
use reth_evm::state_change::post_block_withdrawals_balance_increments; use reth_evm::state_change::post_block_withdrawals_balance_increments;
use reth_payload_builder::{KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJobGenerator}; use reth_payload_builder::{KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJobGenerator};
use reth_payload_primitives::{ use reth_payload_builder_primitives::PayloadBuilderError;
BuiltPayload, PayloadBuilderAttributes, PayloadBuilderError, PayloadKind, use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind};
};
use reth_primitives::{proofs, SealedHeader}; use reth_primitives::{proofs, SealedHeader};
use reth_primitives_traits::constants::RETH_CLIENT_VERSION; use reth_primitives_traits::constants::RETH_CLIENT_VERSION;
use reth_provider::{BlockReaderIdExt, CanonStateNotification, StateProviderFactory}; use reth_provider::{BlockReaderIdExt, CanonStateNotification, StateProviderFactory};

View File

@ -0,0 +1,33 @@
[package]
name = "reth-payload-builder-primitives"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
exclude.workspace = true
[lints]
workspace = true
[dependencies]
# reth
reth-errors.workspace = true
reth-payload-primitives.workspace = true
reth-transaction-pool.workspace = true
revm-primitives.workspace = true
# alloy
alloy-primitives.workspace = true
alloy-rpc-types-engine = { workspace = true, features = ["serde"] }
# async
async-trait.workspace = true
pin-project.workspace = true
tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true
# misc
thiserror.workspace = true
tracing.workspace = true

View File

@ -0,0 +1,58 @@
//! Error types emitted by types or implementations of this crate.
use alloy_primitives::B256;
use reth_errors::{ProviderError, RethError};
use reth_transaction_pool::BlobStoreError;
use revm_primitives::EVMError;
use tokio::sync::oneshot;
/// Possible error variants during payload building.
#[derive(Debug, thiserror::Error)]
pub enum PayloadBuilderError {
/// Thrown when the parent header cannot be found
#[error("missing parent header: {0}")]
MissingParentHeader(B256),
/// Thrown when the parent block is missing.
#[error("missing parent block {0}")]
MissingParentBlock(B256),
/// An oneshot channels has been closed.
#[error("sender has been dropped")]
ChannelClosed,
/// If there's no payload to resolve.
#[error("missing payload")]
MissingPayload,
/// Error occurring in the blob store.
#[error(transparent)]
BlobStore(#[from] BlobStoreError),
/// Other internal error
#[error(transparent)]
Internal(#[from] RethError),
/// Unrecoverable error during evm execution.
#[error("evm execution error: {0}")]
EvmExecutionError(EVMError<ProviderError>),
/// Any other payload building errors.
#[error(transparent)]
Other(Box<dyn core::error::Error + Send + Sync>),
}
impl PayloadBuilderError {
/// Create a new error from a boxed error.
pub fn other<E>(error: E) -> Self
where
E: core::error::Error + Send + Sync + 'static,
{
Self::Other(Box::new(error))
}
}
impl From<ProviderError> for PayloadBuilderError {
fn from(error: ProviderError) -> Self {
Self::Internal(RethError::Provider(error))
}
}
impl From<oneshot::error::RecvError> for PayloadBuilderError {
fn from(_: oneshot::error::RecvError) -> Self {
Self::ChannelClosed
}
}

View File

@ -1,4 +1,4 @@
use crate::PayloadTypes; use reth_payload_primitives::PayloadTypes;
use std::{ use std::{
pin::Pin, pin::Pin,
task::{ready, Context, Poll}, task::{ready, Context, Poll},

View File

@ -0,0 +1,19 @@
//! This crate defines abstractions to create and update payloads (blocks)
#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
mod error;
pub use error::PayloadBuilderError;
mod events;
pub use crate::events::{Events, PayloadEvents};
/// Contains the payload builder trait to abstract over payload attributes.
mod traits;
pub use traits::{PayloadBuilder, PayloadStoreExt};

View File

@ -0,0 +1,111 @@
use crate::{PayloadBuilderError, PayloadEvents};
use alloy_rpc_types_engine::PayloadId;
use reth_payload_primitives::{PayloadKind, PayloadTypes};
use std::fmt::Debug;
use tokio::sync::oneshot;
/// A helper trait for internal usage to retrieve and resolve payloads.
#[async_trait::async_trait]
pub trait PayloadStoreExt<T: PayloadTypes>: Debug + Send + Sync + Unpin {
/// Resolves the payload job and returns the best payload that has been built so far.
async fn resolve_kind(
&self,
id: PayloadId,
kind: PayloadKind,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>>;
/// Resolves the payload job as fast and possible and returns the best payload that has been
/// built so far.
async fn resolve(&self, id: PayloadId) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
self.resolve_kind(id, PayloadKind::Earliest).await
}
/// Returns the best payload for the given identifier.
async fn best_payload(
&self,
id: PayloadId,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>>;
/// Returns the payload attributes associated with the given identifier.
async fn payload_attributes(
&self,
id: PayloadId,
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>>;
}
#[async_trait::async_trait]
impl<T: PayloadTypes, P> PayloadStoreExt<T> for P
where
P: PayloadBuilder<PayloadType = T>,
{
async fn resolve_kind(
&self,
id: PayloadId,
kind: PayloadKind,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
Some(PayloadBuilder::resolve_kind(self, id, kind).await?.map_err(Into::into))
}
async fn best_payload(
&self,
id: PayloadId,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
Some(PayloadBuilder::best_payload(self, id).await?.map_err(Into::into))
}
async fn payload_attributes(
&self,
id: PayloadId,
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>> {
Some(PayloadBuilder::payload_attributes(self, id).await?.map_err(Into::into))
}
}
/// A type that can request, subscribe to and resolve payloads.
#[async_trait::async_trait]
pub trait PayloadBuilder: Debug + Send + Sync + Unpin {
/// The Payload type for the builder.
type PayloadType: PayloadTypes;
/// The error type returned by the builder.
type Error: Into<PayloadBuilderError>;
/// Sends a message to the service to start building a new payload for the given payload.
///
/// Returns a receiver that will receive the payload id.
fn send_new_payload(
&self,
attr: <Self::PayloadType as PayloadTypes>::PayloadBuilderAttributes,
) -> oneshot::Receiver<Result<PayloadId, Self::Error>>;
/// Returns the best payload for the given identifier.
async fn best_payload(
&self,
id: PayloadId,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>>;
/// Resolves the payload job and returns the best payload that has been built so far.
async fn resolve_kind(
&self,
id: PayloadId,
kind: PayloadKind,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>>;
/// Resolves the payload job as fast and possible and returns the best payload that has been
/// built so far.
async fn resolve(
&self,
id: PayloadId,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>> {
self.resolve_kind(id, PayloadKind::Earliest).await
}
/// Sends a message to the service to subscribe to payload events.
/// Returns a receiver that will receive them.
async fn subscribe(&self) -> Result<PayloadEvents<Self::PayloadType>, Self::Error>;
/// Returns the payload attributes associated with the given identifier.
async fn payload_attributes(
&self,
id: PayloadId,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::PayloadBuilderAttributes, Self::Error>>;
}

View File

@ -15,6 +15,7 @@ workspace = true
# reth # reth
reth-primitives = { workspace = true, optional = true } reth-primitives = { workspace = true, optional = true }
reth-chain-state.workspace = true reth-chain-state.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-ethereum-engine-primitives.workspace = true reth-ethereum-engine-primitives.workspace = true

View File

@ -113,7 +113,8 @@ pub mod noop;
pub mod test_utils; pub mod test_utils;
pub use alloy_rpc_types::engine::PayloadId; pub use alloy_rpc_types::engine::PayloadId;
pub use reth_payload_primitives::{PayloadBuilderError, PayloadKind}; pub use reth_payload_builder_primitives::PayloadBuilderError;
pub use reth_payload_primitives::PayloadKind;
pub use service::{ pub use service::{
PayloadBuilderHandle, PayloadBuilderService, PayloadServiceCommand, PayloadStore, PayloadBuilderHandle, PayloadBuilderService, PayloadServiceCommand, PayloadStore,
}; };

View File

@ -10,10 +10,10 @@ use crate::{
use alloy_rpc_types::engine::PayloadId; use alloy_rpc_types::engine::PayloadId;
use futures_util::{future::FutureExt, Stream, StreamExt}; use futures_util::{future::FutureExt, Stream, StreamExt};
use reth_chain_state::CanonStateNotification; use reth_chain_state::CanonStateNotification;
use reth_payload_primitives::{ use reth_payload_builder_primitives::{
BuiltPayload, Events, PayloadBuilder, PayloadBuilderAttributes, PayloadBuilderError, Events, PayloadBuilder, PayloadBuilderError, PayloadEvents, PayloadStoreExt,
PayloadEvents, PayloadKind, PayloadStoreExt, PayloadTypes,
}; };
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind, PayloadTypes};
use std::{ use std::{
fmt, fmt,
future::Future, future::Future,

View File

@ -7,7 +7,8 @@ use crate::{
use alloy_primitives::U256; use alloy_primitives::U256;
use reth_chain_state::{CanonStateNotification, ExecutedBlock}; use reth_chain_state::{CanonStateNotification, ExecutedBlock};
use reth_payload_primitives::{PayloadBuilderError, PayloadKind, PayloadTypes}; use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::{PayloadKind, PayloadTypes};
use reth_primitives::Block; use reth_primitives::Block;
use std::{ use std::{
future::Future, future::Future,

View File

@ -1,9 +1,8 @@
//! Trait abstractions used by the payload crate. //! Trait abstractions used by the payload crate.
use reth_chain_state::CanonStateNotification; use reth_chain_state::CanonStateNotification;
use reth_payload_primitives::{ use reth_payload_builder_primitives::PayloadBuilderError;
BuiltPayload, PayloadBuilderAttributes, PayloadBuilderError, PayloadKind, use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadKind};
};
use std::future::Future; use std::future::Future;
/// A type that can build a payload. /// A type that can build a payload.

View File

@ -14,9 +14,7 @@ workspace = true
[dependencies] [dependencies]
# reth # reth
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-errors.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-transaction-pool.workspace = true
reth-chain-state.workspace = true reth-chain-state.workspace = true
# alloy # alloy
@ -25,18 +23,9 @@ alloy-primitives.workspace = true
alloy-rpc-types-engine = { workspace = true, features = ["serde"] } alloy-rpc-types-engine = { workspace = true, features = ["serde"] }
op-alloy-rpc-types-engine = { workspace = true, optional = true } op-alloy-rpc-types-engine = { workspace = true, optional = true }
revm-primitives.workspace = true
# async
async-trait.workspace = true
tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true
pin-project.workspace = true
# misc # misc
serde.workspace = true serde.workspace = true
thiserror.workspace = true thiserror.workspace = true
tracing.workspace = true
[features] [features]
op = ["dep:op-alloy-rpc-types-engine"] op = ["dep:op-alloy-rpc-types-engine"]

View File

@ -1,62 +1,5 @@
//! Error types emitted by types or implementations of this crate. //! Error types emitted by types or implementations of this crate.
use alloy_primitives::B256;
use reth_errors::{ProviderError, RethError};
use reth_transaction_pool::BlobStoreError;
use revm_primitives::EVMError;
use tokio::sync::oneshot;
/// Possible error variants during payload building.
#[derive(Debug, thiserror::Error)]
pub enum PayloadBuilderError {
/// Thrown when the parent header cannot be found
#[error("missing parent header: {0}")]
MissingParentHeader(B256),
/// Thrown when the parent block is missing.
#[error("missing parent block {0}")]
MissingParentBlock(B256),
/// An oneshot channels has been closed.
#[error("sender has been dropped")]
ChannelClosed,
/// If there's no payload to resolve.
#[error("missing payload")]
MissingPayload,
/// Error occurring in the blob store.
#[error(transparent)]
BlobStore(#[from] BlobStoreError),
/// Other internal error
#[error(transparent)]
Internal(#[from] RethError),
/// Unrecoverable error during evm execution.
#[error("evm execution error: {0}")]
EvmExecutionError(EVMError<ProviderError>),
/// Any other payload building errors.
#[error(transparent)]
Other(Box<dyn core::error::Error + Send + Sync>),
}
impl PayloadBuilderError {
/// Create a new error from a boxed error.
pub fn other<E>(error: E) -> Self
where
E: core::error::Error + Send + Sync + 'static,
{
Self::Other(Box::new(error))
}
}
impl From<ProviderError> for PayloadBuilderError {
fn from(error: ProviderError) -> Self {
Self::Internal(RethError::Provider(error))
}
}
impl From<oneshot::error::RecvError> for PayloadBuilderError {
fn from(_: oneshot::error::RecvError) -> Self {
Self::ChannelClosed
}
}
/// Thrown when the payload or attributes are known to be invalid before processing. /// Thrown when the payload or attributes are known to be invalid before processing.
/// ///
/// This is used mainly for /// This is used mainly for

View File

@ -9,18 +9,13 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
mod error; mod error;
pub use error::{EngineObjectValidationError, VersionSpecificValidationError};
pub use error::{EngineObjectValidationError, PayloadBuilderError, VersionSpecificValidationError};
mod events;
pub use crate::events::{Events, PayloadEvents};
/// Contains traits to abstract over payload attributes types and default implementations of the /// Contains traits to abstract over payload attributes types and default implementations of the
/// [`PayloadAttributes`] trait for ethereum mainnet and optimism types. /// [`PayloadAttributes`] trait for ethereum mainnet and optimism types.
mod traits; mod traits;
pub use traits::{ pub use traits::{
BuiltPayload, PayloadAttributes, PayloadAttributesBuilder, PayloadBuilder, BuiltPayload, PayloadAttributes, PayloadAttributesBuilder, PayloadBuilderAttributes,
PayloadBuilderAttributes, PayloadStoreExt,
}; };
mod payload; mod payload;

View File

@ -1,4 +1,3 @@
use crate::{PayloadBuilderError, PayloadEvents, PayloadKind, PayloadTypes};
use alloy_eips::{ use alloy_eips::{
eip4895::{Withdrawal, Withdrawals}, eip4895::{Withdrawal, Withdrawals},
eip7685::Requests, eip7685::Requests,
@ -7,114 +6,6 @@ use alloy_primitives::{Address, B256, U256};
use alloy_rpc_types_engine::{PayloadAttributes as EthPayloadAttributes, PayloadId}; use alloy_rpc_types_engine::{PayloadAttributes as EthPayloadAttributes, PayloadId};
use reth_chain_state::ExecutedBlock; use reth_chain_state::ExecutedBlock;
use reth_primitives::SealedBlock; use reth_primitives::SealedBlock;
use std::fmt::Debug;
use tokio::sync::oneshot;
/// A type that can request, subscribe to and resolve payloads.
#[async_trait::async_trait]
pub trait PayloadBuilder: Debug + Send + Sync + Unpin {
/// The Payload type for the builder.
type PayloadType: PayloadTypes;
/// The error type returned by the builder.
type Error: Into<PayloadBuilderError>;
/// Sends a message to the service to start building a new payload for the given payload.
///
/// Returns a receiver that will receive the payload id.
fn send_new_payload(
&self,
attr: <Self::PayloadType as PayloadTypes>::PayloadBuilderAttributes,
) -> oneshot::Receiver<Result<PayloadId, Self::Error>>;
/// Returns the best payload for the given identifier.
async fn best_payload(
&self,
id: PayloadId,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>>;
/// Resolves the payload job and returns the best payload that has been built so far.
async fn resolve_kind(
&self,
id: PayloadId,
kind: PayloadKind,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>>;
/// Resolves the payload job as fast and possible and returns the best payload that has been
/// built so far.
async fn resolve(
&self,
id: PayloadId,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::BuiltPayload, Self::Error>> {
self.resolve_kind(id, PayloadKind::Earliest).await
}
/// Sends a message to the service to subscribe to payload events.
/// Returns a receiver that will receive them.
async fn subscribe(&self) -> Result<PayloadEvents<Self::PayloadType>, Self::Error>;
/// Returns the payload attributes associated with the given identifier.
async fn payload_attributes(
&self,
id: PayloadId,
) -> Option<Result<<Self::PayloadType as PayloadTypes>::PayloadBuilderAttributes, Self::Error>>;
}
/// A helper trait for internal usage to retrieve and resolve payloads.
#[async_trait::async_trait]
pub trait PayloadStoreExt<T: PayloadTypes>: Debug + Send + Sync + Unpin {
/// Resolves the payload job and returns the best payload that has been built so far.
async fn resolve_kind(
&self,
id: PayloadId,
kind: PayloadKind,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>>;
/// Resolves the payload job as fast and possible and returns the best payload that has been
/// built so far.
async fn resolve(&self, id: PayloadId) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
self.resolve_kind(id, PayloadKind::Earliest).await
}
/// Returns the best payload for the given identifier.
async fn best_payload(
&self,
id: PayloadId,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>>;
/// Returns the payload attributes associated with the given identifier.
async fn payload_attributes(
&self,
id: PayloadId,
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>>;
}
#[async_trait::async_trait]
impl<T: PayloadTypes, P> PayloadStoreExt<T> for P
where
P: PayloadBuilder<PayloadType = T>,
{
async fn resolve_kind(
&self,
id: PayloadId,
kind: PayloadKind,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
Some(PayloadBuilder::resolve_kind(self, id, kind).await?.map_err(Into::into))
}
async fn best_payload(
&self,
id: PayloadId,
) -> Option<Result<T::BuiltPayload, PayloadBuilderError>> {
Some(PayloadBuilder::best_payload(self, id).await?.map_err(Into::into))
}
async fn payload_attributes(
&self,
id: PayloadId,
) -> Option<Result<T::PayloadBuilderAttributes, PayloadBuilderError>> {
Some(PayloadBuilder::payload_attributes(self, id).await?.map_err(Into::into))
}
}
/// Represents a built payload type that contains a built [`SealedBlock`] and can be converted into /// Represents a built payload type that contains a built [`SealedBlock`] and can be converted into
/// engine API execution payloads. /// engine API execution payloads.

View File

@ -19,6 +19,7 @@ reth-rpc-api.workspace = true
reth-storage-api.workspace = true reth-storage-api.workspace = true
reth-beacon-consensus.workspace = true reth-beacon-consensus.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-tasks.workspace = true reth-tasks.workspace = true
reth-rpc-types-compat.workspace = true reth-rpc-types-compat.workspace = true

View File

@ -4,7 +4,8 @@ use jsonrpsee_types::error::{
}; };
use reth_beacon_consensus::BeaconForkChoiceUpdateError; use reth_beacon_consensus::BeaconForkChoiceUpdateError;
use reth_engine_primitives::BeaconOnNewPayloadError; use reth_engine_primitives::BeaconOnNewPayloadError;
use reth_payload_primitives::{EngineObjectValidationError, PayloadBuilderError}; use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::EngineObjectValidationError;
use thiserror::Error; use thiserror::Error;
/// The Engine API result type /// The Engine API result type

View File

@ -10,7 +10,6 @@ reth.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-node-core.workspace = true reth-node-core.workspace = true
reth-primitives.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-basic-payload-builder.workspace = true reth-basic-payload-builder.workspace = true
reth-ethereum-payload-builder.workspace = true reth-ethereum-payload-builder.workspace = true