Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Nov 6, 2024
1 parent 3c48daf commit d0b1e96
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 234 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions bin/reth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ use reth_node_builder::{
},
EngineNodeLauncher,
};
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
use reth_node_ethereum::{
node::{EthStorage, EthereumAddOns},
EthereumNode,
};
use reth_provider::providers::BlockchainProvider2;
use reth_tracing::tracing::warn;
use tracing::info;
Expand Down Expand Up @@ -73,7 +76,7 @@ fn main() {
.with_persistence_threshold(engine_args.persistence_threshold)
.with_memory_block_buffer_target(engine_args.memory_block_buffer_target);
let handle = builder
.with_types_and_provider::<EthereumNode, BlockchainProvider2<_>>()
.with_types_and_provider::<EthereumNode, BlockchainProvider2<_, EthStorage>>()
.with_components(EthereumNode::components())
.with_add_ons(EthereumAddOns::default())
.launch_with_fn(|builder| {
Expand Down
16 changes: 10 additions & 6 deletions crates/engine/local/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use core::fmt;
use std::{
fmt::{Debug, Formatter},
marker::PhantomData,
pin::Pin,
sync::Arc,
task::{Context, Poll},
Expand Down Expand Up @@ -44,7 +45,7 @@ use tracing::error;
///
/// This service both produces and consumes [`BeaconEngineMessage`]s. This is done to allow
/// modifications of the stream
pub struct LocalEngineService<N>
pub struct LocalEngineService<N, S>
where
N: EngineNodeTypes,
{
Expand All @@ -54,19 +55,21 @@ where
handler: EngineApiRequestHandler<EngineApiRequest<N::Engine>>,
/// Receiver for incoming requests (from the engine API endpoint) that need to be processed.
incoming_requests: EngineMessageStream<N::Engine>,
_marker: PhantomData<S>,
}

impl<N> LocalEngineService<N>
impl<N, S> LocalEngineService<N, S>
where
N: EngineNodeTypes,
S: Send + Sync + 'static,
{
/// Constructor for [`LocalEngineService`].
#[allow(clippy::too_many_arguments)]
pub fn new<B>(
consensus: Arc<dyn Consensus>,
executor_factory: impl BlockExecutorProvider,
provider: ProviderFactory<N>,
blockchain_db: BlockchainProvider2<N>,
blockchain_db: BlockchainProvider2<N, S>,
pruner: PrunerWithFactory<ProviderFactory<N>>,
payload_builder: PayloadBuilderHandle<N::Engine>,
tree_config: TreeConfig,
Expand Down Expand Up @@ -113,13 +116,14 @@ where
payload_builder,
);

Self { handler, incoming_requests: from_engine }
Self { handler, incoming_requests: from_engine, _marker: PhantomData }
}
}

impl<N> Stream for LocalEngineService<N>
impl<N, S> Stream for LocalEngineService<N, S>
where
N: EngineNodeTypes,
S: Unpin,
{
type Item = ChainEvent<BeaconConsensusEngineEvent>;

Expand Down Expand Up @@ -152,7 +156,7 @@ where
}
}

impl<N: EngineNodeTypes> Debug for LocalEngineService<N> {
impl<N: EngineNodeTypes, S> Debug for LocalEngineService<N, S> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("LocalEngineService").finish_non_exhaustive()
}
Expand Down
11 changes: 7 additions & 4 deletions crates/engine/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,23 @@ type EngineServiceType<N, Client> = ChainOrchestrator<
/// The type that drives the chain forward and communicates progress.
#[pin_project]
#[allow(missing_debug_implementations)]
pub struct EngineService<N, Client, E>
pub struct EngineService<N, Client, E, S>
where
N: EngineNodeTypes,
Client: BlockClient + 'static,
E: BlockExecutorProvider + 'static,
{
orchestrator: EngineServiceType<N, Client>,
_marker: PhantomData<E>,
_marker_s: PhantomData<S>,
}

impl<N, Client, E> EngineService<N, Client, E>
impl<N, Client, E, S> EngineService<N, Client, E, S>
where
N: EngineNodeTypes,
Client: BlockClient + 'static,
E: BlockExecutorProvider + 'static,
S: Send + Sync + 'static,
{
/// Constructor for `EngineService`.
#[allow(clippy::too_many_arguments)]
Expand All @@ -73,7 +75,7 @@ where
pipeline: Pipeline<N>,
pipeline_task_spawner: Box<dyn TaskSpawner>,
provider: ProviderFactory<N>,
blockchain_db: BlockchainProvider2<N>,
blockchain_db: BlockchainProvider2<N, S>,
pruner: PrunerWithFactory<ProviderFactory<N>>,
payload_builder: PayloadBuilderHandle<N::Engine>,
tree_config: TreeConfig,
Expand Down Expand Up @@ -112,6 +114,7 @@ where
Self {
orchestrator: ChainOrchestrator::new(handler, backfill_sync),
_marker: Default::default(),
_marker_s: Default::default(),
}
}

Expand All @@ -121,7 +124,7 @@ where
}
}

impl<N, Client, E> Stream for EngineService<N, Client, E>
impl<N, Client, E, S> Stream for EngineService<N, Client, E, S>
where
N: EngineNodeTypes,
Client: BlockClient + 'static,
Expand Down
53 changes: 28 additions & 25 deletions crates/ethereum/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use reth_node_builder::{
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{Block, BlockBody, Header};
use reth_provider::{
BlockNumReader, BlockReader, CanonStateSubscriptions, ChainStorageReader, DBProvider,
HeaderProvider, ProviderResult, TransactionsProvider, WithdrawalsProvider,
BlockNumReader, BlockReader, CanonStateSubscriptions, ChainStorageReader, ChainStorageWriter,
DBProvider, HeaderProvider, ProviderResult, TransactionsProvider, WithdrawalsProvider,
};
use reth_rpc::EthApi;
use reth_tracing::tracing::{debug, info};
Expand Down Expand Up @@ -88,7 +88,6 @@ impl NodeTypes for EthereumNode {
type Primitives = EthPrimitives;
type ChainSpec = ChainSpec;
type StateCommitment = MerklePatriciaTrie;
type Storage = EthStorage;
}

impl NodeTypesWithEngine for EthereumNode {
Expand Down Expand Up @@ -138,22 +137,37 @@ where
#[derive(Debug, Default)]
pub struct EthStorage;

impl ChainStorageReader for EthStorage {
impl<P> ChainStorageWriter<P> for EthStorage
where
P: DBProvider<Tx: DbTxMut>,
{
type Primitives = EthPrimitives;

fn read_block<P>(
fn write_block(
&self,
_: &P,
_: &<Self::Primitives as NodePrimitives>::Block,
) -> ProviderResult<()> {
unimplemented!()
}
}

impl<P> ChainStorageReader<P> for EthStorage
where
P: DBProvider<Tx: DbTx>
+ TransactionsProvider
+ BlockReader
+ WithdrawalsProvider
+ HeaderProvider
+ BlockNumReader,
{
type Primitives = EthPrimitives;

fn read_block(
&self,
provider: &P,
id: BlockHashOrNumber,
) -> ProviderResult<Option<<Self::Primitives as NodePrimitives>::Block>>
where
P: DBProvider<Tx: DbTx>
+ TransactionsProvider
+ BlockReader
+ WithdrawalsProvider
+ HeaderProvider
+ BlockNumReader,
{
) -> ProviderResult<Option<<Self::Primitives as NodePrimitives>::Block>> {
if let Some(number) = provider.convert_hash_or_number(id)? {
if let Some(header) = provider.header_by_number(number)? {
let withdrawals = provider.withdrawals_by_block(number.into(), header.timestamp)?;
Expand All @@ -176,17 +190,6 @@ impl ChainStorageReader for EthStorage {

Ok(None)
}

fn write_block<P>(
&self,
_provider: &P,
_block: &<Self::Primitives as NodePrimitives>::Block,
) -> ProviderResult<()>
where
P: DBProvider<Tx: DbTxMut>,
{
todo!()
}
}

/// A regular ethereum evm and executor builder.
Expand Down
1 change: 0 additions & 1 deletion crates/exex/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ impl NodeTypes for TestNode {
type Primitives = ();
type ChainSpec = ChainSpec;
type StateCommitment = reth_trie_db::MerklePatriciaTrie;
type Storage = ();
}

impl NodeTypesWithEngine for TestNode {
Expand Down
2 changes: 1 addition & 1 deletion crates/node/builder/src/launch/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<N: NodeTypesWithDB> WithTree for BlockchainProvider<N> {
}
}

impl<N: NodeTypesWithDB> WithTree for BlockchainProvider2<N> {
impl<N: NodeTypesWithDB, S> WithTree for BlockchainProvider2<N, S> {
fn set_tree(self, _tree: Arc<dyn TreeViewer>) -> Self {
self
}
Expand Down
11 changes: 8 additions & 3 deletions crates/node/builder/src/launch/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ use reth_node_core::{
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
use reth_payload_primitives::PayloadBuilder;
use reth_primitives::EthereumHardforks;
use reth_provider::providers::{BlockchainProvider2, ProviderNodeTypes};
use reth_provider::{
providers::{BlockchainProvider2, ProviderNodeTypes},
ChainStorageReader, ChainStorageWriter, DatabaseProviderFactory, ProviderFactory,
};
use reth_tasks::TaskExecutor;
use reth_tokio_util::EventSender;
use reth_tracing::tracing::{debug, error, info};
Expand Down Expand Up @@ -68,10 +71,12 @@ impl EngineNodeLauncher {
}
}

impl<Types, T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
impl<Types, S, T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
where
Types: ProviderNodeTypes + NodeTypesWithEngine,
T: FullNodeTypes<Types = Types, Provider = BlockchainProvider2<Types>>,
S: ChainStorageReader<<ProviderFactory<Types> as DatabaseProviderFactory>::Provider>
+ ChainStorageWriter<<ProviderFactory<Types> as DatabaseProviderFactory>::ProviderRW>,
T: FullNodeTypes<Types = Types, Provider = BlockchainProvider2<Types, S>>,
CB: NodeComponentsBuilder<T>,
AO: RethRpcAddOns<NodeAdapter<T, CB::Components>>,
LocalPayloadAttributesBuilder<Types::ChainSpec>: PayloadAttributesBuilder<
Expand Down
2 changes: 0 additions & 2 deletions crates/node/builder/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ where
type ChainSpec = <N::Types as NodeTypes>::ChainSpec;

type StateCommitment = <N::Types as NodeTypes>::StateCommitment;

type Storage = <N::Types as NodeTypes>::Storage;
}

impl<N, C, AO> NodeTypesWithEngine for AnyNode<N, C, AO>
Expand Down
1 change: 0 additions & 1 deletion crates/node/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ reth-chainspec.workspace = true
reth-db-api.workspace = true
reth-engine-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-storage-api.workspace =true
reth-trie-db.workspace = true
Loading

0 comments on commit d0b1e96

Please sign in to comment.