feat: use primitive transaction as PoolTransaction::Consensus (#13086)

This commit is contained in:
Arsenii Kulikov
2024-12-03 12:46:37 +04:00
committed by GitHub
parent ae8912fa73
commit 5724114947
38 changed files with 283 additions and 202 deletions

View File

@ -13,7 +13,7 @@ use reth_db::transaction::{DbTx, DbTxMut};
use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvm};
use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, PeersInfo};
use reth_node_api::{
AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, PayloadBuilder,
AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, PayloadBuilder, TxTy,
};
use reth_node_builder::{
components::{
@ -42,7 +42,7 @@ use reth_provider::{
use reth_rpc_server_types::RethRpcModule;
use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::{
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, TransactionPool,
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, PoolTransaction, TransactionPool,
TransactionValidationTaskExecutor,
};
use reth_trie_db::MerklePatriciaTrie;
@ -465,7 +465,9 @@ where
Primitives = OpPrimitives,
>,
>,
Pool: TransactionPool + Unpin + 'static,
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin
+ 'static,
Evm: ConfigureEvm<Header = Header>,
{
let payload_builder = reth_optimism_payload_builder::OpPayloadBuilder::new(evm_config)
@ -505,7 +507,9 @@ where
Primitives = OpPrimitives,
>,
>,
Pool: TransactionPool + Unpin + 'static,
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin
+ 'static,
Txs: OpPayloadTransactions,
{
async fn spawn_payload_service(
@ -577,7 +581,9 @@ impl OpNetworkBuilder {
impl<Node, Pool> NetworkBuilder<Node, Pool> for OpNetworkBuilder
where
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec, Primitives = OpPrimitives>>,
Pool: TransactionPool + Unpin + 'static,
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin
+ 'static,
{
async fn build_network(
self,

View File

@ -70,7 +70,7 @@ impl<Client, Tx> OpTransactionValidator<Client, Tx> {
impl<Client, Tx> OpTransactionValidator<Client, Tx>
where
Client: StateProviderFactory + BlockReaderIdExt<Block = reth_primitives::Block>,
Tx: EthPoolTransaction,
Tx: EthPoolTransaction<Consensus = TransactionSigned>,
{
/// Create a new [`OpTransactionValidator`].
pub fn new(inner: EthTransactionValidator<Client, Tx>) -> Self {
@ -142,7 +142,7 @@ where
let l1_block_info = self.block_info.l1_block_info.read().clone();
let mut encoded = Vec::with_capacity(valid_tx.transaction().encoded_length());
let tx: TransactionSigned = valid_tx.transaction().clone_into_consensus().into();
let tx = valid_tx.transaction().clone_into_consensus();
tx.encode_2718(&mut encoded);
let cost_addition = match l1_block_info.l1_tx_data_fee(
@ -196,7 +196,7 @@ where
impl<Client, Tx> TransactionValidator for OpTransactionValidator<Client, Tx>
where
Client: StateProviderFactory + BlockReaderIdExt<Block = reth_primitives::Block>,
Tx: EthPoolTransaction,
Tx: EthPoolTransaction<Consensus = TransactionSigned>,
{
type Transaction = Tx;

View File

@ -30,7 +30,7 @@ use reth_payload_util::{PayloadTransactions, PayloadTransactionsChain, PayloadTr
use reth_primitives::{RecoveredTx, SealedBlock, Transaction, TransactionSigned};
use reth_provider::providers::BlockchainProvider2;
use reth_tasks::TaskManager;
use reth_transaction_pool::pool::BestPayloadTransactions;
use reth_transaction_pool::{pool::BestPayloadTransactions, PoolTransaction};
use std::sync::Arc;
use tokio::sync::Mutex;
@ -44,9 +44,11 @@ impl OpPayloadTransactions for CustomTxPriority {
&self,
pool: Pool,
attr: reth_transaction_pool::BestTransactionsAttributes,
) -> impl PayloadTransactions
) -> impl PayloadTransactions<Transaction = TransactionSigned>
where
Pool: reth_transaction_pool::TransactionPool,
Pool: reth_transaction_pool::TransactionPool<
Transaction: PoolTransaction<Consensus = TransactionSigned>,
>,
{
// Block composition:
// 1. Best transactions from the pool (up to 250k gas)