Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ eyre = "0.6"
fdlimit = "0.3.0"
fixed-map = { version = "0.9", default-features = false }
humantime = "2.1"
imbl = "7"
humantime-serde = "1.1"
itertools = { version = "0.14", default-features = false }
linked_hash_set = "0.1"
Expand Down
4 changes: 4 additions & 0 deletions crates/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ serde = { workspace = true, features = ["derive", "rc"] }
serde_json.workspace = true
bitflags.workspace = true
auto_impl.workspace = true
imbl.workspace = true
smallvec.workspace = true

# testing
Expand Down Expand Up @@ -84,6 +85,7 @@ serde = [
"alloy-eips/serde",
"alloy-primitives/serde",
"bitflags/serde",
"imbl/serde",
"parking_lot/serde",
"rand?/serde",
"smallvec/serde",
Expand Down Expand Up @@ -112,6 +114,7 @@ test-utils = [
arbitrary = [
"proptest",
"proptest-arbitrary-interop",
"imbl/arbitrary",
"reth-chainspec/arbitrary",
"reth-eth-wire-types/arbitrary",
"alloy-consensus/arbitrary",
Expand All @@ -124,4 +127,5 @@ arbitrary = [
"reth-ethereum-primitives/arbitrary",
"revm-primitives/arbitrary",
"revm/arbitrary",
"imbl/arbitrary",
]
2 changes: 2 additions & 0 deletions crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

pub use imbl::OrdMap;

pub use crate::{
batcher::{BatchTxProcessor, BatchTxRequest},
blobstore::{BlobStore, BlobStoreError},
Expand Down
5 changes: 3 additions & 2 deletions crates/transaction-pool/src/pool/best.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use crate::{
use alloy_consensus::Transaction;
use alloy_primitives::map::AddressSet;
use core::fmt;
use imbl::OrdMap;
use reth_primitives_traits::transaction::error::InvalidTransactionError;
use std::{
collections::{BTreeMap, BTreeSet, HashSet, VecDeque},
collections::{BTreeSet, HashSet, VecDeque},
sync::Arc,
};
use tokio::sync::broadcast::{error::TryRecvError, Receiver};
Expand Down Expand Up @@ -84,7 +85,7 @@ impl<T: TransactionOrdering> Iterator for BestTransactionsWithFees<T> {
pub struct BestTransactions<T: TransactionOrdering> {
/// Contains a copy of _all_ transactions of the pending pool at the point in time this
/// iterator was created.
pub(crate) all: BTreeMap<TransactionId, PendingTransaction<T>>,
pub(crate) all: OrdMap<TransactionId, PendingTransaction<T>>,
/// Transactions that can be executed right away: these have the expected nonce.
///
/// Once an `independent` transaction with the nonce `N` is returned, it unlocks `N+1`, which
Expand Down
14 changes: 5 additions & 9 deletions crates/transaction-pool/src/pool/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ use crate::{
},
Priority, SubPoolLimit, TransactionOrdering, ValidPoolTransaction,
};
use imbl::OrdMap;
use rustc_hash::{FxHashMap, FxHashSet};
use std::{
cmp::Ordering,
collections::{hash_map::Entry, BTreeMap},
ops::Bound::Unbounded,
sync::Arc,
};
use std::{cmp::Ordering, collections::hash_map::Entry, ops::Bound::Unbounded, sync::Arc};
use tokio::sync::broadcast;

/// A pool of validated and gapless transactions that are ready to be executed on the current state
Expand All @@ -36,7 +32,7 @@ pub struct PendingPool<T: TransactionOrdering> {
/// This way we can determine when transactions were submitted to the pool.
submission_id: u64,
/// _All_ Transactions that are currently inside the pool grouped by their identifier.
by_id: BTreeMap<TransactionId, PendingTransaction<T>>,
by_id: OrdMap<TransactionId, PendingTransaction<T>>,
/// The highest nonce transactions for each sender - like the `independent` set, but the
/// highest instead of lowest nonce.
highest_nonces: FxHashMap<SenderId, PendingTransaction<T>>,
Expand Down Expand Up @@ -80,7 +76,7 @@ impl<T: TransactionOrdering> PendingPool<T> {
/// # Returns
///
/// Returns all transactions by id.
fn clear_transactions(&mut self) -> BTreeMap<TransactionId, PendingTransaction<T>> {
fn clear_transactions(&mut self) -> OrdMap<TransactionId, PendingTransaction<T>> {
self.independent_transactions.clear();
self.highest_nonces.clear();
self.size_of.reset();
Expand Down Expand Up @@ -525,7 +521,7 @@ impl<T: TransactionOrdering> PendingPool<T> {
}

/// All transactions grouped by id
pub const fn by_id(&self) -> &BTreeMap<TransactionId, PendingTransaction<T>> {
pub const fn by_id(&self) -> &OrdMap<TransactionId, PendingTransaction<T>> {
Comment thread
DaniPopes marked this conversation as resolved.
&self.by_id
}

Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ allow = [
# https://github.com/rustls/webpki/blob/main/LICENSE ISC Style
"LicenseRef-rustls-webpki",
"CDLA-Permissive-2.0",
"MPL-2.0",
]

# Allow 1 or more licenses on a per-crate basis, so that particular licenses
Expand Down
Loading