Skip to content

Commit

Permalink
chore: remove PooledTransactionsElement alias (#13384)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 13, 2024
1 parent 197f274 commit b67e5a2
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 113 deletions.
7 changes: 2 additions & 5 deletions crates/ethereum/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use reth_node_builder::{
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{EthPrimitives, PooledTransactionsElement};
use reth_primitives::{EthPrimitives, PooledTransaction};
use reth_provider::{CanonStateSubscriptions, EthStorage};
use reth_rpc::EthApi;
use reth_tracing::tracing::{debug, info};
Expand Down Expand Up @@ -312,10 +312,7 @@ impl<Node, Pool> NetworkBuilder<Node, Pool> for EthereumNetworkBuilder
where
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec, Primitives = EthPrimitives>>,
Pool: TransactionPool<
Transaction: PoolTransaction<
Consensus = TxTy<Node::Types>,
Pooled = PooledTransactionsElement,
>,
Transaction: PoolTransaction<Consensus = TxTy<Node::Types>, Pooled = PooledTransaction>,
> + Unpin
+ 'static,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/net/eth-wire-types/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ impl NetworkPrimitives for EthNetworkPrimitives {
type BlockBody = reth_primitives::BlockBody;
type Block = reth_primitives::Block;
type BroadcastedTransaction = reth_primitives::TransactionSigned;
type PooledTransaction = reth_primitives::PooledTransactionsElement;
type PooledTransaction = reth_primitives::PooledTransaction;
type Receipt = reth_primitives::Receipt;
}
32 changes: 16 additions & 16 deletions crates/net/eth-wire-types/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloy_primitives::B256;
use alloy_rlp::{RlpDecodableWrapper, RlpEncodableWrapper};
use derive_more::{Constructor, Deref, IntoIterator};
use reth_codecs_derive::add_arbitrary_tests;
use reth_primitives::PooledTransactionsElement;
use reth_primitives::PooledTransaction;

/// A list of transaction hashes that the peer would like transaction bodies for.
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
Expand Down Expand Up @@ -46,7 +46,7 @@ where
Constructor,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PooledTransactions<T = PooledTransactionsElement>(
pub struct PooledTransactions<T = PooledTransaction>(
/// The transaction bodies, each of which should correspond to a requested hash.
pub Vec<T>,
);
Expand Down Expand Up @@ -88,7 +88,7 @@ mod tests {
use alloy_primitives::{hex, PrimitiveSignature as Signature, TxKind, U256};
use alloy_rlp::{Decodable, Encodable};
use reth_chainspec::MIN_TRANSACTION_GAS;
use reth_primitives::{PooledTransactionsElement, Transaction, TransactionSigned};
use reth_primitives::{PooledTransaction, Transaction, TransactionSigned};
use std::str::FromStr;

#[test]
Expand Down Expand Up @@ -175,17 +175,17 @@ mod tests {
),
),
];
let message: Vec<PooledTransactionsElement> = txs
let message: Vec<PooledTransaction> = txs
.into_iter()
.map(|tx| {
PooledTransactionsElement::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransactionsElement")
PooledTransaction::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransaction")
})
.collect();
let request = RequestPair {
request_id: 1111,
message: PooledTransactions(message), /* Assuming PooledTransactions wraps a
* Vec<PooledTransactionsElement> */
* Vec<PooledTransaction> */
};
request.encode(&mut data);
assert_eq!(data, expected);
Expand Down Expand Up @@ -241,11 +241,11 @@ mod tests {
),
),
];
let message: Vec<PooledTransactionsElement> = txs
let message: Vec<PooledTransaction> = txs
.into_iter()
.map(|tx| {
PooledTransactionsElement::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransactionsElement")
PooledTransaction::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransaction")
})
.collect();
let expected = RequestPair { request_id: 1111, message: PooledTransactions(message) };
Expand Down Expand Up @@ -373,11 +373,11 @@ mod tests {
),
),
];
let message: Vec<PooledTransactionsElement> = txs
let message: Vec<PooledTransaction> = txs
.into_iter()
.map(|tx| {
PooledTransactionsElement::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransactionsElement")
PooledTransaction::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransaction")
})
.collect();
let expected_transactions =
Expand Down Expand Up @@ -510,11 +510,11 @@ mod tests {
),
),
];
let message: Vec<PooledTransactionsElement> = txs
let message: Vec<PooledTransaction> = txs
.into_iter()
.map(|tx| {
PooledTransactionsElement::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransactionsElement")
PooledTransaction::try_from(tx)
.expect("Failed to convert TransactionSigned to PooledTransaction")
})
.collect();
let transactions = RequestPair { request_id: 0, message: PooledTransactions(message) };
Expand Down
6 changes: 3 additions & 3 deletions crates/net/eth-wire/tests/pooled_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy_eips::eip2718::Decodable2718;
use alloy_primitives::hex;
use alloy_rlp::{Decodable, Encodable};
use reth_eth_wire::{EthNetworkPrimitives, EthVersion, PooledTransactions, ProtocolMessage};
use reth_primitives::PooledTransactionsElement;
use reth_primitives::PooledTransaction;
use std::{fs, path::PathBuf};
use test_fuzz::test_fuzz;

Expand Down Expand Up @@ -61,7 +61,7 @@ fn decode_blob_transaction_data() {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testdata/blob_transaction");
let data = fs::read_to_string(network_data_path).expect("Unable to read file");
let hex_data = hex::decode(data.trim()).unwrap();
let _txs = PooledTransactionsElement::decode(&mut &hex_data[..]).unwrap();
let _txs = PooledTransaction::decode(&mut &hex_data[..]).unwrap();
}

#[test]
Expand All @@ -71,5 +71,5 @@ fn decode_blob_rpc_transaction() {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testdata/rpc_blob_transaction");
let data = fs::read_to_string(network_data_path).expect("Unable to read file");
let hex_data = hex::decode(data.trim()).unwrap();
let _txs = PooledTransactionsElement::decode_2718(&mut hex_data.as_ref()).unwrap();
let _txs = PooledTransaction::decode_2718(&mut hex_data.as_ref()).unwrap();
}
17 changes: 4 additions & 13 deletions crates/net/network/src/test_utils/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use reth_network_api::{
NetworkEvent, NetworkEventListenerProvider, NetworkInfo, Peers,
};
use reth_network_peers::PeerId;
use reth_primitives::{PooledTransactionsElement, TransactionSigned};
use reth_primitives::{PooledTransaction, TransactionSigned};
use reth_storage_api::{
noop::NoopProvider, BlockReader, BlockReaderIdExt, HeaderProvider, StateProviderFactory,
};
Expand Down Expand Up @@ -229,10 +229,7 @@ where
+ Unpin
+ 'static,
Pool: TransactionPool<
Transaction: PoolTransaction<
Consensus = TransactionSigned,
Pooled = PooledTransactionsElement,
>,
Transaction: PoolTransaction<Consensus = TransactionSigned, Pooled = PooledTransaction>,
> + Unpin
+ 'static,
{
Expand Down Expand Up @@ -300,10 +297,7 @@ where
+ Unpin
+ 'static,
Pool: TransactionPool<
Transaction: PoolTransaction<
Consensus = TransactionSigned,
Pooled = PooledTransactionsElement,
>,
Transaction: PoolTransaction<Consensus = TransactionSigned, Pooled = PooledTransaction>,
> + Unpin
+ 'static,
{
Expand Down Expand Up @@ -537,10 +531,7 @@ where
+ Unpin
+ 'static,
Pool: TransactionPool<
Transaction: PoolTransaction<
Consensus = TransactionSigned,
Pooled = PooledTransactionsElement,
>,
Transaction: PoolTransaction<Consensus = TransactionSigned, Pooled = PooledTransaction>,
> + Unpin
+ 'static,
{
Expand Down
14 changes: 7 additions & 7 deletions crates/net/network/src/transactions/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use reth_eth_wire_types::{EthNetworkPrimitives, NetworkPrimitives};
use reth_network_api::PeerRequest;
use reth_network_p2p::error::{RequestError, RequestResult};
use reth_network_peers::PeerId;
use reth_primitives::PooledTransactionsElement;
use reth_primitives::PooledTransaction;
use reth_primitives_traits::SignedTransaction;
use schnellru::ByLength;
#[cfg(debug_assertions)]
Expand Down Expand Up @@ -1084,7 +1084,7 @@ impl TxFetchMetadata {

/// Represents possible events from fetching transactions.
#[derive(Debug)]
pub enum FetchEvent<T = PooledTransactionsElement> {
pub enum FetchEvent<T = PooledTransaction> {
/// Triggered when transactions are successfully fetched.
TransactionsFetched {
/// The ID of the peer from which transactions were fetched.
Expand All @@ -1108,7 +1108,7 @@ pub enum FetchEvent<T = PooledTransactionsElement> {

/// An inflight request for [`PooledTransactions`] from a peer.
#[derive(Debug)]
pub struct GetPooledTxRequest<T = PooledTransactionsElement> {
pub struct GetPooledTxRequest<T = PooledTransaction> {
peer_id: PeerId,
/// Transaction hashes that were requested, for cleanup purposes
requested_hashes: RequestTxHashes,
Expand All @@ -1118,7 +1118,7 @@ pub struct GetPooledTxRequest<T = PooledTransactionsElement> {
/// Upon reception of a response, a [`GetPooledTxRequest`] is deconstructed to form a
/// [`GetPooledTxResponse`].
#[derive(Debug)]
pub struct GetPooledTxResponse<T = PooledTransactionsElement> {
pub struct GetPooledTxResponse<T = PooledTransaction> {
peer_id: PeerId,
/// Transaction hashes that were requested, for cleanup purposes, since peer may only return a
/// subset of requested hashes.
Expand All @@ -1131,7 +1131,7 @@ pub struct GetPooledTxResponse<T = PooledTransactionsElement> {
#[must_use = "futures do nothing unless polled"]
#[pin_project::pin_project]
#[derive(Debug)]
pub struct GetPooledTxRequestFut<T = PooledTransactionsElement> {
pub struct GetPooledTxRequestFut<T = PooledTransaction> {
#[pin]
inner: Option<GetPooledTxRequest<T>>,
}
Expand Down Expand Up @@ -1517,10 +1517,10 @@ mod test {
#[test]
fn verify_response_hashes() {
let input = hex!("02f871018302a90f808504890aef60826b6c94ddf4c5025d1a5742cf12f74eec246d4432c295e487e09c3bbcc12b2b80c080a0f21a4eacd0bf8fea9c5105c543be5a1d8c796516875710fafafdf16d16d8ee23a001280915021bb446d1973501a67f93d2b38894a514b976e7b46dc2fe54598daa");
let signed_tx_1: PooledTransactionsElement =
let signed_tx_1: PooledTransaction =
TransactionSigned::decode(&mut &input[..]).unwrap().try_into().unwrap();
let input = hex!("02f871018302a90f808504890aef60826b6c94ddf4c5025d1a5742cf12f74eec246d4432c295e487e09c3bbcc12b2b80c080a0f21a4eacd0bf8fea9c5105c543be5a1d8c796516875710fafafdf16d16d8ee23a001280915021bb446d1973501a67f93d2b38894a514b976e7b46dc2fe54598d76");
let signed_tx_2: PooledTransactionsElement =
let signed_tx_2: PooledTransaction =
TransactionSigned::decode(&mut &input[..]).unwrap().try_into().unwrap();

// only tx 1 is requested
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/transactions/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait ValidateTx68 {

/// Returns the reasonable minimum encoded transaction length, if any. This property is not
/// spec'ed out but can be inferred by looking at which
/// [`reth_primitives::PooledTransactionsElement`] will successfully pass decoding
/// [`reth_primitives::PooledTransaction`] will successfully pass decoding
/// for any given transaction type.
fn min_encoded_tx_length(&self, ty: TxType) -> Option<usize>;

Expand Down
6 changes: 3 additions & 3 deletions crates/node/builder/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use reth_node_core::{
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
};
use reth_payload_builder::PayloadStore;
use reth_primitives::{EthPrimitives, PooledTransactionsElement};
use reth_primitives::{EthPrimitives, PooledTransaction};
use reth_provider::providers::ProviderNodeTypes;
use reth_rpc::{
eth::{EthApiTypes, FullEthApiServer},
Expand Down Expand Up @@ -405,7 +405,7 @@ where
impl<N, EthApi, EV> RpcAddOns<N, EthApi, EV>
where
N: FullNodeComponents<
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransactionsElement>>,
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
>,
EthApi: EthApiTypes
+ FullEthApiServer<Provider = N::Provider, Pool = N::Pool, Network = N::Network>
Expand Down Expand Up @@ -536,7 +536,7 @@ impl<N, EthApi, EV> NodeAddOns<N> for RpcAddOns<N, EthApi, EV>
where
N: FullNodeComponents<
Types: ProviderNodeTypes<Primitives = EthPrimitives>,
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransactionsElement>>,
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
>,
EthApi: EthApiTypes
+ FullEthApiServer<Provider = N::Provider, Pool = N::Pool, Network = N::Network>
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/cli/src/ovm_file_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Decodable for TransactionSigned {
/// This cannot be used for decoding EIP-4844 transactions in p2p `PooledTransactions`, since
/// the EIP-4844 variant of [`TransactionSigned`] does not include the blob sidecar.
///
/// For a method suitable for decoding pooled transactions, see \[`PooledTransactionsElement`\].
/// For a method suitable for decoding pooled transactions, see \[`PooledTransaction`\].
///
/// CAUTION: Due to a quirk in [`Header::decode`], this method will succeed even if a typed
/// transaction is encoded in this format, and does not start with a RLP header:
Expand Down
11 changes: 4 additions & 7 deletions crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use reth_optimism_rpc::{
OpEthApi, SequencerClient,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{BlockBody, PooledTransactionsElement, TransactionSigned};
use reth_primitives::{BlockBody, PooledTransaction, TransactionSigned};
use reth_provider::{
providers::ChainStorage, BlockBodyReader, BlockBodyWriter, CanonStateSubscriptions,
ChainSpecProvider, DBProvider, EthStorage, ProviderResult, ReadBodyInput, StorageLocation,
Expand Down Expand Up @@ -252,7 +252,7 @@ where
Storage = OpStorage,
Engine = OpEngineTypes,
>,
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransactionsElement>>,
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
>,
OpEngineValidator: EngineValidator<<N::Types as NodeTypesWithEngine>::Engine>,
{
Expand Down Expand Up @@ -303,7 +303,7 @@ where
Storage = OpStorage,
Engine = OpEngineTypes,
>,
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransactionsElement>>,
Pool: TransactionPool<Transaction: PoolTransaction<Pooled = PooledTransaction>>,
>,
OpEngineValidator: EngineValidator<<N::Types as NodeTypesWithEngine>::Engine>,
{
Expand Down Expand Up @@ -666,10 +666,7 @@ impl<Node, Pool> NetworkBuilder<Node, Pool> for OpNetworkBuilder
where
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec, Primitives = OpPrimitives>>,
Pool: TransactionPool<
Transaction: PoolTransaction<
Consensus = TxTy<Node::Types>,
Pooled = PooledTransactionsElement,
>,
Transaction: PoolTransaction<Consensus = TxTy<Node::Types>, Pooled = PooledTransaction>,
> + Unpin
+ 'static,
{
Expand Down
8 changes: 3 additions & 5 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ pub use reth_primitives_traits::{
};
pub use static_file::StaticFileSegment;

pub use alloy_consensus::{transaction::PooledTransaction, ReceiptWithBloom};
pub use transaction::{
util::secp256k1::{public_key_to_address, recover_signer_unchecked, sign_message},
InvalidTransactionError, PooledTransactionsElement, PooledTransactionsElementEcRecovered,
RecoveredTx, Transaction, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered,
TxType,
InvalidTransactionError, PooledTransactionsElementEcRecovered, RecoveredTx, Transaction,
TransactionMeta, TransactionSigned, TransactionSignedEcRecovered, TxType,
};

pub use alloy_consensus::ReceiptWithBloom;

// Re-exports
pub use reth_ethereum_forks::*;

Expand Down
Loading

0 comments on commit b67e5a2

Please sign in to comment.