mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: NodePrimitivesProvider (#12855)
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -6603,7 +6603,6 @@ dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-signer",
|
||||
"alloy-signer-local",
|
||||
"auto_impl",
|
||||
"derive_more 1.0.0",
|
||||
"metrics",
|
||||
"parking_lot",
|
||||
@ -8409,7 +8408,6 @@ dependencies = [
|
||||
"derive_more 1.0.0",
|
||||
"op-alloy-consensus",
|
||||
"reth-codecs",
|
||||
"reth-node-types",
|
||||
"reth-primitives",
|
||||
"reth-primitives-traits",
|
||||
"rstest",
|
||||
@ -8444,6 +8442,7 @@ dependencies = [
|
||||
"reth-optimism-evm",
|
||||
"reth-optimism-forks",
|
||||
"reth-optimism-payload-builder",
|
||||
"reth-optimism-primitives",
|
||||
"reth-primitives",
|
||||
"reth-provider",
|
||||
"reth-rpc",
|
||||
|
||||
@ -4,8 +4,8 @@ use alloy_primitives::{BlockHash, BlockNumber};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_db::{static_file::BlockHashMask, tables};
|
||||
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
|
||||
use reth_node_types::{FullNodePrimitives, NodeTypesWithDB};
|
||||
use reth_primitives::StaticFileSegment;
|
||||
use reth_node_types::NodeTypesWithDB;
|
||||
use reth_primitives::{EthPrimitives, StaticFileSegment};
|
||||
use reth_provider::{
|
||||
providers::{NodeTypesForProvider, ProviderNodeTypes},
|
||||
ChainStateBlockReader, ChainStateBlockWriter, ProviderFactory, StaticFileProviderFactory,
|
||||
@ -15,25 +15,9 @@ use reth_storage_errors::provider::ProviderResult;
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within [`TreeExternals`].
|
||||
pub trait NodeTypesForTree:
|
||||
NodeTypesForProvider<
|
||||
Primitives: FullNodePrimitives<
|
||||
Block = reth_primitives::Block,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
>,
|
||||
>
|
||||
{
|
||||
}
|
||||
pub trait NodeTypesForTree: NodeTypesForProvider<Primitives = EthPrimitives> {}
|
||||
|
||||
impl<T> NodeTypesForTree for T where
|
||||
T: NodeTypesForProvider<
|
||||
Primitives: FullNodePrimitives<
|
||||
Block = reth_primitives::Block,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
>,
|
||||
>
|
||||
{
|
||||
}
|
||||
impl<T> NodeTypesForTree for T where T: NodeTypesForProvider<Primitives = EthPrimitives> {}
|
||||
|
||||
/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within [`TreeExternals`].
|
||||
pub trait TreeNodeTypes: ProviderNodeTypes + NodeTypesForTree {}
|
||||
|
||||
@ -6,10 +6,10 @@ use reth_blockchain_tree_api::{
|
||||
BlockValidationKind, BlockchainTreeEngine, BlockchainTreeViewer, CanonicalOutcome,
|
||||
InsertPayloadOk,
|
||||
};
|
||||
use reth_primitives::{Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader};
|
||||
use reth_primitives::{EthPrimitives, Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader};
|
||||
use reth_provider::{
|
||||
BlockchainTreePendingStateProvider, CanonStateNotificationSender, CanonStateNotifications,
|
||||
CanonStateSubscriptions, FullExecutionDataProvider,
|
||||
CanonStateSubscriptions, FullExecutionDataProvider, NodePrimitivesProvider,
|
||||
};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::collections::BTreeMap;
|
||||
@ -126,6 +126,10 @@ impl BlockchainTreePendingStateProvider for NoopBlockchainTree {
|
||||
}
|
||||
}
|
||||
|
||||
impl NodePrimitivesProvider for NoopBlockchainTree {
|
||||
type Primitives = EthPrimitives;
|
||||
}
|
||||
|
||||
impl CanonStateSubscriptions for NoopBlockchainTree {
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications {
|
||||
self.canon_state_notification_sender
|
||||
|
||||
@ -16,7 +16,7 @@ use reth_node_types::NodeTypesWithDB;
|
||||
use reth_primitives::{Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader};
|
||||
use reth_provider::{
|
||||
providers::ProviderNodeTypes, BlockchainTreePendingStateProvider, CanonStateNotifications,
|
||||
CanonStateSubscriptions, FullExecutionDataProvider, ProviderError,
|
||||
CanonStateSubscriptions, FullExecutionDataProvider, NodePrimitivesProvider, ProviderError,
|
||||
};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
@ -185,10 +185,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<N, E> CanonStateSubscriptions for ShareableBlockchainTree<N, E>
|
||||
impl<N, E> NodePrimitivesProvider for ShareableBlockchainTree<N, E>
|
||||
where
|
||||
N: ProviderNodeTypes,
|
||||
E: Send + Sync,
|
||||
{
|
||||
type Primitives = N::Primitives;
|
||||
}
|
||||
|
||||
impl<N, E> CanonStateSubscriptions for ShareableBlockchainTree<N, E>
|
||||
where
|
||||
N: TreeNodeTypes,
|
||||
E: Send + Sync,
|
||||
{
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications {
|
||||
trace!(target: "blockchain_tree", "Registered subscriber for canonical state");
|
||||
|
||||
@ -35,7 +35,6 @@ tokio-stream = { workspace = true, features = ["sync"] }
|
||||
tracing.workspace = true
|
||||
|
||||
# misc
|
||||
auto_impl.workspace = true
|
||||
derive_more.workspace = true
|
||||
metrics.workspace = true
|
||||
parking_lot.workspace = true
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
//! Canonical chain state notification trait and types.
|
||||
|
||||
use auto_impl::auto_impl;
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use reth_execution_types::{BlockReceipts, Chain};
|
||||
use reth_primitives::{NodePrimitives, SealedBlockWithSenders, SealedHeader};
|
||||
use reth_storage_api::NodePrimitivesProvider;
|
||||
use std::{
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
@ -25,21 +25,30 @@ pub type CanonStateNotificationSender<N = reth_primitives::EthPrimitives> =
|
||||
broadcast::Sender<CanonStateNotification<N>>;
|
||||
|
||||
/// A type that allows to register chain related event subscriptions.
|
||||
#[auto_impl(&, Arc)]
|
||||
pub trait CanonStateSubscriptions: Send + Sync {
|
||||
pub trait CanonStateSubscriptions: NodePrimitivesProvider + Send + Sync {
|
||||
/// Get notified when a new canonical chain was imported.
|
||||
///
|
||||
/// A canonical chain be one or more blocks, a reorg or a revert.
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications;
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications<Self::Primitives>;
|
||||
|
||||
/// Convenience method to get a stream of [`CanonStateNotification`].
|
||||
fn canonical_state_stream(&self) -> CanonStateNotificationStream {
|
||||
fn canonical_state_stream(&self) -> CanonStateNotificationStream<Self::Primitives> {
|
||||
CanonStateNotificationStream {
|
||||
st: BroadcastStream::new(self.subscribe_to_canonical_state()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: CanonStateSubscriptions> CanonStateSubscriptions for &T {
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications<Self::Primitives> {
|
||||
(*self).subscribe_to_canonical_state()
|
||||
}
|
||||
|
||||
fn canonical_state_stream(&self) -> CanonStateNotificationStream<Self::Primitives> {
|
||||
(*self).canonical_state_stream()
|
||||
}
|
||||
}
|
||||
|
||||
/// A Stream of [`CanonStateNotification`].
|
||||
#[derive(Debug)]
|
||||
#[pin_project::pin_project]
|
||||
|
||||
@ -14,9 +14,11 @@ use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS};
|
||||
use reth_execution_types::{Chain, ExecutionOutcome};
|
||||
use reth_primitives::{
|
||||
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
|
||||
BlockBody, NodePrimitives, Receipt, Receipts, SealedBlock, SealedBlockWithSenders,
|
||||
SealedHeader, Transaction, TransactionSigned, TransactionSignedEcRecovered,
|
||||
BlockBody, EthPrimitives, NodePrimitives, Receipt, Receipts, SealedBlock,
|
||||
SealedBlockWithSenders, SealedHeader, Transaction, TransactionSigned,
|
||||
TransactionSignedEcRecovered,
|
||||
};
|
||||
use reth_storage_api::NodePrimitivesProvider;
|
||||
use reth_trie::{root::state_root_unhashed, updates::TrieUpdates, HashedPostState};
|
||||
use revm::{db::BundleState, primitives::AccountInfo};
|
||||
use std::{
|
||||
@ -314,6 +316,10 @@ impl TestCanonStateSubscriptions {
|
||||
}
|
||||
}
|
||||
|
||||
impl NodePrimitivesProvider for TestCanonStateSubscriptions {
|
||||
type Primitives = EthPrimitives;
|
||||
}
|
||||
|
||||
impl CanonStateSubscriptions for TestCanonStateSubscriptions {
|
||||
/// Sets up a broadcast channel with a buffer size of 100.
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications {
|
||||
|
||||
@ -10,12 +10,12 @@ use reth_db::{init_db, open_db_read_only, DatabaseEnv};
|
||||
use reth_db_common::init::init_genesis;
|
||||
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
|
||||
use reth_evm::noop::NoopBlockExecutorProvider;
|
||||
use reth_node_api::FullNodePrimitives;
|
||||
use reth_node_builder::{NodeTypesWithDBAdapter, NodeTypesWithEngine};
|
||||
use reth_node_core::{
|
||||
args::{DatabaseArgs, DatadirArgs},
|
||||
dirs::{ChainPath, DataDirPath},
|
||||
};
|
||||
use reth_primitives::EthPrimitives;
|
||||
use reth_provider::{
|
||||
providers::{NodeTypesForProvider, StaticFileProvider},
|
||||
ProviderFactory, StaticFileProviderFactory,
|
||||
@ -196,22 +196,10 @@ impl AccessRights {
|
||||
/// Helper trait with a common set of requirements for the
|
||||
/// [`NodeTypes`](reth_node_builder::NodeTypes) in CLI.
|
||||
pub trait CliNodeTypes:
|
||||
NodeTypesWithEngine
|
||||
+ NodeTypesForProvider<
|
||||
Primitives: FullNodePrimitives<
|
||||
Block = reth_primitives::Block,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
>,
|
||||
>
|
||||
NodeTypesWithEngine + NodeTypesForProvider<Primitives = EthPrimitives>
|
||||
{
|
||||
}
|
||||
impl<N> CliNodeTypes for N where
|
||||
N: NodeTypesWithEngine
|
||||
+ NodeTypesForProvider<
|
||||
Primitives: FullNodePrimitives<
|
||||
Block = reth_primitives::Block,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
>,
|
||||
>
|
||||
N: NodeTypesWithEngine + NodeTypesForProvider<Primitives = EthPrimitives>
|
||||
{
|
||||
}
|
||||
|
||||
@ -6,8 +6,9 @@ use node::NodeTestContext;
|
||||
use reth::{
|
||||
args::{DiscoveryArgs, NetworkArgs, RpcServerArgs},
|
||||
blockchain_tree::externals::NodeTypesForTree,
|
||||
builder::{FullNodePrimitives, NodeBuilder, NodeConfig, NodeHandle},
|
||||
builder::{NodeBuilder, NodeConfig, NodeHandle},
|
||||
network::PeersHandleProvider,
|
||||
primitives::EthPrimitives,
|
||||
rpc::server_types::RpcModuleSelection,
|
||||
tasks::TaskManager,
|
||||
};
|
||||
@ -121,7 +122,7 @@ pub async fn setup_engine<N>(
|
||||
where
|
||||
N: Default
|
||||
+ Node<TmpNodeAdapter<N, BlockchainProvider2<NodeTypesWithDBAdapter<N, TmpDB>>>>
|
||||
+ NodeTypesWithEngine
|
||||
+ NodeTypesWithEngine<Primitives = EthPrimitives>
|
||||
+ NodeTypesForProvider,
|
||||
N::ComponentsBuilder: NodeComponentsBuilder<
|
||||
TmpNodeAdapter<N, BlockchainProvider2<NodeTypesWithDBAdapter<N, TmpDB>>>,
|
||||
@ -134,8 +135,6 @@ where
|
||||
LocalPayloadAttributesBuilder<N::ChainSpec>: PayloadAttributesBuilder<
|
||||
<<N as NodeTypesWithEngine>::Engine as PayloadTypes>::PayloadAttributes,
|
||||
>,
|
||||
N::Primitives:
|
||||
FullNodePrimitives<Block = reth_primitives::Block, BlockBody = reth_primitives::BlockBody>,
|
||||
{
|
||||
let tasks = TaskManager::current();
|
||||
let exec = tasks.executor();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::{marker::PhantomData, pin::Pin};
|
||||
|
||||
use alloy_consensus::{BlockHeader, Sealable};
|
||||
use alloy_consensus::BlockHeader;
|
||||
use alloy_primitives::{BlockHash, BlockNumber, Bytes, B256};
|
||||
use alloy_rpc_types_eth::BlockNumberOrTag;
|
||||
use eyre::Ok;
|
||||
@ -16,8 +16,9 @@ use reth::{
|
||||
},
|
||||
};
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_node_api::{Block, FullBlock, NodePrimitives};
|
||||
use reth_node_api::Block;
|
||||
use reth_node_builder::{rpc::RethRpcAddOns, NodeTypes, NodeTypesWithEngine};
|
||||
use reth_primitives::EthPrimitives;
|
||||
use reth_stages_types::StageId;
|
||||
use tokio_stream::StreamExt;
|
||||
use url::Url;
|
||||
@ -56,7 +57,7 @@ where
|
||||
Node::Types: NodeTypesWithEngine<
|
||||
ChainSpec: EthereumHardforks,
|
||||
Engine = Engine,
|
||||
Primitives: NodePrimitives<Block: FullBlock>,
|
||||
Primitives = EthPrimitives,
|
||||
>,
|
||||
Node::Network: PeersHandleProvider,
|
||||
AddOns: RethRpcAddOns<Node>,
|
||||
|
||||
@ -164,7 +164,7 @@ pub struct EthereumPoolBuilder {
|
||||
|
||||
impl<Types, Node> PoolBuilder<Node> for EthereumPoolBuilder
|
||||
where
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
||||
Node: FullNodeTypes<Types = Types>,
|
||||
{
|
||||
type Pool = EthTransactionPool<Node::Provider, DiskFileBlobStore>;
|
||||
@ -240,7 +240,7 @@ impl EthereumPayloadBuilder {
|
||||
pool: Pool,
|
||||
) -> eyre::Result<PayloadBuilderHandle<Types::Engine>>
|
||||
where
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
||||
Node: FullNodeTypes<Types = Types>,
|
||||
Evm: ConfigureEvm<Header = Header>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
@ -278,7 +278,7 @@ impl EthereumPayloadBuilder {
|
||||
|
||||
impl<Types, Node, Pool> PayloadServiceBuilder<Node, Pool> for EthereumPayloadBuilder
|
||||
where
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
||||
Node: FullNodeTypes<Types = Types>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
Types::Engine: PayloadTypes<
|
||||
|
||||
@ -28,7 +28,7 @@ use reth_node_core::{
|
||||
primitives::Head,
|
||||
};
|
||||
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
|
||||
use reth_primitives::EthereumHardforks;
|
||||
use reth_primitives::{EthPrimitives, EthereumHardforks};
|
||||
use reth_provider::providers::{BlockchainProvider2, ProviderNodeTypes};
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tokio_util::EventSender;
|
||||
@ -70,7 +70,8 @@ impl EngineNodeLauncher {
|
||||
|
||||
impl<Types, T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
|
||||
where
|
||||
Types: ProviderNodeTypes + NodeTypesWithEngine + PersistenceNodeTypes,
|
||||
Types:
|
||||
ProviderNodeTypes<Primitives = EthPrimitives> + NodeTypesWithEngine + PersistenceNodeTypes,
|
||||
T: FullNodeTypes<Types = Types, Provider = BlockchainProvider2<Types>>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
AO: RethRpcAddOns<NodeAdapter<T, CB::Components>>,
|
||||
|
||||
@ -10,7 +10,7 @@ use reth_exex::{
|
||||
DEFAULT_EXEX_MANAGER_CAPACITY,
|
||||
};
|
||||
use reth_node_api::{FullNodeComponents, NodeTypes};
|
||||
use reth_primitives::Head;
|
||||
use reth_primitives::{EthPrimitives, Head};
|
||||
use reth_provider::CanonStateSubscriptions;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
use tracing::Instrument;
|
||||
@ -25,7 +25,9 @@ pub struct ExExLauncher<Node: FullNodeComponents> {
|
||||
config_container: WithConfigs<<Node::Types as NodeTypes>::ChainSpec>,
|
||||
}
|
||||
|
||||
impl<Node: FullNodeComponents + Clone> ExExLauncher<Node> {
|
||||
impl<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>> + Clone>
|
||||
ExExLauncher<Node>
|
||||
{
|
||||
/// Create a new `ExExLauncher` with the given extensions.
|
||||
pub const fn new(
|
||||
head: Head,
|
||||
|
||||
@ -18,6 +18,7 @@ use reth_node_core::{
|
||||
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
|
||||
};
|
||||
use reth_payload_builder::PayloadStore;
|
||||
use reth_primitives::EthPrimitives;
|
||||
use reth_provider::providers::ProviderNodeTypes;
|
||||
use reth_rpc::{
|
||||
eth::{EthApiTypes, FullEthApiServer},
|
||||
@ -402,7 +403,7 @@ where
|
||||
impl<N, EthApi, EV> RpcAddOns<N, EthApi, EV>
|
||||
where
|
||||
N: FullNodeComponents<
|
||||
Types: ProviderNodeTypes,
|
||||
Types: ProviderNodeTypes<Primitives = EthPrimitives>,
|
||||
PayloadBuilder: PayloadBuilder<PayloadType = <N::Types as NodeTypesWithEngine>::Engine>,
|
||||
>,
|
||||
EthApi: EthApiTypes + FullEthApiServer + AddDevSigners + Unpin + 'static,
|
||||
@ -524,7 +525,7 @@ where
|
||||
impl<N, EthApi, EV> NodeAddOns<N> for RpcAddOns<N, EthApi, EV>
|
||||
where
|
||||
N: FullNodeComponents<
|
||||
Types: ProviderNodeTypes,
|
||||
Types: ProviderNodeTypes<Primitives = EthPrimitives>,
|
||||
PayloadBuilder: PayloadBuilder<PayloadType = <N::Types as NodeTypesWithEngine>::Engine>,
|
||||
>,
|
||||
EthApi: EthApiTypes + FullEthApiServer + AddDevSigners + Unpin + 'static,
|
||||
@ -566,7 +567,9 @@ pub trait EthApiBuilder<N: FullNodeComponents>: 'static {
|
||||
fn build(ctx: &EthApiBuilderCtx<N>) -> Self;
|
||||
}
|
||||
|
||||
impl<N: FullNodeComponents> EthApiBuilder<N> for EthApi<N::Provider, N::Pool, N::Network, N::Evm> {
|
||||
impl<N: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>> EthApiBuilder<N>
|
||||
for EthApi<N::Provider, N::Pool, N::Network, N::Evm>
|
||||
{
|
||||
fn build(ctx: &EthApiBuilderCtx<N>) -> Self {
|
||||
Self::with_spawner(ctx)
|
||||
}
|
||||
|
||||
@ -204,13 +204,13 @@ impl NodeTypesWithEngine for OpNode {
|
||||
#[derive(Debug)]
|
||||
pub struct OpAddOns<N: FullNodeComponents>(pub RpcAddOns<N, OpEthApi<N>, OpEngineValidatorBuilder>);
|
||||
|
||||
impl<N: FullNodeComponents> Default for OpAddOns<N> {
|
||||
impl<N: FullNodeComponents<Types: NodeTypes<Primitives = OpPrimitives>>> Default for OpAddOns<N> {
|
||||
fn default() -> Self {
|
||||
Self::new(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: FullNodeComponents> OpAddOns<N> {
|
||||
impl<N: FullNodeComponents<Types: NodeTypes<Primitives = OpPrimitives>>> OpAddOns<N> {
|
||||
/// Create a new instance with the given `sequencer_http` URL.
|
||||
pub fn new(sequencer_http: Option<String>) -> Self {
|
||||
Self(RpcAddOns::new(move |ctx| OpEthApi::new(ctx, sequencer_http), Default::default()))
|
||||
@ -418,7 +418,11 @@ where
|
||||
) -> eyre::Result<PayloadBuilderHandle<OpEngineTypes>>
|
||||
where
|
||||
Node: FullNodeTypes<
|
||||
Types: NodeTypesWithEngine<Engine = OpEngineTypes, ChainSpec = OpChainSpec>,
|
||||
Types: NodeTypesWithEngine<
|
||||
Engine = OpEngineTypes,
|
||||
ChainSpec = OpChainSpec,
|
||||
Primitives = OpPrimitives,
|
||||
>,
|
||||
>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
Evm: ConfigureEvm<Header = Header>,
|
||||
@ -453,8 +457,13 @@ where
|
||||
|
||||
impl<Node, Pool, Txs> PayloadServiceBuilder<Node, Pool> for OpPayloadBuilder<Txs>
|
||||
where
|
||||
Node:
|
||||
FullNodeTypes<Types: NodeTypesWithEngine<Engine = OpEngineTypes, ChainSpec = OpChainSpec>>,
|
||||
Node: FullNodeTypes<
|
||||
Types: NodeTypesWithEngine<
|
||||
Engine = OpEngineTypes,
|
||||
ChainSpec = OpChainSpec,
|
||||
Primitives = OpPrimitives,
|
||||
>,
|
||||
>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
Txs: OpPayloadTransactions,
|
||||
{
|
||||
|
||||
@ -13,7 +13,6 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-node-types.workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-codecs = { workspace = true, optional = true, features = ["optimism"] }
|
||||
@ -47,7 +46,6 @@ default = ["std", "reth-codec"]
|
||||
std = [
|
||||
"reth-primitives-traits/std",
|
||||
"reth-primitives/std",
|
||||
"reth-node-types/std",
|
||||
"reth-codecs/std",
|
||||
"alloy-consensus/std",
|
||||
"alloy-eips/std",
|
||||
|
||||
@ -6,26 +6,29 @@
|
||||
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
|
||||
)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod bedrock;
|
||||
pub mod transaction;
|
||||
|
||||
use reth_primitives::EthPrimitives;
|
||||
pub use transaction::{tx_type::OpTxType, OpTransaction};
|
||||
|
||||
use alloy_consensus::Header;
|
||||
use reth_node_types::NodePrimitives;
|
||||
use reth_primitives::{Block, BlockBody, Receipt, TransactionSigned};
|
||||
|
||||
/// Optimism primitive types.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
pub struct OpPrimitives;
|
||||
pub type OpPrimitives = EthPrimitives;
|
||||
|
||||
impl NodePrimitives for OpPrimitives {
|
||||
type Block = Block;
|
||||
type BlockHeader = Header;
|
||||
type BlockBody = BlockBody;
|
||||
type SignedTx = TransactionSigned;
|
||||
type TxType = OpTxType;
|
||||
type Receipt = Receipt;
|
||||
}
|
||||
// TODO: once we are ready for separating primitive types, introduce a separate `NodePrimitives`
|
||||
// implementation used exclusively by legacy engine.
|
||||
//
|
||||
// #[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
// pub struct OpPrimitives;
|
||||
//
|
||||
// impl NodePrimitives for OpPrimitives {
|
||||
// type Block = Block;
|
||||
// type BlockHeader = Header;
|
||||
// type BlockBody = BlockBody;
|
||||
// type SignedTx = TransactionSigned;
|
||||
// type TxType = OpTxType;
|
||||
// type Receipt = Receipt;
|
||||
// }
|
||||
|
||||
@ -33,6 +33,7 @@ reth-optimism-chainspec.workspace = true
|
||||
reth-optimism-consensus.workspace = true
|
||||
reth-optimism-evm.workspace = true
|
||||
reth-optimism-payload-builder.workspace = true
|
||||
reth-optimism-primitives.workspace = true
|
||||
reth-optimism-forks.workspace = true
|
||||
|
||||
# ethereum
|
||||
|
||||
@ -8,6 +8,7 @@ mod call;
|
||||
mod pending_block;
|
||||
|
||||
pub use receipt::{OpReceiptBuilder, OpReceiptFieldsBuilder};
|
||||
use reth_optimism_primitives::OpPrimitives;
|
||||
|
||||
use std::{fmt, sync::Arc};
|
||||
|
||||
@ -71,7 +72,11 @@ pub struct OpEthApi<N: RpcNodeCore> {
|
||||
impl<N> OpEthApi<N>
|
||||
where
|
||||
N: RpcNodeCore<
|
||||
Provider: BlockReaderIdExt + ChainSpecProvider + CanonStateSubscriptions + Clone + 'static,
|
||||
Provider: BlockReaderIdExt
|
||||
+ ChainSpecProvider
|
||||
+ CanonStateSubscriptions<Primitives = OpPrimitives>
|
||||
+ Clone
|
||||
+ 'static,
|
||||
>,
|
||||
{
|
||||
/// Creates a new instance for given context.
|
||||
|
||||
@ -6,7 +6,7 @@ use reth_db::transaction::DbTxMut;
|
||||
use reth_exex_types::FinishedExExHeight;
|
||||
use reth_provider::{
|
||||
providers::StaticFileProvider, BlockReader, DBProvider, DatabaseProviderFactory,
|
||||
PruneCheckpointWriter, StaticFileProviderFactory,
|
||||
NodePrimitivesProvider, PruneCheckpointWriter, StaticFileProviderFactory,
|
||||
};
|
||||
use reth_prune_types::PruneModes;
|
||||
use std::time::Duration;
|
||||
@ -82,7 +82,7 @@ impl PrunerBuilder {
|
||||
+ BlockReader<Transaction: Encodable2718>
|
||||
+ StaticFileProviderFactory,
|
||||
> + StaticFileProviderFactory<
|
||||
Primitives = <PF::ProviderRW as StaticFileProviderFactory>::Primitives,
|
||||
Primitives = <PF::ProviderRW as NodePrimitivesProvider>::Primitives,
|
||||
>,
|
||||
{
|
||||
let segments =
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use alloy_consensus::Header;
|
||||
use reth_evm::ConfigureEvm;
|
||||
use reth_primitives::EthPrimitives;
|
||||
use reth_provider::{BlockReader, CanonStateSubscriptions, EvmEnvProvider, StateProviderFactory};
|
||||
use reth_rpc::{EthFilter, EthPubSub};
|
||||
use reth_rpc_eth_api::EthApiTypes;
|
||||
@ -35,7 +36,7 @@ where
|
||||
+ 'static,
|
||||
Pool: Send + Sync + Clone + 'static,
|
||||
Network: Clone + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives = EthPrimitives> + Clone + 'static,
|
||||
EthApi: EthApiTypes + 'static,
|
||||
{
|
||||
/// Returns a new instance with handlers for `eth` namespace.
|
||||
|
||||
@ -42,7 +42,8 @@
|
||||
//! + ChangeSetReader,
|
||||
//! Pool: TransactionPool + Unpin + 'static,
|
||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||
//! Events: CanonStateSubscriptions + Clone + 'static,
|
||||
//! Events:
|
||||
//! CanonStateSubscriptions<Primitives = reth_primitives::EthPrimitives> + Clone + 'static,
|
||||
//! EvmConfig: ConfigureEvm<Header = Header>,
|
||||
//! BlockExecutor: BlockExecutorProvider,
|
||||
//! Consensus: reth_consensus::Consensus + Clone + 'static,
|
||||
@ -118,7 +119,8 @@
|
||||
//! + ChangeSetReader,
|
||||
//! Pool: TransactionPool + Unpin + 'static,
|
||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||
//! Events: CanonStateSubscriptions + Clone + 'static,
|
||||
//! Events:
|
||||
//! CanonStateSubscriptions<Primitives = reth_primitives::EthPrimitives> + Clone + 'static,
|
||||
//! EngineApi: EngineApiServer<EngineT>,
|
||||
//! EngineT: EngineTypes,
|
||||
//! EvmConfig: ConfigureEvm<Header = Header>,
|
||||
@ -190,6 +192,7 @@ use reth_consensus::Consensus;
|
||||
use reth_engine_primitives::EngineTypes;
|
||||
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvm};
|
||||
use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers};
|
||||
use reth_primitives::EthPrimitives;
|
||||
use reth_provider::{
|
||||
AccountReader, BlockReader, CanonStateSubscriptions, ChainSpecProvider, ChangeSetReader,
|
||||
EvmEnvProvider, FullRpcProvider, StateProviderFactory,
|
||||
@ -264,7 +267,7 @@ where
|
||||
Pool: TransactionPool + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives = EthPrimitives> + Clone + 'static,
|
||||
EvmConfig: ConfigureEvm<Header = alloy_consensus::Header>,
|
||||
EthApi: FullEthApiServer,
|
||||
BlockExecutor: BlockExecutorProvider,
|
||||
@ -617,7 +620,7 @@ where
|
||||
Pool: TransactionPool + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives = EthPrimitives> + Clone + 'static,
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
BlockExecutor: BlockExecutorProvider,
|
||||
Consensus: reth_consensus::Consensus + Clone + 'static,
|
||||
@ -920,7 +923,7 @@ where
|
||||
+ 'static,
|
||||
Pool: Send + Sync + Clone + 'static,
|
||||
Network: Clone + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives = EthPrimitives> + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
EthApi: EthApiTypes + 'static,
|
||||
BlockExecutor: BlockExecutorProvider,
|
||||
@ -1282,7 +1285,7 @@ where
|
||||
Pool: TransactionPool + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives = EthPrimitives> + Clone + 'static,
|
||||
EthApi: FullEthApiServer,
|
||||
BlockExecutor: BlockExecutorProvider,
|
||||
Consensus: reth_consensus::Consensus + Clone + 'static,
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use reth_chain_state::CanonStateSubscriptions;
|
||||
use reth_chainspec::ChainSpecProvider;
|
||||
use reth_primitives::NodePrimitives;
|
||||
use reth_storage_api::BlockReaderIdExt;
|
||||
use reth_tasks::TaskSpawner;
|
||||
|
||||
@ -41,7 +42,8 @@ where
|
||||
where
|
||||
Provider: ChainSpecProvider + 'static,
|
||||
Tasks: TaskSpawner,
|
||||
Events: CanonStateSubscriptions,
|
||||
Events:
|
||||
CanonStateSubscriptions<Primitives: NodePrimitives<Receipt = reth_primitives::Receipt>>,
|
||||
{
|
||||
let fee_history_cache =
|
||||
FeeHistoryCache::new(self.cache.clone(), self.config.fee_history_cache);
|
||||
|
||||
@ -16,7 +16,7 @@ use futures::{
|
||||
use metrics::atomics::AtomicU64;
|
||||
use reth_chain_state::CanonStateNotification;
|
||||
use reth_chainspec::{ChainSpecProvider, EthChainSpec};
|
||||
use reth_primitives::{Receipt, SealedBlock, TransactionSigned};
|
||||
use reth_primitives::{NodePrimitives, Receipt, SealedBlock, TransactionSigned};
|
||||
use reth_storage_api::BlockReaderIdExt;
|
||||
use revm_primitives::{calc_blob_gasprice, calc_excess_blob_gas};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -205,13 +205,14 @@ struct FeeHistoryCacheInner {
|
||||
|
||||
/// Awaits for new chain events and directly inserts them into the cache so they're available
|
||||
/// immediately before they need to be fetched from disk.
|
||||
pub async fn fee_history_cache_new_blocks_task<St, Provider>(
|
||||
pub async fn fee_history_cache_new_blocks_task<St, Provider, N>(
|
||||
fee_history_cache: FeeHistoryCache,
|
||||
mut events: St,
|
||||
provider: Provider,
|
||||
) where
|
||||
St: Stream<Item = CanonStateNotification> + Unpin + 'static,
|
||||
St: Stream<Item = CanonStateNotification<N>> + Unpin + 'static,
|
||||
Provider: BlockReaderIdExt + ChainSpecProvider + 'static,
|
||||
N: NodePrimitives<Receipt = reth_primitives::Receipt>,
|
||||
{
|
||||
// We're listening for new blocks emitted when the node is in live sync.
|
||||
// If the node transitions to stage sync, we need to fetch the missing blocks
|
||||
|
||||
@ -7,6 +7,7 @@ use alloy_eips::BlockNumberOrTag;
|
||||
use alloy_network::Ethereum;
|
||||
use alloy_primitives::U256;
|
||||
use derive_more::Deref;
|
||||
use reth_primitives::NodePrimitives;
|
||||
use reth_provider::{BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider};
|
||||
use reth_rpc_eth_api::{
|
||||
helpers::{EthSigner, SpawnBlocking},
|
||||
@ -102,7 +103,8 @@ where
|
||||
) -> Self
|
||||
where
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
Events: CanonStateSubscriptions,
|
||||
Events:
|
||||
CanonStateSubscriptions<Primitives: NodePrimitives<Receipt = reth_primitives::Receipt>>,
|
||||
{
|
||||
let blocking_task_pool =
|
||||
BlockingTaskPool::build().expect("failed to build blocking task pool");
|
||||
|
||||
@ -15,6 +15,7 @@ use jsonrpsee::{
|
||||
server::SubscriptionMessage, types::ErrorObject, PendingSubscriptionSink, SubscriptionSink,
|
||||
};
|
||||
use reth_network_api::NetworkInfo;
|
||||
use reth_primitives::NodePrimitives;
|
||||
use reth_provider::{BlockReader, CanonStateSubscriptions, EvmEnvProvider};
|
||||
use reth_rpc_eth_api::{pubsub::EthPubSubApiServer, TransactionCompat};
|
||||
use reth_rpc_eth_types::logs_utils;
|
||||
@ -84,7 +85,9 @@ impl<Provider, Pool, Events, Network, Eth> EthPubSubApiServer<Eth::Transaction>
|
||||
where
|
||||
Provider: BlockReader + EvmEnvProvider + Clone + 'static,
|
||||
Pool: TransactionPool + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives: NodePrimitives<Receipt = reth_primitives::Receipt>>
|
||||
+ Clone
|
||||
+ 'static,
|
||||
Network: NetworkInfo + Clone + 'static,
|
||||
Eth: TransactionCompat + 'static,
|
||||
{
|
||||
@ -117,7 +120,9 @@ async fn handle_accepted<Provider, Pool, Events, Network, Eth>(
|
||||
where
|
||||
Provider: BlockReader + EvmEnvProvider + Clone + 'static,
|
||||
Pool: TransactionPool + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives: NodePrimitives<Receipt = reth_primitives::Receipt>>
|
||||
+ Clone
|
||||
+ 'static,
|
||||
Network: NetworkInfo + Clone + 'static,
|
||||
Eth: TransactionCompat,
|
||||
{
|
||||
@ -333,7 +338,8 @@ where
|
||||
impl<Provider, Pool, Events, Network> EthPubSubInner<Provider, Pool, Events, Network>
|
||||
where
|
||||
Provider: BlockReader + EvmEnvProvider + 'static,
|
||||
Events: CanonStateSubscriptions + 'static,
|
||||
Events: CanonStateSubscriptions<Primitives: NodePrimitives<Receipt = reth_primitives::Receipt>>
|
||||
+ 'static,
|
||||
Network: NetworkInfo + 'static,
|
||||
Pool: 'static,
|
||||
{
|
||||
|
||||
@ -27,14 +27,14 @@ use reth_evm::ConfigureEvmEnv;
|
||||
use reth_execution_types::ExecutionOutcome;
|
||||
use reth_node_types::{BlockTy, NodeTypesWithDB, TxTy};
|
||||
use reth_primitives::{
|
||||
Account, Block, BlockWithSenders, NodePrimitives, Receipt, SealedBlock, SealedBlockFor,
|
||||
SealedBlockWithSenders, SealedHeader, StorageEntry, TransactionMeta, TransactionSigned,
|
||||
TransactionSignedNoHash,
|
||||
Account, Block, BlockWithSenders, EthPrimitives, NodePrimitives, Receipt, SealedBlock,
|
||||
SealedBlockFor, SealedBlockWithSenders, SealedHeader, StorageEntry, TransactionMeta,
|
||||
TransactionSigned, TransactionSignedNoHash,
|
||||
};
|
||||
use reth_primitives_traits::BlockBody as _;
|
||||
use reth_prune_types::{PruneCheckpoint, PruneSegment};
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
use reth_storage_api::{DBProvider, StorageChangeSetReader};
|
||||
use reth_storage_api::{DBProvider, NodePrimitivesProvider, StorageChangeSetReader};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use revm::primitives::{BlockEnv, CfgEnvWithHandlerCfg};
|
||||
use std::{
|
||||
@ -150,6 +150,10 @@ impl<N: ProviderNodeTypes> BlockchainProvider2<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB> NodePrimitivesProvider for BlockchainProvider2<N> {
|
||||
type Primitives = N::Primitives;
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> DatabaseProviderFactory for BlockchainProvider2<N> {
|
||||
type DB = N::DB;
|
||||
type Provider = <ProviderFactory<N> as DatabaseProviderFactory>::Provider;
|
||||
@ -165,8 +169,6 @@ impl<N: ProviderNodeTypes> DatabaseProviderFactory for BlockchainProvider2<N> {
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> StaticFileProviderFactory for BlockchainProvider2<N> {
|
||||
type Primitives = N::Primitives;
|
||||
|
||||
fn static_file_provider(&self) -> StaticFileProvider<Self::Primitives> {
|
||||
self.database.static_file_provider()
|
||||
}
|
||||
@ -711,8 +713,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB> CanonStateSubscriptions for BlockchainProvider2<N> {
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications {
|
||||
impl<N: NodeTypesWithDB<Primitives = EthPrimitives>> CanonStateSubscriptions
|
||||
for BlockchainProvider2<N>
|
||||
{
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications<Self::Primitives> {
|
||||
self.canonical_in_memory_state.subscribe_canon_state()
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,9 @@ use reth_primitives::{
|
||||
use reth_primitives_traits::{Block, BlockBody};
|
||||
use reth_prune_types::{PruneCheckpoint, PruneSegment};
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
use reth_storage_api::{DatabaseProviderFactory, StateProvider, StorageChangeSetReader};
|
||||
use reth_storage_api::{
|
||||
DatabaseProviderFactory, NodePrimitivesProvider, StateProvider, StorageChangeSetReader,
|
||||
};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use revm::{
|
||||
db::states::PlainStorageRevert,
|
||||
@ -613,9 +615,11 @@ impl<N: ProviderNodeTypes> ConsistentProvider<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> StaticFileProviderFactory for ConsistentProvider<N> {
|
||||
impl<N: ProviderNodeTypes> NodePrimitivesProvider for ConsistentProvider<N> {
|
||||
type Primitives = N::Primitives;
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> StaticFileProviderFactory for ConsistentProvider<N> {
|
||||
fn static_file_provider(&self) -> StaticFileProvider<N::Primitives> {
|
||||
self.storage_provider.static_file_provider()
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ use reth_primitives::{
|
||||
};
|
||||
use reth_prune_types::{PruneCheckpoint, PruneModes, PruneSegment};
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
use reth_storage_api::TryIntoHistoricalStateProvider;
|
||||
use reth_storage_api::{NodePrimitivesProvider, TryIntoHistoricalStateProvider};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use revm::primitives::{BlockEnv, CfgEnvWithHandlerCfg};
|
||||
use std::{
|
||||
@ -202,6 +202,10 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB> NodePrimitivesProvider for ProviderFactory<N> {
|
||||
type Primitives = N::Primitives;
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> DatabaseProviderFactory for ProviderFactory<N> {
|
||||
type DB = N::DB;
|
||||
type Provider = DatabaseProvider<<N::DB as Database>::TX, N>;
|
||||
@ -217,8 +221,6 @@ impl<N: ProviderNodeTypes> DatabaseProviderFactory for ProviderFactory<N> {
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB> StaticFileProviderFactory for ProviderFactory<N> {
|
||||
type Primitives = N::Primitives;
|
||||
|
||||
/// Returns static file provider
|
||||
fn static_file_provider(&self) -> StaticFileProvider<Self::Primitives> {
|
||||
self.static_file_provider.clone()
|
||||
|
||||
@ -56,7 +56,8 @@ use reth_primitives_traits::{Block as _, BlockBody as _, SignedTransaction};
|
||||
use reth_prune_types::{PruneCheckpoint, PruneModes, PruneSegment};
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
use reth_storage_api::{
|
||||
BlockBodyReader, StateProvider, StorageChangeSetReader, TryIntoHistoricalStateProvider,
|
||||
BlockBodyReader, NodePrimitivesProvider, StateProvider, StorageChangeSetReader,
|
||||
TryIntoHistoricalStateProvider,
|
||||
};
|
||||
use reth_storage_errors::provider::{ProviderResult, RootMismatch};
|
||||
use reth_trie::{
|
||||
@ -207,9 +208,11 @@ impl<TX: DbTx + 'static, N: NodeTypes> DatabaseProvider<TX, N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<TX, N: NodeTypes> StaticFileProviderFactory for DatabaseProvider<TX, N> {
|
||||
impl<TX, N: NodeTypes> NodePrimitivesProvider for DatabaseProvider<TX, N> {
|
||||
type Primitives = N::Primitives;
|
||||
}
|
||||
|
||||
impl<TX, N: NodeTypes> StaticFileProviderFactory for DatabaseProvider<TX, N> {
|
||||
/// Returns a static file provider
|
||||
fn static_file_provider(&self) -> StaticFileProvider<Self::Primitives> {
|
||||
self.static_file_provider.clone()
|
||||
@ -2678,7 +2681,7 @@ impl<TX: DbTxMut + DbTx + 'static, N: NodeTypesForProvider + 'static> BlockExecu
|
||||
&self,
|
||||
block: BlockNumber,
|
||||
remove_transactions_from: StorageLocation,
|
||||
) -> ProviderResult<Chain> {
|
||||
) -> ProviderResult<Chain<Self::Primitives>> {
|
||||
let range = block + 1..=self.last_block_number()?;
|
||||
|
||||
self.unwind_trie_state_range(range.clone())?;
|
||||
|
||||
@ -3,9 +3,10 @@ use crate::{
|
||||
BlockSource, BlockchainTreePendingStateProvider, CanonChainTracker, CanonStateNotifications,
|
||||
CanonStateSubscriptions, ChainSpecProvider, ChainStateBlockReader, ChangeSetReader,
|
||||
DatabaseProviderFactory, EvmEnvProvider, FullExecutionDataProvider, HeaderProvider,
|
||||
ProviderError, PruneCheckpointReader, ReceiptProvider, ReceiptProviderIdExt,
|
||||
StageCheckpointReader, StateProviderBox, StateProviderFactory, StaticFileProviderFactory,
|
||||
TransactionVariant, TransactionsProvider, TreeViewer, WithdrawalsProvider,
|
||||
NodePrimitivesProvider, ProviderError, PruneCheckpointReader, ReceiptProvider,
|
||||
ReceiptProviderIdExt, StageCheckpointReader, StateProviderBox, StateProviderFactory,
|
||||
StaticFileProviderFactory, TransactionVariant, TransactionsProvider, TreeViewer,
|
||||
WithdrawalsProvider,
|
||||
};
|
||||
use alloy_consensus::Header;
|
||||
use alloy_eips::{
|
||||
@ -80,6 +81,7 @@ where
|
||||
BlockHeader = alloy_consensus::Header,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
Block = reth_primitives::Block,
|
||||
Receipt = reth_primitives::Receipt,
|
||||
>,
|
||||
>,
|
||||
{
|
||||
@ -94,6 +96,7 @@ impl<T> NodeTypesForProvider for T where
|
||||
BlockHeader = alloy_consensus::Header,
|
||||
BlockBody = reth_primitives::BlockBody,
|
||||
Block = reth_primitives::Block,
|
||||
Receipt = reth_primitives::Receipt,
|
||||
>,
|
||||
>
|
||||
{
|
||||
@ -118,7 +121,7 @@ pub struct BlockchainProvider<N: NodeTypesWithDB> {
|
||||
/// Provider type used to access the database.
|
||||
database: ProviderFactory<N>,
|
||||
/// The blockchain tree instance.
|
||||
tree: Arc<dyn TreeViewer>,
|
||||
tree: Arc<dyn TreeViewer<Primitives = N::Primitives>>,
|
||||
/// Tracks the chain info wrt forkchoice updates
|
||||
chain_info: ChainInfoTracker<reth_primitives::EthPrimitives>,
|
||||
}
|
||||
@ -136,7 +139,7 @@ impl<N: ProviderNodeTypes> Clone for BlockchainProvider<N> {
|
||||
impl<N: NodeTypesWithDB> BlockchainProvider<N> {
|
||||
/// Sets the treeviewer for the provider.
|
||||
#[doc(hidden)]
|
||||
pub fn with_tree(mut self, tree: Arc<dyn TreeViewer>) -> Self {
|
||||
pub fn with_tree(mut self, tree: Arc<dyn TreeViewer<Primitives = N::Primitives>>) -> Self {
|
||||
self.tree = tree;
|
||||
self
|
||||
}
|
||||
@ -148,7 +151,7 @@ impl<N: ProviderNodeTypes> BlockchainProvider<N> {
|
||||
/// if it exists.
|
||||
pub fn with_blocks(
|
||||
database: ProviderFactory<N>,
|
||||
tree: Arc<dyn TreeViewer>,
|
||||
tree: Arc<dyn TreeViewer<Primitives = N::Primitives>>,
|
||||
latest: SealedHeader,
|
||||
finalized: Option<SealedHeader>,
|
||||
safe: Option<SealedHeader>,
|
||||
@ -158,7 +161,10 @@ impl<N: ProviderNodeTypes> BlockchainProvider<N> {
|
||||
|
||||
/// Create a new provider using only the database and the tree, fetching the latest header from
|
||||
/// the database to initialize the provider.
|
||||
pub fn new(database: ProviderFactory<N>, tree: Arc<dyn TreeViewer>) -> ProviderResult<Self> {
|
||||
pub fn new(
|
||||
database: ProviderFactory<N>,
|
||||
tree: Arc<dyn TreeViewer<Primitives = N::Primitives>>,
|
||||
) -> ProviderResult<Self> {
|
||||
let provider = database.provider()?;
|
||||
let best = provider.chain_info()?;
|
||||
let latest_header = provider
|
||||
@ -225,6 +231,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> NodePrimitivesProvider for BlockchainProvider<N> {
|
||||
type Primitives = N::Primitives;
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> DatabaseProviderFactory for BlockchainProvider<N> {
|
||||
type DB = N::DB;
|
||||
type Provider = <ProviderFactory<N> as DatabaseProviderFactory>::Provider;
|
||||
@ -240,8 +250,6 @@ impl<N: ProviderNodeTypes> DatabaseProviderFactory for BlockchainProvider<N> {
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> StaticFileProviderFactory for BlockchainProvider<N> {
|
||||
type Primitives = N::Primitives;
|
||||
|
||||
fn static_file_provider(&self) -> StaticFileProvider<Self::Primitives> {
|
||||
self.database.static_file_provider()
|
||||
}
|
||||
@ -944,7 +952,7 @@ impl<N: ProviderNodeTypes> BlockchainTreePendingStateProvider for BlockchainProv
|
||||
}
|
||||
|
||||
impl<N: ProviderNodeTypes> CanonStateSubscriptions for BlockchainProvider<N> {
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications {
|
||||
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications<Self::Primitives> {
|
||||
self.tree.subscribe_to_canonical_state()
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ use reth_primitives::{
|
||||
};
|
||||
use reth_prune_types::{PruneCheckpoint, PruneSegment};
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
use reth_storage_api::{StateProofProvider, StorageRootProvider};
|
||||
use reth_storage_api::{NodePrimitivesProvider, StateProofProvider, StorageRootProvider};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use reth_trie::{
|
||||
updates::TrieUpdates, AccountProof, HashedPostState, HashedStorage, MultiProof, TrieInput,
|
||||
@ -559,9 +559,11 @@ impl PruneCheckpointReader for NoopProvider {
|
||||
}
|
||||
}
|
||||
|
||||
impl StaticFileProviderFactory for NoopProvider {
|
||||
impl NodePrimitivesProvider for NoopProvider {
|
||||
type Primitives = EthPrimitives;
|
||||
}
|
||||
|
||||
impl StaticFileProviderFactory for NoopProvider {
|
||||
fn static_file_provider(&self) -> StaticFileProvider<Self::Primitives> {
|
||||
StaticFileProvider::read_only(PathBuf::default(), false).unwrap()
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
use alloy_primitives::BlockNumber;
|
||||
use reth_db_api::models::StoredBlockBodyIndices;
|
||||
use reth_execution_types::{Chain, ExecutionOutcome};
|
||||
use reth_node_types::NodePrimitives;
|
||||
use reth_primitives::SealedBlockWithSenders;
|
||||
use reth_storage_api::NodePrimitivesProvider;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use reth_trie::{updates::TrieUpdates, HashedPostStateSorted};
|
||||
|
||||
@ -28,9 +30,10 @@ impl StorageLocation {
|
||||
}
|
||||
}
|
||||
|
||||
/// BlockExecution Writer
|
||||
#[auto_impl::auto_impl(&, Arc, Box)]
|
||||
pub trait BlockExecutionWriter: BlockWriter + Send + Sync {
|
||||
/// `BlockExecution` Writer
|
||||
pub trait BlockExecutionWriter:
|
||||
NodePrimitivesProvider<Primitives: NodePrimitives<Block = Self::Block>> + BlockWriter + Send + Sync
|
||||
{
|
||||
/// Take all of the blocks above the provided number and their execution result
|
||||
///
|
||||
/// The passed block number will stay in the database.
|
||||
@ -38,7 +41,7 @@ pub trait BlockExecutionWriter: BlockWriter + Send + Sync {
|
||||
&self,
|
||||
block: BlockNumber,
|
||||
remove_transactions_from: StorageLocation,
|
||||
) -> ProviderResult<Chain>;
|
||||
) -> ProviderResult<Chain<Self::Primitives>>;
|
||||
|
||||
/// Remove all of the blocks above the provided number and their execution result
|
||||
///
|
||||
@ -50,6 +53,24 @@ pub trait BlockExecutionWriter: BlockWriter + Send + Sync {
|
||||
) -> ProviderResult<()>;
|
||||
}
|
||||
|
||||
impl<T: BlockExecutionWriter> BlockExecutionWriter for &T {
|
||||
fn take_block_and_execution_above(
|
||||
&self,
|
||||
block: BlockNumber,
|
||||
remove_transactions_from: StorageLocation,
|
||||
) -> ProviderResult<Chain<Self::Primitives>> {
|
||||
(*self).take_block_and_execution_above(block, remove_transactions_from)
|
||||
}
|
||||
|
||||
fn remove_block_and_execution_above(
|
||||
&self,
|
||||
block: BlockNumber,
|
||||
remove_transactions_from: StorageLocation,
|
||||
) -> ProviderResult<()> {
|
||||
(*self).remove_block_and_execution_above(block, remove_transactions_from)
|
||||
}
|
||||
}
|
||||
|
||||
/// This just receives state, or [`ExecutionOutcome`], from the provider
|
||||
#[auto_impl::auto_impl(&, Arc, Box)]
|
||||
pub trait StateReader: Send + Sync {
|
||||
|
||||
@ -19,7 +19,7 @@ pub trait FullProvider<N: NodeTypesWithDB>:
|
||||
+ EvmEnvProvider
|
||||
+ ChainSpecProvider<ChainSpec = N::ChainSpec>
|
||||
+ ChangeSetReader
|
||||
+ CanonStateSubscriptions
|
||||
+ CanonStateSubscriptions<Primitives = N::Primitives>
|
||||
+ ForkChoiceSubscriptions
|
||||
+ StageCheckpointReader
|
||||
+ Clone
|
||||
@ -37,7 +37,7 @@ impl<T, N: NodeTypesWithDB> FullProvider<N> for T where
|
||||
+ EvmEnvProvider
|
||||
+ ChainSpecProvider<ChainSpec = N::ChainSpec>
|
||||
+ ChangeSetReader
|
||||
+ CanonStateSubscriptions
|
||||
+ CanonStateSubscriptions<Primitives = N::Primitives>
|
||||
+ ForkChoiceSubscriptions
|
||||
+ StageCheckpointReader
|
||||
+ Clone
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
use reth_node_types::NodePrimitives;
|
||||
use reth_storage_api::NodePrimitivesProvider;
|
||||
|
||||
use crate::providers::StaticFileProvider;
|
||||
|
||||
/// Static file provider factory.
|
||||
pub trait StaticFileProviderFactory {
|
||||
/// The network primitives type [`StaticFileProvider`] is using.
|
||||
type Primitives: NodePrimitives;
|
||||
|
||||
pub trait StaticFileProviderFactory: NodePrimitivesProvider {
|
||||
/// Create new instance of static file provider.
|
||||
fn static_file_provider(&self) -> StaticFileProvider<Self::Primitives>;
|
||||
}
|
||||
|
||||
@ -70,3 +70,6 @@ pub use stats::*;
|
||||
|
||||
mod legacy;
|
||||
pub use legacy::*;
|
||||
|
||||
mod primitives;
|
||||
pub use primitives::*;
|
||||
|
||||
8
crates/storage/storage-api/src/primitives.rs
Normal file
8
crates/storage/storage-api/src/primitives.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use reth_primitives::NodePrimitives;
|
||||
|
||||
/// Provider implementation that knows configured [`NodePrimitives`].
|
||||
#[auto_impl::auto_impl(&, Arc, Box)]
|
||||
pub trait NodePrimitivesProvider {
|
||||
/// The node primitive types.
|
||||
type Primitives: NodePrimitives;
|
||||
}
|
||||
@ -300,7 +300,11 @@ pub struct CustomPayloadServiceBuilder;
|
||||
impl<Node, Pool> PayloadServiceBuilder<Node, Pool> for CustomPayloadServiceBuilder
|
||||
where
|
||||
Node: FullNodeTypes<
|
||||
Types: NodeTypesWithEngine<Engine = CustomEngineTypes, ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<
|
||||
Engine = CustomEngineTypes,
|
||||
ChainSpec = ChainSpec,
|
||||
Primitives = EthPrimitives,
|
||||
>,
|
||||
>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ use reth_node_ethereum::{
|
||||
node::{EthereumAddOns, EthereumPayloadBuilder},
|
||||
BasicBlockExecutorProvider, EthExecutionStrategyFactory, EthereumNode,
|
||||
};
|
||||
use reth_primitives::TransactionSigned;
|
||||
use reth_primitives::{EthPrimitives, TransactionSigned};
|
||||
use reth_tracing::{RethTracer, Tracer};
|
||||
use std::{convert::Infallible, sync::Arc};
|
||||
|
||||
@ -181,7 +181,7 @@ pub struct MyPayloadBuilder {
|
||||
|
||||
impl<Types, Node, Pool> PayloadServiceBuilder<Node, Pool> for MyPayloadBuilder
|
||||
where
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
|
||||
Node: FullNodeTypes<Types = Types>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
Types::Engine: PayloadTypes<
|
||||
|
||||
@ -7,6 +7,7 @@ use reth::{
|
||||
builder::{components::PoolBuilder, BuilderContext, FullNodeTypes},
|
||||
chainspec::ChainSpec,
|
||||
cli::Cli,
|
||||
primitives::EthPrimitives,
|
||||
providers::CanonStateSubscriptions,
|
||||
transaction_pool::{
|
||||
blobstore::InMemoryBlobStore, EthTransactionPool, TransactionValidationTaskExecutor,
|
||||
@ -47,7 +48,7 @@ pub struct CustomPoolBuilder {
|
||||
/// This will be used to build the transaction pool and its maintenance tasks during launch.
|
||||
impl<Node> PoolBuilder<Node> for CustomPoolBuilder
|
||||
where
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec, Primitives = EthPrimitives>>,
|
||||
{
|
||||
type Pool = EthTransactionPool<Node::Provider, InMemoryBlobStore>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user