feat(tx-pool): add blob_sidecar to EIP-4844 mock transactions (#5132)

This commit is contained in:
Thomas Coratger
2023-10-22 20:22:13 +02:00
committed by GitHub
parent 0088ba4553
commit 55a78719bd
2 changed files with 12 additions and 9 deletions

View File

@ -13,11 +13,11 @@ use rand::{
}; };
use reth_primitives::{ use reth_primitives::{
constants::{eip4844::DATA_GAS_PER_BLOB, MIN_PROTOCOL_BASE_FEE}, constants::{eip4844::DATA_GAS_PER_BLOB, MIN_PROTOCOL_BASE_FEE},
hex, AccessList, Address, Bytes, FromRecoveredPooledTransaction, FromRecoveredTransaction, hex, AccessList, Address, BlobTransactionSidecar, Bytes, FromRecoveredPooledTransaction,
IntoRecoveredTransaction, PooledTransactionsElementEcRecovered, Signature, Transaction, FromRecoveredTransaction, IntoRecoveredTransaction, PooledTransactionsElementEcRecovered,
TransactionKind, TransactionSigned, TransactionSignedEcRecovered, TxEip1559, TxEip2930, Signature, Transaction, TransactionKind, TransactionSigned, TransactionSignedEcRecovered,
TxEip4844, TxHash, TxLegacy, TxType, TxValue, B256, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, TxEip1559, TxEip2930, TxEip4844, TxHash, TxLegacy, TxType, TxValue, B256, EIP1559_TX_TYPE_ID,
EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, U128, U256, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, U128, U256,
}; };
use std::{ops::Range, sync::Arc, time::Instant}; use std::{ops::Range, sync::Arc, time::Instant};
@ -121,6 +121,7 @@ pub enum MockTransaction {
value: U256, value: U256,
accesslist: AccessList, accesslist: AccessList,
input: Bytes, input: Bytes,
sidecar: BlobTransactionSidecar,
}, },
Eip2930 { Eip2930 {
hash: B256, hash: B256,
@ -191,6 +192,7 @@ impl MockTransaction {
value: Default::default(), value: Default::default(),
input: Bytes::new(), input: Bytes::new(),
accesslist: Default::default(), accesslist: Default::default(),
sidecar: Default::default(),
} }
} }
@ -642,6 +644,7 @@ impl FromRecoveredTransaction for MockTransaction {
value: value.into(), value: value.into(),
input, input,
accesslist: access_list, accesslist: access_list,
sidecar: BlobTransactionSidecar::default(),
}, },
Transaction::Eip2930(TxEip2930 { Transaction::Eip2930(TxEip2930 {
chain_id: _, chain_id: _,
@ -742,6 +745,7 @@ impl From<MockTransaction> for Transaction {
value, value,
accesslist, accesslist,
input, input,
sidecar,
} => Self::Eip4844(TxEip4844 { } => Self::Eip4844(TxEip4844 {
chain_id: 1, chain_id: 1,
nonce, nonce,
@ -785,8 +789,8 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy { fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
use proptest::prelude::{any, Strategy}; use proptest::prelude::{any, Strategy};
any::<(Transaction, Address, B256)>() any::<(Transaction, Address, B256, BlobTransactionSidecar)>()
.prop_map(|(tx, sender, tx_hash)| match &tx { .prop_map(|(tx, sender, tx_hash, sidecar)| match &tx {
Transaction::Legacy(TxLegacy { Transaction::Legacy(TxLegacy {
nonce, nonce,
gas_price, gas_price,
@ -859,6 +863,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
value: (*value).into(), value: (*value).into(),
input: (*input).clone(), input: (*input).clone(),
accesslist: (*access_list).clone(), accesslist: (*access_list).clone(),
sidecar,
}, },
}) })
.boxed() .boxed()

View File

@ -10,8 +10,6 @@ use reth_transaction_pool::{
async fn blobs_exclusive() { async fn blobs_exclusive() {
let txpool = testing_pool(); let txpool = testing_pool();
let mut mock_tx_factory = MockTransactionFactory::default(); 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 blob_tx = mock_tx_factory.create_eip4844();
let hash = txpool let hash = txpool