From f7c85fc4aed49c1967d7d260af9592d2c2b393aa Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 10 Dec 2024 15:07:54 +0100 Subject: [PATCH 1/2] chore: releax eth pooled tx --- crates/transaction-pool/src/traits.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index a0d4d40983e4..1c8561e22dd8 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -1179,9 +1179,9 @@ pub trait EthPoolTransaction: PoolTransaction { /// This type is essentially a wrapper around [`RecoveredTx`] with additional /// fields derived from the transaction that are frequently used by the pools for ordering. #[derive(Debug, Clone, PartialEq, Eq)] -pub struct EthPooledTransaction { +pub struct EthPooledTransaction { /// `EcRecovered` transaction, the consensus format. - pub(crate) transaction: T, + pub(crate) transaction: RecoveredTx, /// For EIP-1559 transactions: `max_fee_per_gas * gas_limit + tx_value`. /// For legacy transactions: `gas_price * gas_limit + tx_value`. @@ -1197,16 +1197,16 @@ pub struct EthPooledTransaction { pub(crate) blob_sidecar: EthBlobTransactionSidecar, } -impl EthPooledTransaction { +impl EthPooledTransaction { /// Create new instance of [Self]. /// /// Caution: In case of blob transactions, this does marks the blob sidecar as /// [`EthBlobTransactionSidecar::Missing`] - pub fn new(transaction: RecoveredTx, encoded_length: usize) -> Self { + pub fn new(transaction: RecoveredTx, encoded_length: usize) -> Self { let mut blob_sidecar = EthBlobTransactionSidecar::None; - let gas_cost = U256::from(transaction.transaction.max_fee_per_gas()) - .saturating_mul(U256::from(transaction.transaction.gas_limit())); + let gas_cost = U256::from(transaction.max_fee_per_gas()) + .saturating_mul(U256::from(transaction.gas_limit())); let mut cost = gas_cost.saturating_add(transaction.value()); From 3b89ee843af2429f5116e525711b67f9a95aa28d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 12 Dec 2024 13:19:05 +0100 Subject: [PATCH 2/2] wip --- crates/transaction-pool/src/traits.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index e976ab103ee4..4811e9783d68 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -1210,10 +1210,12 @@ impl EthPooledTransaction { let mut cost = gas_cost.saturating_add(transaction.value()); - if let Some(blob_tx) = transaction.as_eip4844() { + if let (Some(blob_gas_used), Some(max_fee_per_blob_gas)) = + (transaction.blob_gas_used(), transaction.max_fee_per_blob_gas()) + { // Add max blob cost using saturating math to avoid overflow cost = cost.saturating_add(U256::from( - blob_tx.max_fee_per_blob_gas.saturating_mul(blob_tx.blob_gas() as u128), + max_fee_per_blob_gas.saturating_mul(blob_gas_used as u128), )); // because the blob sidecar is not included in this transaction variant, mark it as @@ -1225,7 +1227,7 @@ impl EthPooledTransaction { } /// Return the reference to the underlying transaction. - pub const fn transaction(&self) -> &RecoveredTx { + pub const fn transaction(&self) -> &RecoveredTx { &self.transaction } }