feat(op, txpool): add conditionals to op pooled tx (#14264)

Co-authored-by: Hamdi Allam <hamdi.allam97@gmail.com>
This commit is contained in:
Federico Gimenez
2025-02-06 14:10:54 +01:00
committed by GitHub
parent 8c4c8c90cf
commit ad7dec3b6a
3 changed files with 18 additions and 0 deletions

1
Cargo.lock generated
View File

@ -8319,6 +8319,7 @@ dependencies = [
"alloy-network", "alloy-network",
"alloy-primitives", "alloy-primitives",
"alloy-rpc-types-engine", "alloy-rpc-types-engine",
"alloy-rpc-types-eth",
"alloy-signer-local", "alloy-signer-local",
"clap", "clap",
"derive_more", "derive_more",

View File

@ -55,6 +55,7 @@ op-alloy-consensus.workspace = true
op-alloy-rpc-types-engine.workspace = true op-alloy-rpc-types-engine.workspace = true
op-alloy-flz.workspace = true op-alloy-flz.workspace = true
alloy-rpc-types-engine.workspace = true alloy-rpc-types-engine.workspace = true
alloy-rpc-types-eth.workspace = true
alloy-consensus.workspace = true alloy-consensus.workspace = true
# misc # misc

View File

@ -4,6 +4,7 @@ use alloy_consensus::{
}; };
use alloy_eips::{eip2718::Encodable2718, eip7702::SignedAuthorization}; use alloy_eips::{eip2718::Encodable2718, eip7702::SignedAuthorization};
use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, U256}; use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, U256};
use alloy_rpc_types_eth::erc4337::TransactionConditional;
use parking_lot::RwLock; use parking_lot::RwLock;
use reth_node_api::{Block, BlockBody}; use reth_node_api::{Block, BlockBody};
use reth_optimism_evm::RethL1BlockInfo; use reth_optimism_evm::RethL1BlockInfo;
@ -50,6 +51,9 @@ pub struct OpPooledTransaction<
estimated_tx_compressed_size: OnceLock<u64>, estimated_tx_compressed_size: OnceLock<u64>,
/// The pooled transaction type. /// The pooled transaction type.
_pd: core::marker::PhantomData<Pooled>, _pd: core::marker::PhantomData<Pooled>,
/// Optional conditional attached to this transaction.
conditional: Option<Box<TransactionConditional>>,
} }
impl<Cons: SignedTransaction, Pooled> OpPooledTransaction<Cons, Pooled> { impl<Cons: SignedTransaction, Pooled> OpPooledTransaction<Cons, Pooled> {
@ -58,6 +62,7 @@ impl<Cons: SignedTransaction, Pooled> OpPooledTransaction<Cons, Pooled> {
Self { Self {
inner: EthPooledTransaction::new(transaction, encoded_length), inner: EthPooledTransaction::new(transaction, encoded_length),
estimated_tx_compressed_size: Default::default(), estimated_tx_compressed_size: Default::default(),
conditional: None,
_pd: core::marker::PhantomData, _pd: core::marker::PhantomData,
} }
} }
@ -70,6 +75,17 @@ impl<Cons: SignedTransaction, Pooled> OpPooledTransaction<Cons, Pooled> {
op_alloy_flz::tx_estimated_size_fjord(&self.inner.transaction().encoded_2718()) op_alloy_flz::tx_estimated_size_fjord(&self.inner.transaction().encoded_2718())
}) })
} }
/// Conditional setter.
pub fn with_conditional(mut self, conditional: TransactionConditional) -> Self {
self.conditional = Some(Box::new(conditional));
self
}
/// Conditional getter.
pub fn conditional(&self) -> Option<&TransactionConditional> {
self.conditional.as_deref()
}
} }
impl<Cons, Pooled> PoolTransaction for OpPooledTransaction<Cons, Pooled> impl<Cons, Pooled> PoolTransaction for OpPooledTransaction<Cons, Pooled>