Skip to content

Commit 1453e7a

Browse files
authored
Flashblocks Support (#43)
* Add Flashblocks support to RpcWithBlock in executor (#43) - Introduced a new extension trait `FlashblocksSupport` for `RpcWithBlock` to automatically select the appropriate block tag based on the chain ID. - Updated the `EoaExecutorWorker` to utilize the new `with_flashblocks_support` method when fetching the transaction count, enhancing compatibility with specific chains. These changes improve the flexibility and functionality of the RPC provider in handling flashblocks support. * Remove unused RpcError import in EIP-7702 executor confirm module
1 parent 5f8cefd commit 1453e7a

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

executors/src/eip7702_executor/confirm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use alloy::primitives::TxHash;
22
use alloy::providers::Provider;
33
use alloy::rpc::types::TransactionReceipt;
4-
use alloy::transports::RpcError;
54
use engine_core::error::{AlloyRpcErrorToEngineError, EngineError};
65
use engine_core::rpc_clients::TwGetTransactionHashResponse;
76
use engine_core::{

executors/src/eoa/worker/confirm.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ use alloy::{primitives::B256, providers::Provider};
22
use engine_core::{chain::Chain, error::AlloyRpcErrorToEngineError};
33
use serde::{Deserialize, Serialize};
44

5-
use crate::eoa::{
6-
EoaExecutorStore,
7-
store::{
8-
CleanupReport, ConfirmedTransaction, ReplacedTransaction, SubmittedTransactionDehydrated,
9-
TransactionStoreError,
10-
},
11-
worker::{
12-
EoaExecutorWorker,
13-
error::{EoaExecutorWorkerError, should_update_balance_threshold},
5+
use crate::{
6+
FlashblocksSupport,
7+
eoa::{
8+
EoaExecutorStore,
9+
store::{
10+
CleanupReport, ConfirmedTransaction, ReplacedTransaction, SubmittedTransactionDehydrated,
11+
TransactionStoreError,
12+
},
13+
worker::{
14+
EoaExecutorWorker,
15+
error::{EoaExecutorWorkerError, should_update_balance_threshold},
16+
},
1417
},
1518
};
1619

@@ -34,6 +37,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
3437
.chain
3538
.provider()
3639
.get_transaction_count(self.eoa)
40+
.with_flashblocks_support(self.chain.chain_id())
3741
.await
3842
.map_err(|e| {
3943
let engine_error = e.to_engine_error(&self.chain);

executors/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,24 @@ pub mod external_bundler;
44
pub mod metrics;
55
pub mod transaction_registry;
66
pub mod webhook;
7+
8+
use alloy::rpc::json_rpc::{RpcSend, RpcRecv};
9+
10+
/// Extension trait for RpcWithBlock to automatically select block tag based on flashblocks support
11+
pub trait FlashblocksSupport {
12+
fn with_flashblocks_support(self, chain_id: u64) -> Self;
13+
}
14+
15+
impl<Params, Resp, Output, Map> FlashblocksSupport for alloy::providers::RpcWithBlock<Params, Resp, Output, Map>
16+
where
17+
Params: RpcSend,
18+
Resp: RpcRecv,
19+
Map: Fn(Resp) -> Output + Clone,
20+
{
21+
fn with_flashblocks_support(self, chain_id: u64) -> Self {
22+
match chain_id {
23+
8453 | 84532 => self.pending(), // Base Mainnet | Base Sepolia
24+
_ => self,
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)