diff --git a/executors/src/eip7702_executor/confirm.rs b/executors/src/eip7702_executor/confirm.rs index e8b213e..7972d4e 100644 --- a/executors/src/eip7702_executor/confirm.rs +++ b/executors/src/eip7702_executor/confirm.rs @@ -1,7 +1,6 @@ use alloy::primitives::TxHash; use alloy::providers::Provider; use alloy::rpc::types::TransactionReceipt; -use alloy::transports::RpcError; use engine_core::error::{AlloyRpcErrorToEngineError, EngineError}; use engine_core::rpc_clients::TwGetTransactionHashResponse; use engine_core::{ diff --git a/executors/src/eoa/worker/confirm.rs b/executors/src/eoa/worker/confirm.rs index 2fc0b11..6e10e46 100644 --- a/executors/src/eoa/worker/confirm.rs +++ b/executors/src/eoa/worker/confirm.rs @@ -2,15 +2,18 @@ use alloy::{primitives::B256, providers::Provider}; use engine_core::{chain::Chain, error::AlloyRpcErrorToEngineError}; use serde::{Deserialize, Serialize}; -use crate::eoa::{ - EoaExecutorStore, - store::{ - CleanupReport, ConfirmedTransaction, ReplacedTransaction, SubmittedTransactionDehydrated, - TransactionStoreError, - }, - worker::{ - EoaExecutorWorker, - error::{EoaExecutorWorkerError, should_update_balance_threshold}, +use crate::{ + FlashblocksSupport, + eoa::{ + EoaExecutorStore, + store::{ + CleanupReport, ConfirmedTransaction, ReplacedTransaction, SubmittedTransactionDehydrated, + TransactionStoreError, + }, + worker::{ + EoaExecutorWorker, + error::{EoaExecutorWorkerError, should_update_balance_threshold}, + }, }, }; @@ -34,6 +37,7 @@ impl EoaExecutorWorker { .chain .provider() .get_transaction_count(self.eoa) + .with_flashblocks_support(self.chain.chain_id()) .await .map_err(|e| { let engine_error = e.to_engine_error(&self.chain); diff --git a/executors/src/lib.rs b/executors/src/lib.rs index 26a133a..7a01247 100644 --- a/executors/src/lib.rs +++ b/executors/src/lib.rs @@ -4,3 +4,24 @@ pub mod external_bundler; pub mod metrics; pub mod transaction_registry; pub mod webhook; + +use alloy::rpc::json_rpc::{RpcSend, RpcRecv}; + +/// Extension trait for RpcWithBlock to automatically select block tag based on flashblocks support +pub trait FlashblocksSupport { + fn with_flashblocks_support(self, chain_id: u64) -> Self; +} + +impl FlashblocksSupport for alloy::providers::RpcWithBlock +where + Params: RpcSend, + Resp: RpcRecv, + Map: Fn(Resp) -> Output + Clone, +{ + fn with_flashblocks_support(self, chain_id: u64) -> Self { + match chain_id { + 8453 | 84532 => self.pending(), // Base Mainnet | Base Sepolia + _ => self, + } + } +}