Skip to content

Commit

Permalink
feat(tx-pool): add blob_sidecar to EIP-4844 mock transactions (para…
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Oct 22, 2023
1 parent 0088ba4 commit 55a7871
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 12 additions & 7 deletions crates/transaction-pool/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -121,6 +121,7 @@ pub enum MockTransaction {
value: U256,
accesslist: AccessList,
input: Bytes,
sidecar: BlobTransactionSidecar,
},
Eip2930 {
hash: B256,
Expand Down Expand Up @@ -191,6 +192,7 @@ impl MockTransaction {
value: Default::default(),
input: Bytes::new(),
accesslist: Default::default(),
sidecar: Default::default(),
}
}

Expand Down Expand Up @@ -642,6 +644,7 @@ impl FromRecoveredTransaction for MockTransaction {
value: value.into(),
input,
accesslist: access_list,
sidecar: BlobTransactionSidecar::default(),
},
Transaction::Eip2930(TxEip2930 {
chain_id: _,
Expand Down Expand Up @@ -742,6 +745,7 @@ impl From<MockTransaction> for Transaction {
value,
accesslist,
input,
sidecar,
} => Self::Eip4844(TxEip4844 {
chain_id: 1,
nonce,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -859,6 +863,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
value: (*value).into(),
input: (*input).clone(),
accesslist: (*access_list).clone(),
sidecar,
},
})
.boxed()
Expand Down
2 changes: 0 additions & 2 deletions crates/transaction-pool/tests/it/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55a7871

Please sign in to comment.