Skip to content

Commit a163a5c

Browse files
authored
feat: relax eth_callBundle bounds (#13485)
1 parent 05382ec commit a163a5c

File tree

4 files changed

+28
-44
lines changed

4 files changed

+28
-44
lines changed

crates/node/builder/src/rpc.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use reth_node_core::{
1818
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
1919
};
2020
use reth_payload_builder::PayloadStore;
21-
use reth_primitives::{EthPrimitives, PooledTransaction};
22-
use reth_provider::providers::NodeTypesForProvider;
21+
use reth_primitives::EthPrimitives;
2322
use reth_rpc::{
2423
eth::{EthApiTypes, FullEthApiServer},
2524
EthApi,
@@ -33,7 +32,6 @@ use reth_rpc_builder::{
3332
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
3433
use reth_tasks::TaskExecutor;
3534
use reth_tracing::tracing::{debug, info};
36-
use reth_transaction_pool::{PoolTransaction, TransactionPool};
3735
use std::sync::Arc;
3836

3937
use crate::EthApiBuilderCtx;
@@ -404,9 +402,7 @@ where
404402

405403
impl<N, EthApi, EV> RpcAddOns<N, EthApi, EV>
406404
where
407-
N: FullNodeComponents<
408-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
409-
>,
405+
N: FullNodeComponents,
410406
EthApi: EthApiTypes
411407
+ FullEthApiServer<Provider = N::Provider, Pool = N::Pool, Network = N::Network>
412408
+ AddDevSigners
@@ -534,10 +530,7 @@ where
534530

535531
impl<N, EthApi, EV> NodeAddOns<N> for RpcAddOns<N, EthApi, EV>
536532
where
537-
N: FullNodeComponents<
538-
Types: NodeTypesForProvider<Primitives = EthPrimitives>,
539-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
540-
>,
533+
N: FullNodeComponents,
541534
EthApi: EthApiTypes
542535
+ FullEthApiServer<Provider = N::Provider, Pool = N::Pool, Network = N::Network>
543536
+ AddDevSigners

crates/optimism/node/src/node.rs

-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ where
252252
Storage = OpStorage,
253253
Engine = OpEngineTypes,
254254
>,
255-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
256255
>,
257256
OpEngineValidator: EngineValidator<<N::Types as NodeTypesWithEngine>::Engine>,
258257
{
@@ -303,7 +302,6 @@ where
303302
Storage = OpStorage,
304303
Engine = OpEngineTypes,
305304
>,
306-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
307305
>,
308306
OpEngineValidator: EngineValidator<<N::Types as NodeTypesWithEngine>::Engine>,
309307
{

crates/rpc/rpc-builder/src/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ use reth_consensus::FullConsensus;
230230
use reth_engine_primitives::{EngineTypes, PayloadValidator};
231231
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvm};
232232
use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers};
233-
use reth_primitives::{NodePrimitives, PooledTransaction};
233+
use reth_primitives::NodePrimitives;
234234
use reth_provider::{
235235
AccountReader, BlockReader, CanonStateSubscriptions, ChainSpecProvider, ChangeSetReader,
236236
EvmEnvProvider, FullRpcProvider, ProviderBlock, ProviderHeader, ProviderReceipt,
@@ -248,7 +248,7 @@ use reth_rpc_eth_api::{
248248
use reth_rpc_eth_types::{EthConfig, EthStateCache, EthSubscriptionIdProvider};
249249
use reth_rpc_layer::{AuthLayer, Claims, CompressionLayer, JwtAuthValidator, JwtSecret};
250250
use reth_tasks::{pool::BlockingTaskGuard, TaskSpawner, TokioTaskExecutor};
251-
use reth_transaction_pool::{noop::NoopTransactionPool, PoolTransaction, TransactionPool};
251+
use reth_transaction_pool::{noop::NoopTransactionPool, TransactionPool};
252252
use serde::{Deserialize, Serialize};
253253
use tower::Layer;
254254
use tower_http::cors::CorsLayer;
@@ -323,7 +323,6 @@ where
323323
Receipt = <BlockExecutor::Primitives as NodePrimitives>::Receipt,
324324
Header = <BlockExecutor::Primitives as NodePrimitives>::BlockHeader,
325325
>,
326-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
327326
>,
328327
BlockExecutor: BlockExecutorProvider,
329328
{
@@ -715,7 +714,6 @@ where
715714
Receipt = <Events::Primitives as NodePrimitives>::Receipt,
716715
Header = <Events::Primitives as NodePrimitives>::BlockHeader,
717716
>,
718-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
719717
>,
720718
{
721719
let Self {
@@ -841,7 +839,6 @@ where
841839
Block = <Events::Primitives as NodePrimitives>::Block,
842840
Header = <Events::Primitives as NodePrimitives>::BlockHeader,
843841
>,
844-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
845842
>,
846843
Pool: TransactionPool<Transaction = <EthApi::Pool as TransactionPool>::Transaction>,
847844
{
@@ -1382,7 +1379,6 @@ where
13821379
Receipt = <BlockExecutor::Primitives as NodePrimitives>::Receipt,
13831380
Header = <BlockExecutor::Primitives as NodePrimitives>::BlockHeader,
13841381
>,
1385-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
13861382
>,
13871383
BlockExecutor: BlockExecutorProvider,
13881384
Consensus: reth_consensus::FullConsensus<BlockExecutor::Primitives> + Clone + 'static,

crates/rpc/rpc/src/eth/bundle.rs

+23-26
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use alloy_rpc_types_mev::{EthCallBundle, EthCallBundleResponse, EthCallBundleTra
66
use jsonrpsee::core::RpcResult;
77
use reth_chainspec::EthChainSpec;
88
use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv};
9-
use reth_primitives::PooledTransaction;
109
use reth_primitives_traits::SignedTransaction;
1110
use reth_provider::{ChainSpecProvider, HeaderProvider};
1211
use reth_revm::database::StateProviderDatabase;
@@ -16,7 +15,9 @@ use reth_rpc_eth_api::{
1615
};
1716
use reth_rpc_eth_types::{utils::recover_raw_transaction, EthApiError, RpcInvalidTransactionError};
1817
use reth_tasks::pool::BlockingTaskGuard;
19-
use reth_transaction_pool::{PoolPooledTx, PoolTransaction, PoolTx, TransactionPool};
18+
use reth_transaction_pool::{
19+
EthBlobTransactionSidecar, EthPoolTransaction, PoolPooledTx, PoolTransaction, TransactionPool,
20+
};
2021
use revm::{
2122
db::{CacheDB, DatabaseCommit, DatabaseRef},
2223
primitives::{ResultAndState, TxEnv},
@@ -44,11 +45,7 @@ impl<Eth> EthBundle<Eth> {
4445

4546
impl<Eth> EthBundle<Eth>
4647
where
47-
Eth: EthTransactions<
48-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
49-
> + LoadPendingBlock
50-
+ Call
51-
+ 'static,
48+
Eth: EthTransactions + LoadPendingBlock + Call + 'static,
5249
{
5350
/// Simulates a bundle of transactions at the top of a given block number with the state of
5451
/// another (or the same) block. This can be used to simulate future blocks with the current
@@ -88,12 +85,11 @@ where
8885
.map(|tx| recover_raw_transaction::<PoolPooledTx<Eth::Pool>>(&tx))
8986
.collect::<Result<Vec<_>, _>>()?
9087
.into_iter()
91-
.map(|tx| tx.to_components())
9288
.collect::<Vec<_>>();
9389

9490
// Validate that the bundle does not contain more than MAX_BLOB_NUMBER_PER_BLOCK blob
9591
// transactions.
96-
if transactions.iter().filter_map(|(tx, _)| tx.blob_gas_used()).sum::<u64>() >
92+
if transactions.iter().filter_map(|tx| tx.blob_gas_used()).sum::<u64>() >
9793
MAX_BLOB_GAS_PER_BLOCK
9894
{
9995
return Err(EthApiError::InvalidParams(
@@ -185,18 +181,23 @@ where
185181
let mut results = Vec::with_capacity(transactions.len());
186182
let mut transactions = transactions.into_iter().peekable();
187183

188-
while let Some((tx, signer)) = transactions.next() {
189-
// Verify that the given blob data, commitments, and proofs are all valid for
190-
// this transaction.
191-
if let PooledTransaction::Eip4844(ref tx) = tx {
192-
tx.tx().validate_blob(EnvKzgSettings::Default.get()).map_err(|e| {
193-
Eth::Error::from_eth_err(EthApiError::InvalidParams(e.to_string()))
194-
})?;
195-
}
196-
197-
let tx: PoolPooledTx<Eth::Pool> = tx;
198-
let tx = PoolTx::<Eth::Pool>::pooled_into_consensus(tx);
199-
// let tx = PoolConsensusTx::<Eth::Pool>::Trafrom(tx);
184+
while let Some(tx) = transactions.next() {
185+
let signer = tx.signer();
186+
let tx = {
187+
let mut tx: <Eth::Pool as TransactionPool>::Transaction = tx.into();
188+
189+
if let EthBlobTransactionSidecar::Present(sidecar) = tx.take_blob() {
190+
tx.validate_blob(&sidecar, EnvKzgSettings::Default.get()).map_err(
191+
|e| {
192+
Eth::Error::from_eth_err(EthApiError::InvalidParams(
193+
e.to_string(),
194+
))
195+
},
196+
)?;
197+
}
198+
199+
tx.into_consensus()
200+
};
200201

201202
hasher.update(*tx.tx_hash());
202203
let gas_price = tx.effective_gas_price(basefee);
@@ -278,11 +279,7 @@ where
278279
#[async_trait::async_trait]
279280
impl<Eth> EthCallBundleApiServer for EthBundle<Eth>
280281
where
281-
Eth: EthTransactions<
282-
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
283-
> + LoadPendingBlock
284-
+ Call
285-
+ 'static,
282+
Eth: EthTransactions + LoadPendingBlock + Call + 'static,
286283
{
287284
async fn call_bundle(&self, request: EthCallBundle) -> RpcResult<EthCallBundleResponse> {
288285
Self::call_bundle(self, request).await.map_err(Into::into)

0 commit comments

Comments
 (0)