From 621348e1abcc78e196a539344e96f5e7a61efdec Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 20 Dec 2024 17:36:22 +0200 Subject: [PATCH] feat: relax eth_callBundle bounds --- crates/node/builder/src/rpc.rs | 13 ++------ crates/optimism/node/src/node.rs | 2 -- crates/rpc/rpc-builder/src/lib.rs | 8 ++--- crates/rpc/rpc/src/eth/bundle.rs | 49 +++++++++++++++---------------- 4 files changed, 28 insertions(+), 44 deletions(-) diff --git a/crates/node/builder/src/rpc.rs b/crates/node/builder/src/rpc.rs index 5497052dfffa..1f6803bd4c62 100644 --- a/crates/node/builder/src/rpc.rs +++ b/crates/node/builder/src/rpc.rs @@ -18,8 +18,7 @@ use reth_node_core::{ version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA}, }; use reth_payload_builder::PayloadStore; -use reth_primitives::{EthPrimitives, PooledTransaction}; -use reth_provider::providers::NodeTypesForProvider; +use reth_primitives::EthPrimitives; use reth_rpc::{ eth::{EthApiTypes, FullEthApiServer}, EthApi, @@ -33,7 +32,6 @@ use reth_rpc_builder::{ use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi}; use reth_tasks::TaskExecutor; use reth_tracing::tracing::{debug, info}; -use reth_transaction_pool::{PoolTransaction, TransactionPool}; use std::sync::Arc; use crate::EthApiBuilderCtx; @@ -404,9 +402,7 @@ where impl RpcAddOns where - N: FullNodeComponents< - Pool: TransactionPool>, - >, + N: FullNodeComponents, EthApi: EthApiTypes + FullEthApiServer + AddDevSigners @@ -534,10 +530,7 @@ where impl NodeAddOns for RpcAddOns where - N: FullNodeComponents< - Types: NodeTypesForProvider, - Pool: TransactionPool>, - >, + N: FullNodeComponents, EthApi: EthApiTypes + FullEthApiServer + AddDevSigners diff --git a/crates/optimism/node/src/node.rs b/crates/optimism/node/src/node.rs index f8428b795bd9..f0db0fae4e22 100644 --- a/crates/optimism/node/src/node.rs +++ b/crates/optimism/node/src/node.rs @@ -252,7 +252,6 @@ where Storage = OpStorage, Engine = OpEngineTypes, >, - Pool: TransactionPool>, >, OpEngineValidator: EngineValidator<::Engine>, { @@ -303,7 +302,6 @@ where Storage = OpStorage, Engine = OpEngineTypes, >, - Pool: TransactionPool>, >, OpEngineValidator: EngineValidator<::Engine>, { diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index dcbb9f22225f..9835c832ce94 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -230,7 +230,7 @@ use reth_consensus::FullConsensus; use reth_engine_primitives::{EngineTypes, PayloadValidator}; use reth_evm::{execute::BlockExecutorProvider, ConfigureEvm}; use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers}; -use reth_primitives::{NodePrimitives, PooledTransaction}; +use reth_primitives::NodePrimitives; use reth_provider::{ AccountReader, BlockReader, CanonStateSubscriptions, ChainSpecProvider, ChangeSetReader, EvmEnvProvider, FullRpcProvider, ProviderBlock, ProviderHeader, ProviderReceipt, @@ -248,7 +248,7 @@ use reth_rpc_eth_api::{ use reth_rpc_eth_types::{EthConfig, EthStateCache, EthSubscriptionIdProvider}; use reth_rpc_layer::{AuthLayer, Claims, CompressionLayer, JwtAuthValidator, JwtSecret}; use reth_tasks::{pool::BlockingTaskGuard, TaskSpawner, TokioTaskExecutor}; -use reth_transaction_pool::{noop::NoopTransactionPool, PoolTransaction, TransactionPool}; +use reth_transaction_pool::{noop::NoopTransactionPool, TransactionPool}; use serde::{Deserialize, Serialize}; use tower::Layer; use tower_http::cors::CorsLayer; @@ -323,7 +323,6 @@ where Receipt = ::Receipt, Header = ::BlockHeader, >, - Pool: TransactionPool>, >, BlockExecutor: BlockExecutorProvider, { @@ -715,7 +714,6 @@ where Receipt = ::Receipt, Header = ::BlockHeader, >, - Pool: TransactionPool>, >, { let Self { @@ -841,7 +839,6 @@ where Block = ::Block, Header = ::BlockHeader, >, - Pool: TransactionPool>, >, Pool: TransactionPool::Transaction>, { @@ -1382,7 +1379,6 @@ where Receipt = ::Receipt, Header = ::BlockHeader, >, - Pool: TransactionPool>, >, BlockExecutor: BlockExecutorProvider, Consensus: reth_consensus::FullConsensus + Clone + 'static, diff --git a/crates/rpc/rpc/src/eth/bundle.rs b/crates/rpc/rpc/src/eth/bundle.rs index 30dd3b4a092d..a57053489d0b 100644 --- a/crates/rpc/rpc/src/eth/bundle.rs +++ b/crates/rpc/rpc/src/eth/bundle.rs @@ -6,7 +6,6 @@ use alloy_rpc_types_mev::{EthCallBundle, EthCallBundleResponse, EthCallBundleTra use jsonrpsee::core::RpcResult; use reth_chainspec::EthChainSpec; use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv}; -use reth_primitives::PooledTransaction; use reth_primitives_traits::SignedTransaction; use reth_provider::{ChainSpecProvider, HeaderProvider}; use reth_revm::database::StateProviderDatabase; @@ -16,7 +15,9 @@ use reth_rpc_eth_api::{ }; use reth_rpc_eth_types::{utils::recover_raw_transaction, EthApiError, RpcInvalidTransactionError}; use reth_tasks::pool::BlockingTaskGuard; -use reth_transaction_pool::{PoolPooledTx, PoolTransaction, PoolTx, TransactionPool}; +use reth_transaction_pool::{ + EthBlobTransactionSidecar, EthPoolTransaction, PoolPooledTx, PoolTransaction, TransactionPool, +}; use revm::{ db::{CacheDB, DatabaseCommit, DatabaseRef}, primitives::{ResultAndState, TxEnv}, @@ -44,11 +45,7 @@ impl EthBundle { impl EthBundle where - Eth: EthTransactions< - Pool: TransactionPool>, - > + LoadPendingBlock - + Call - + 'static, + Eth: EthTransactions + LoadPendingBlock + Call + 'static, { /// Simulates a bundle of transactions at the top of a given block number with the state of /// another (or the same) block. This can be used to simulate future blocks with the current @@ -88,12 +85,11 @@ where .map(|tx| recover_raw_transaction::>(&tx)) .collect::, _>>()? .into_iter() - .map(|tx| tx.to_components()) .collect::>(); // Validate that the bundle does not contain more than MAX_BLOB_NUMBER_PER_BLOCK blob // transactions. - if transactions.iter().filter_map(|(tx, _)| tx.blob_gas_used()).sum::() > + if transactions.iter().filter_map(|tx| tx.blob_gas_used()).sum::() > MAX_BLOB_GAS_PER_BLOCK { return Err(EthApiError::InvalidParams( @@ -185,18 +181,23 @@ where let mut results = Vec::with_capacity(transactions.len()); let mut transactions = transactions.into_iter().peekable(); - while let Some((tx, signer)) = transactions.next() { - // Verify that the given blob data, commitments, and proofs are all valid for - // this transaction. - if let PooledTransaction::Eip4844(ref tx) = tx { - tx.tx().validate_blob(EnvKzgSettings::Default.get()).map_err(|e| { - Eth::Error::from_eth_err(EthApiError::InvalidParams(e.to_string())) - })?; - } - - let tx: PoolPooledTx = tx; - let tx = PoolTx::::pooled_into_consensus(tx); - // let tx = PoolConsensusTx::::Trafrom(tx); + while let Some(tx) = transactions.next() { + let signer = tx.signer(); + let tx = { + let mut tx: ::Transaction = tx.into(); + + if let EthBlobTransactionSidecar::Present(sidecar) = tx.take_blob() { + tx.validate_blob(&sidecar, EnvKzgSettings::Default.get()).map_err( + |e| { + Eth::Error::from_eth_err(EthApiError::InvalidParams( + e.to_string(), + )) + }, + )?; + } + + tx.into_consensus() + }; hasher.update(*tx.tx_hash()); let gas_price = tx.effective_gas_price(basefee); @@ -278,11 +279,7 @@ where #[async_trait::async_trait] impl EthCallBundleApiServer for EthBundle where - Eth: EthTransactions< - Pool: TransactionPool>, - > + LoadPendingBlock - + Call - + 'static, + Eth: EthTransactions + LoadPendingBlock + Call + 'static, { async fn call_bundle(&self, request: EthCallBundle) -> RpcResult { Self::call_bundle(self, request).await.map_err(Into::into)