From 55a78719bd0a22f4c09938f1af193a9561a67141 Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Sun, 22 Oct 2023 20:22:13 +0200 Subject: [PATCH] feat(tx-pool): add `blob_sidecar` to EIP-4844 mock transactions (#5132) --- .../transaction-pool/src/test_utils/mock.rs | 19 ++++++++++++------- crates/transaction-pool/tests/it/blobs.rs | 2 -- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index 255dd2a01..324392c56 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -13,11 +13,11 @@ use rand::{ }; use reth_primitives::{ constants::{eip4844::DATA_GAS_PER_BLOB, MIN_PROTOCOL_BASE_FEE}, - hex, AccessList, Address, Bytes, FromRecoveredPooledTransaction, FromRecoveredTransaction, - IntoRecoveredTransaction, PooledTransactionsElementEcRecovered, Signature, Transaction, - TransactionKind, TransactionSigned, TransactionSignedEcRecovered, TxEip1559, TxEip2930, - TxEip4844, TxHash, TxLegacy, TxType, TxValue, B256, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, - EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, U128, U256, + hex, AccessList, Address, BlobTransactionSidecar, Bytes, FromRecoveredPooledTransaction, + FromRecoveredTransaction, IntoRecoveredTransaction, PooledTransactionsElementEcRecovered, + Signature, Transaction, TransactionKind, TransactionSigned, TransactionSignedEcRecovered, + TxEip1559, TxEip2930, TxEip4844, TxHash, TxLegacy, TxType, TxValue, B256, EIP1559_TX_TYPE_ID, + EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, U128, U256, }; use std::{ops::Range, sync::Arc, time::Instant}; @@ -121,6 +121,7 @@ pub enum MockTransaction { value: U256, accesslist: AccessList, input: Bytes, + sidecar: BlobTransactionSidecar, }, Eip2930 { hash: B256, @@ -191,6 +192,7 @@ impl MockTransaction { value: Default::default(), input: Bytes::new(), accesslist: Default::default(), + sidecar: Default::default(), } } @@ -642,6 +644,7 @@ impl FromRecoveredTransaction for MockTransaction { value: value.into(), input, accesslist: access_list, + sidecar: BlobTransactionSidecar::default(), }, Transaction::Eip2930(TxEip2930 { chain_id: _, @@ -742,6 +745,7 @@ impl From for Transaction { value, accesslist, input, + sidecar, } => Self::Eip4844(TxEip4844 { chain_id: 1, nonce, @@ -785,8 +789,8 @@ impl proptest::arbitrary::Arbitrary for MockTransaction { fn arbitrary_with(_: Self::Parameters) -> Self::Strategy { use proptest::prelude::{any, Strategy}; - any::<(Transaction, Address, B256)>() - .prop_map(|(tx, sender, tx_hash)| match &tx { + any::<(Transaction, Address, B256, BlobTransactionSidecar)>() + .prop_map(|(tx, sender, tx_hash, sidecar)| match &tx { Transaction::Legacy(TxLegacy { nonce, gas_price, @@ -859,6 +863,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction { value: (*value).into(), input: (*input).clone(), accesslist: (*access_list).clone(), + sidecar, }, }) .boxed() diff --git a/crates/transaction-pool/tests/it/blobs.rs b/crates/transaction-pool/tests/it/blobs.rs index e3043a40f..cdcce9de3 100644 --- a/crates/transaction-pool/tests/it/blobs.rs +++ b/crates/transaction-pool/tests/it/blobs.rs @@ -10,8 +10,6 @@ use reth_transaction_pool::{ async fn blobs_exclusive() { let txpool = testing_pool(); let mut mock_tx_factory = MockTransactionFactory::default(); - // TODO: add blob sidecar to mock_eip4844_tx returned here so we can test the - // BlobTxSidecarListener in tx_pool let blob_tx = mock_tx_factory.create_eip4844(); let hash = txpool