mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-12 16:05:08 -05:00
feat(storage): replace Tree generic with Arc<dyn TreeViewer> (#7810)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -63,11 +63,9 @@ use tokio::sync::{mpsc::unbounded_channel, oneshot};
|
||||
|
||||
/// The builtin provider type of the reth node.
|
||||
// Note: we need to hardcode this because custom components might depend on it in associated types.
|
||||
type RethFullProviderType<DB, Evm> =
|
||||
BlockchainProvider<DB, ShareableBlockchainTree<DB, EvmProcessorFactory<Evm>>>;
|
||||
type RethFullProviderType<DB> = BlockchainProvider<DB>;
|
||||
|
||||
type RethFullAdapter<DB, N> =
|
||||
FullNodeTypesAdapter<N, DB, RethFullProviderType<DB, <N as NodeTypes>::Evm>>;
|
||||
type RethFullAdapter<DB, N> = FullNodeTypesAdapter<N, DB, RethFullProviderType<DB>>;
|
||||
|
||||
#[cfg_attr(doc, aquamarine::aquamarine)]
|
||||
/// Declaratively construct a node.
|
||||
@@ -278,7 +276,7 @@ where
|
||||
>,
|
||||
>
|
||||
where
|
||||
N: Node<FullNodeTypesAdapter<N, DB, RethFullProviderType<DB, <N as NodeTypes>::Evm>>>,
|
||||
N: Node<FullNodeTypesAdapter<N, DB, RethFullProviderType<DB>>>,
|
||||
N::PoolBuilder: PoolBuilder<RethFullAdapter<DB, N>>,
|
||||
N::NetworkBuilder: crate::components::NetworkBuilder<
|
||||
RethFullAdapter<DB, N>,
|
||||
@@ -308,15 +306,14 @@ where
|
||||
Types,
|
||||
Components,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
>
|
||||
where
|
||||
Components: NodeComponentsBuilder<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
>,
|
||||
Components:
|
||||
NodeComponentsBuilder<FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>>,
|
||||
{
|
||||
NodeBuilder {
|
||||
config: self.config,
|
||||
@@ -339,7 +336,7 @@ impl<DB, Types, Components>
|
||||
Types,
|
||||
Components,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -347,9 +344,7 @@ impl<DB, Types, Components>
|
||||
where
|
||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
||||
Types: NodeTypes,
|
||||
Components: NodeComponentsBuilder<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
>,
|
||||
Components: NodeComponentsBuilder<FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>>,
|
||||
{
|
||||
/// Apply a function to the components builder.
|
||||
pub fn map_components(self, f: impl FnOnce(Components) -> Components) -> Self {
|
||||
@@ -371,7 +366,7 @@ where
|
||||
where
|
||||
F: Fn(
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
) -> eyre::Result<()>
|
||||
@@ -388,7 +383,7 @@ where
|
||||
F: Fn(
|
||||
FullNode<
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -407,7 +402,7 @@ where
|
||||
RpcContext<
|
||||
'_,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -427,7 +422,7 @@ where
|
||||
RpcContext<
|
||||
'_,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -449,7 +444,7 @@ where
|
||||
F: Fn(
|
||||
ExExContext<
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -476,7 +471,7 @@ where
|
||||
) -> eyre::Result<
|
||||
NodeHandle<
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -556,7 +551,7 @@ where
|
||||
.with_sync_metrics_tx(sync_metrics_tx.clone());
|
||||
|
||||
let canon_state_notification_sender = tree.canon_state_notification_sender();
|
||||
let blockchain_tree = ShareableBlockchainTree::new(tree);
|
||||
let blockchain_tree = Arc::new(ShareableBlockchainTree::new(tree));
|
||||
debug!(target: "reth::cli", "configured blockchain tree");
|
||||
|
||||
// fetch the head block from the database
|
||||
@@ -995,7 +990,7 @@ where
|
||||
>,
|
||||
>
|
||||
where
|
||||
N: Node<FullNodeTypesAdapter<N, DB, RethFullProviderType<DB, <N as NodeTypes>::Evm>>>,
|
||||
N: Node<FullNodeTypesAdapter<N, DB, RethFullProviderType<DB>>>,
|
||||
N::PoolBuilder: PoolBuilder<RethFullAdapter<DB, N>>,
|
||||
N::NetworkBuilder: crate::components::NetworkBuilder<
|
||||
RethFullAdapter<DB, N>,
|
||||
@@ -1032,7 +1027,7 @@ where
|
||||
>,
|
||||
>
|
||||
where
|
||||
N: Node<FullNodeTypesAdapter<N, DB, RethFullProviderType<DB, <N as NodeTypes>::Evm>>>,
|
||||
N: Node<FullNodeTypesAdapter<N, DB, RethFullProviderType<DB>>>,
|
||||
N::PoolBuilder: PoolBuilder<RethFullAdapter<DB, N>>,
|
||||
N::NetworkBuilder: crate::components::NetworkBuilder<
|
||||
RethFullAdapter<DB, N>,
|
||||
@@ -1065,15 +1060,14 @@ where
|
||||
Types,
|
||||
Components,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
>
|
||||
where
|
||||
Components: NodeComponentsBuilder<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
>,
|
||||
Components:
|
||||
NodeComponentsBuilder<FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>>,
|
||||
{
|
||||
WithLaunchContext {
|
||||
builder: self.builder.with_components(components_builder),
|
||||
@@ -1090,7 +1084,7 @@ impl<DB, Types, Components>
|
||||
Types,
|
||||
Components,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -1098,9 +1092,7 @@ impl<DB, Types, Components>
|
||||
where
|
||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
||||
Types: NodeTypes,
|
||||
Components: NodeComponentsBuilder<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
>,
|
||||
Components: NodeComponentsBuilder<FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>>,
|
||||
{
|
||||
/// Apply a function to the components builder.
|
||||
pub fn map_components(self, f: impl FnOnce(Components) -> Components) -> Self {
|
||||
@@ -1116,7 +1108,7 @@ where
|
||||
where
|
||||
F: Fn(
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
) -> eyre::Result<()>
|
||||
@@ -1133,7 +1125,7 @@ where
|
||||
F: Fn(
|
||||
FullNode<
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -1152,7 +1144,7 @@ where
|
||||
RpcContext<
|
||||
'_,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -1172,7 +1164,7 @@ where
|
||||
RpcContext<
|
||||
'_,
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -1190,7 +1182,7 @@ where
|
||||
F: Fn(
|
||||
ExExContext<
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -1210,7 +1202,7 @@ where
|
||||
) -> eyre::Result<
|
||||
NodeHandle<
|
||||
FullNodeComponentsAdapter<
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
Components::Pool,
|
||||
>,
|
||||
>,
|
||||
@@ -1391,13 +1383,12 @@ impl<Node: FullNodeTypes> std::fmt::Debug for BuilderContext<Node> {
|
||||
pub struct InitState;
|
||||
|
||||
/// The state after all types of the node have been configured.
|
||||
#[derive(Debug)]
|
||||
pub struct TypesState<Types, DB>
|
||||
where
|
||||
DB: Database + Clone + 'static,
|
||||
Types: NodeTypes,
|
||||
{
|
||||
adapter: FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB, Types::Evm>>,
|
||||
adapter: FullNodeTypesAdapter<Types, DB, RethFullProviderType<DB>>,
|
||||
}
|
||||
|
||||
/// The state of the node builder process after the node's components have been configured.
|
||||
|
||||
Reference in New Issue
Block a user