Skip to content

Commit 29289cc

Browse files
authored
feat: add Primitives AT to BlockExecutorProvider (paradigmxyz#12994)
1 parent b6b8c47 commit 29289cc

File tree

52 files changed

+591
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+591
-409
lines changed

Diff for: book/sources/exex/hello-world/src/bin/3.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use futures_util::TryStreamExt;
2-
use reth::{api::FullNodeComponents, primitives::Block, providers::BlockReader};
2+
use reth::{api::FullNodeComponents, builder::NodeTypes, primitives::EthPrimitives};
33
use reth_exex::{ExExContext, ExExEvent, ExExNotification};
44
use reth_node_ethereum::EthereumNode;
55
use reth_tracing::tracing::info;
66

7-
async fn my_exex<Node: FullNodeComponents<Provider: BlockReader<Block = Block>>>(
7+
async fn my_exex<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>>(
88
mut ctx: ExExContext<Node>,
99
) -> eyre::Result<()> {
1010
while let Some(notification) = ctx.notifications.try_next().await? {

Diff for: book/sources/exex/remote/src/exex.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use remote_exex::proto::{
33
self,
44
remote_ex_ex_server::{RemoteExEx, RemoteExExServer},
55
};
6-
use reth::{primitives::Block, providers::BlockReader};
6+
use reth::{builder::NodeTypes, primitives::EthPrimitives};
77
use reth_exex::{ExExContext, ExExEvent, ExExNotification};
88
use reth_node_api::FullNodeComponents;
99
use reth_node_ethereum::EthereumNode;
@@ -45,7 +45,7 @@ impl RemoteExEx for ExExService {
4545
}
4646
}
4747

48-
async fn remote_exex<Node: FullNodeComponents<Provider: BlockReader<Block = Block>>>(
48+
async fn remote_exex<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>>(
4949
mut ctx: ExExContext<Node>,
5050
notifications: Arc<broadcast::Sender<ExExNotification>>,
5151
) -> eyre::Result<()> {

Diff for: book/sources/exex/remote/src/exex_4.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use remote_exex::proto::{
33
self,
44
remote_ex_ex_server::{RemoteExEx, RemoteExExServer},
55
};
6-
use reth::{primitives::Block, providers::BlockReader};
6+
use reth::{builder::NodeTypes, primitives::EthPrimitives};
77
use reth_exex::{ExExContext, ExExEvent, ExExNotification};
88
use reth_node_api::FullNodeComponents;
99
use reth_node_ethereum::EthereumNode;
@@ -47,7 +47,7 @@ impl RemoteExEx for ExExService {
4747

4848
// ANCHOR: snippet
4949
#[allow(dead_code)]
50-
async fn remote_exex<Node: FullNodeComponents<Provider: BlockReader<Block = Block>>>(
50+
async fn remote_exex<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>>(
5151
mut ctx: ExExContext<Node>,
5252
notifications: Arc<broadcast::Sender<ExExNotification>>,
5353
) -> eyre::Result<()> {

Diff for: book/sources/exex/tracking-state/src/bin/1.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
};
66

77
use futures_util::{FutureExt, TryStreamExt};
8-
use reth::{api::FullNodeComponents, primitives::Block, providers::BlockReader};
8+
use reth::{api::FullNodeComponents, builder::NodeTypes, primitives::EthPrimitives};
99
use reth_exex::{ExExContext, ExExEvent, ExExNotification};
1010
use reth_node_ethereum::EthereumNode;
1111
use reth_tracing::tracing::info;
@@ -14,7 +14,9 @@ struct MyExEx<Node: FullNodeComponents> {
1414
ctx: ExExContext<Node>,
1515
}
1616

17-
impl<Node: FullNodeComponents<Provider: BlockReader<Block = Block>>> Future for MyExEx<Node> {
17+
impl<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>> Future
18+
for MyExEx<Node>
19+
{
1820
type Output = eyre::Result<()>;
1921

2022
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {

Diff for: book/sources/exex/tracking-state/src/bin/2.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66

77
use alloy_primitives::BlockNumber;
88
use futures_util::{FutureExt, TryStreamExt};
9-
use reth::{api::FullNodeComponents, primitives::Block, providers::BlockReader};
9+
use reth::{api::FullNodeComponents, builder::NodeTypes, primitives::EthPrimitives};
1010
use reth_exex::{ExExContext, ExExEvent};
1111
use reth_node_ethereum::EthereumNode;
1212
use reth_tracing::tracing::info;
@@ -25,7 +25,9 @@ impl<Node: FullNodeComponents> MyExEx<Node> {
2525
}
2626
}
2727

28-
impl<Node: FullNodeComponents<Provider: BlockReader<Block = Block>>> Future for MyExEx<Node> {
28+
impl<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>> Future
29+
for MyExEx<Node>
30+
{
2931
type Output = eyre::Result<()>;
3032

3133
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {

Diff for: crates/blockchain-tree/src/blockchain_tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<N: NodeTypesWithDB, E> BlockchainTree<N, E> {
9595
impl<N, E> BlockchainTree<N, E>
9696
where
9797
N: TreeNodeTypes,
98-
E: BlockExecutorProvider,
98+
E: BlockExecutorProvider<Primitives = N::Primitives>,
9999
{
100100
/// Builds the blockchain tree for the node.
101101
///

Diff for: crates/blockchain-tree/src/chain.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use reth_execution_errors::BlockExecutionError;
1717
use reth_execution_types::{Chain, ExecutionOutcome};
1818
use reth_primitives::{GotExpected, SealedBlockWithSenders, SealedHeader};
1919
use reth_provider::{
20-
providers::{BundleStateProvider, ConsistentDbView, ProviderNodeTypes},
20+
providers::{BundleStateProvider, ConsistentDbView, TreeNodeTypes},
2121
DBProvider, FullExecutionDataProvider, ProviderError, StateRootProvider,
2222
TryIntoHistoricalStateProvider,
2323
};
@@ -76,8 +76,8 @@ impl AppendableChain {
7676
block_validation_kind: BlockValidationKind,
7777
) -> Result<Self, InsertBlockErrorKind>
7878
where
79-
N: ProviderNodeTypes,
80-
E: BlockExecutorProvider,
79+
N: TreeNodeTypes,
80+
E: BlockExecutorProvider<Primitives = N::Primitives>,
8181
{
8282
let execution_outcome = ExecutionOutcome::default();
8383
let empty = BTreeMap::new();
@@ -114,8 +114,8 @@ impl AppendableChain {
114114
block_validation_kind: BlockValidationKind,
115115
) -> Result<Self, InsertBlockErrorKind>
116116
where
117-
N: ProviderNodeTypes,
118-
E: BlockExecutorProvider,
117+
N: TreeNodeTypes,
118+
E: BlockExecutorProvider<Primitives = N::Primitives>,
119119
{
120120
let parent_number =
121121
block.number.checked_sub(1).ok_or(BlockchainTreeError::GenesisBlockHasNoParent)?;
@@ -177,8 +177,8 @@ impl AppendableChain {
177177
) -> Result<(ExecutionOutcome, Option<TrieUpdates>), BlockExecutionError>
178178
where
179179
EDP: FullExecutionDataProvider,
180-
N: ProviderNodeTypes,
181-
E: BlockExecutorProvider,
180+
N: TreeNodeTypes,
181+
E: BlockExecutorProvider<Primitives = N::Primitives>,
182182
{
183183
// some checks are done before blocks comes here.
184184
externals.consensus.validate_header_against_parent(&block, parent_block)?;
@@ -284,8 +284,8 @@ impl AppendableChain {
284284
block_validation_kind: BlockValidationKind,
285285
) -> Result<(), InsertBlockErrorKind>
286286
where
287-
N: ProviderNodeTypes,
288-
E: BlockExecutorProvider,
287+
N: TreeNodeTypes,
288+
E: BlockExecutorProvider<Primitives = N::Primitives>,
289289
{
290290
let parent_block = self.chain.tip();
291291

Diff for: crates/blockchain-tree/src/shareable.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<N: NodeTypesWithDB, E> ShareableBlockchainTree<N, E> {
3939
impl<N, E> BlockchainTreeEngine for ShareableBlockchainTree<N, E>
4040
where
4141
N: TreeNodeTypes,
42-
E: BlockExecutorProvider,
42+
E: BlockExecutorProvider<Primitives = N::Primitives>,
4343
{
4444
fn buffer_block(&self, block: SealedBlockWithSenders) -> Result<(), InsertBlockError> {
4545
let mut tree = self.tree.write();
@@ -110,7 +110,7 @@ where
110110
impl<N, E> BlockchainTreeViewer for ShareableBlockchainTree<N, E>
111111
where
112112
N: TreeNodeTypes,
113-
E: BlockExecutorProvider,
113+
E: BlockExecutorProvider<Primitives = N::Primitives>,
114114
{
115115
fn header_by_hash(&self, hash: BlockHash) -> Option<SealedHeader> {
116116
trace!(target: "blockchain_tree", ?hash, "Returning header by hash");
@@ -173,7 +173,7 @@ where
173173
impl<N, E> BlockchainTreePendingStateProvider for ShareableBlockchainTree<N, E>
174174
where
175175
N: TreeNodeTypes,
176-
E: BlockExecutorProvider,
176+
E: BlockExecutorProvider<Primitives = N::Primitives>,
177177
{
178178
fn find_pending_state_provider(
179179
&self,

Diff for: crates/cli/commands/src/import.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> ImportComm
6060
pub async fn execute<N, E, F>(self, executor: F) -> eyre::Result<()>
6161
where
6262
N: CliNodeTypes<ChainSpec = C::ChainSpec>,
63-
E: BlockExecutorProvider,
63+
E: BlockExecutorProvider<Primitives = N::Primitives>,
6464
F: FnOnce(Arc<N::ChainSpec>) -> E,
6565
{
6666
info!(target: "reth::cli", "reth {} starting", SHORT_VERSION);
@@ -169,7 +169,7 @@ pub fn build_import_pipeline<N, C, E>(
169169
where
170170
N: ProviderNodeTypes + CliNodeTypes,
171171
C: Consensus + 'static,
172-
E: BlockExecutorProvider,
172+
E: BlockExecutorProvider<Primitives = N::Primitives>,
173173
{
174174
if !file_client.has_canonical_blocks() {
175175
eyre::bail!("unable to import non canonical blocks");

Diff for: crates/cli/commands/src/stage/dump/execution.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333
Receipt = reth_primitives::Receipt,
3434
>,
3535
>,
36-
E: BlockExecutorProvider,
36+
E: BlockExecutorProvider<Primitives = N::Primitives>,
3737
{
3838
let (output_db, tip_block_number) = setup(from, to, &output_datadir.db(), db_tool)?;
3939

@@ -188,7 +188,7 @@ where
188188
Receipt = reth_primitives::Receipt,
189189
>,
190190
>,
191-
E: BlockExecutorProvider,
191+
E: BlockExecutorProvider<Primitives = N::Primitives>,
192192
{
193193
info!(target: "reth::cli", "Executing stage. [dry-run]");
194194

Diff for: crates/cli/commands/src/stage/dump/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
9393
pub async fn execute<N, E, F>(self, executor: F) -> eyre::Result<()>
9494
where
9595
N: CliNodeTypes<ChainSpec = C::ChainSpec>,
96-
E: BlockExecutorProvider,
96+
E: BlockExecutorProvider<Primitives = N::Primitives>,
9797
F: FnOnce(Arc<C::ChainSpec>) -> E,
9898
{
9999
let Environment { provider_factory, .. } = self.env.init::<N>(AccessRights::RO)?;

Diff for: crates/cli/commands/src/stage/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
4444
pub async fn execute<N, E, F>(self, ctx: CliContext, executor: F) -> eyre::Result<()>
4545
where
4646
N: CliNodeTypes<ChainSpec = C::ChainSpec>,
47-
E: BlockExecutorProvider,
47+
E: BlockExecutorProvider<Primitives = N::Primitives>,
4848
F: FnOnce(Arc<C::ChainSpec>) -> E,
4949
{
5050
match self.command {

Diff for: crates/cli/commands/src/stage/run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
107107
pub async fn execute<N, E, F>(self, ctx: CliContext, executor: F) -> eyre::Result<()>
108108
where
109109
N: CliNodeTypes<ChainSpec = C::ChainSpec>,
110-
E: BlockExecutorProvider,
110+
E: BlockExecutorProvider<Primitives = N::Primitives>,
111111
F: FnOnce(Arc<C::ChainSpec>) -> E,
112112
{
113113
// Raise the fd limit of the process.

Diff for: crates/e2e-test-utils/src/rpc.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use alloy_consensus::TxEnvelope;
22
use alloy_network::eip2718::Decodable2718;
33
use alloy_primitives::{Bytes, B256};
4-
use alloy_rlp::Encodable;
54
use reth_chainspec::EthereumHardforks;
65
use reth_node_api::{FullNodeComponents, NodePrimitives};
76
use reth_node_builder::{rpc::RpcRegistry, NodeTypes};
@@ -21,7 +20,10 @@ where
2120
Node: FullNodeComponents<
2221
Types: NodeTypes<
2322
ChainSpec: EthereumHardforks,
24-
Primitives: NodePrimitives<Block: Encodable, Receipt = reth_primitives::Receipt>,
23+
Primitives: NodePrimitives<
24+
Block = reth_primitives::Block,
25+
Receipt = reth_primitives::Receipt,
26+
>,
2527
>,
2628
>,
2729
EthApi: EthApiSpec + EthTransactions + TraceExt,

Diff for: crates/engine/local/src/service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ where
6565
#[allow(clippy::too_many_arguments)]
6666
pub fn new<B, V>(
6767
consensus: Arc<dyn Consensus>,
68-
executor_factory: impl BlockExecutorProvider,
68+
executor_factory: impl BlockExecutorProvider<Primitives = N::Primitives>,
6969
provider: ProviderFactory<N>,
7070
blockchain_db: BlockchainProvider2<N>,
7171
pruner: PrunerWithFactory<ProviderFactory<N>>,

Diff for: crates/engine/service/src/service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<N, Client, E> EngineService<N, Client, E>
6060
where
6161
N: EngineNodeTypes + PersistenceNodeTypes,
6262
Client: EthBlockClient + 'static,
63-
E: BlockExecutorProvider + 'static,
63+
E: BlockExecutorProvider<Primitives = N::Primitives> + 'static,
6464
{
6565
/// Constructor for `EngineService`.
6666
#[allow(clippy::too_many_arguments)]

Diff for: crates/engine/tree/src/tree/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,15 @@ impl<N, P: Debug, E: Debug, T: EngineTypes + Debug, V: Debug> std::fmt::Debug
540540

541541
impl<N, P, E, T, V> EngineApiTreeHandler<N, P, E, T, V>
542542
where
543-
N: NodePrimitives,
543+
N: NodePrimitives<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>,
544544
P: DatabaseProviderFactory
545545
+ BlockReader<Block = reth_primitives::Block>
546546
+ StateProviderFactory
547547
+ StateReader<Receipt = reth_primitives::Receipt>
548548
+ Clone
549549
+ 'static,
550550
<P as DatabaseProviderFactory>::Provider: BlockReader,
551-
E: BlockExecutorProvider,
551+
E: BlockExecutorProvider<Primitives = N>,
552552
T: EngineTypes,
553553
V: EngineValidator<T, Block = reth_primitives::Block>,
554554
{

Diff for: crates/ethereum/evm/src/execute.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use reth_evm::{
2020
system_calls::{OnStateHook, SystemCaller},
2121
ConfigureEvm, TxEnvOverrides,
2222
};
23-
use reth_primitives::{BlockWithSenders, Receipt};
23+
use reth_primitives::{BlockWithSenders, EthPrimitives, Receipt};
2424
use reth_revm::db::State;
2525
use revm_primitives::{
2626
db::{Database, DatabaseCommit},
@@ -60,6 +60,8 @@ where
6060
EvmConfig:
6161
Clone + Unpin + Sync + Send + 'static + ConfigureEvm<Header = alloy_consensus::Header>,
6262
{
63+
type Primitives = EthPrimitives;
64+
6365
type Strategy<DB: Database<Error: Into<ProviderError> + Display>> =
6466
EthExecutionStrategy<DB, EvmConfig>;
6567

@@ -122,13 +124,16 @@ where
122124
}
123125
}
124126

125-
impl<DB, EvmConfig> BlockExecutionStrategy<DB> for EthExecutionStrategy<DB, EvmConfig>
127+
impl<DB, EvmConfig> BlockExecutionStrategy for EthExecutionStrategy<DB, EvmConfig>
126128
where
127129
DB: Database<Error: Into<ProviderError> + Display>,
128130
EvmConfig: ConfigureEvm<Header = alloy_consensus::Header>,
129131
{
132+
type DB = DB;
130133
type Error = BlockExecutionError;
131134

135+
type Primitives = EthPrimitives;
136+
132137
fn init(&mut self, tx_env_overrides: Box<dyn TxEnvOverrides>) {
133138
self.tx_env_overrides = Some(tx_env_overrides);
134139
}

Diff for: crates/ethereum/node/src/node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub struct EthereumExecutorBuilder;
133133

134134
impl<Types, Node> ExecutorBuilder<Node> for EthereumExecutorBuilder
135135
where
136-
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
136+
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
137137
Node: FullNodeTypes<Types = Types>,
138138
{
139139
type EVM = EthEvmConfig;

0 commit comments

Comments
 (0)