Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bin/args): enhance transactionpool with --txpool.nolocals Flag #5538

Merged
merged 17 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
4 changes: 4 additions & 0 deletions bin/reth/src/args/txpool_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ pub struct TxPoolArgs {
/// Price bump percentage to replace an already existing blob transaction
#[arg(long = "blobpool.pricebump", default_value_t = REPLACE_BLOB_PRICE_BUMP)]
pub blob_transaction_price_bump: u128,
/// Flag to disable local transaction exemptions.
#[arg(long = "txpool.nolocals")]
pub no_locals: bool,
}

impl TxPoolArgs {
/// Returns transaction pool configuration.
pub fn pool_config(&self) -> PoolConfig {
PoolConfig {
no_locals: self.no_locals,
pending_limit: SubPoolLimit {
max_txs: self.pending_max_count,
max_size: self.pending_max_size * 1024 * 1024,
Expand Down
3 changes: 3 additions & 0 deletions crates/transaction-pool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub struct PoolConfig {
pub max_account_slots: usize,
/// Price bump (in %) for the transaction pool underpriced check.
pub price_bumps: PriceBumpConfig,
/// Flag to disable local transaction exemptions.
pub no_locals: bool,
}

impl Default for PoolConfig {
Expand All @@ -40,6 +42,7 @@ impl Default for PoolConfig {
queued_limit: Default::default(),
max_account_slots: TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
price_bumps: Default::default(),
no_locals: false,
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,9 @@ impl<T: PoolTransaction> AllTransactions<T> {
fn ensure_valid(
&self,
transaction: ValidPoolTransaction<T>,
pool_config: PoolConfig,
) -> Result<ValidPoolTransaction<T>, InsertErr<T>> {
if !transaction.origin.is_local() {
if !transaction.origin.is_local() || pool_config.no_locals {
let current_txs =
self.tx_counter.get(&transaction.sender_id()).copied().unwrap_or_default();
if current_txs >= self.max_account_slots {
Expand Down Expand Up @@ -1442,8 +1443,8 @@ impl<T: PoolTransaction> AllTransactions<T> {
on_chain_nonce: u64,
) -> InsertResult<T> {
assert!(on_chain_nonce <= transaction.nonce(), "Invalid transaction");

let mut transaction = self.ensure_valid(transaction)?;
let pool_config = PoolConfig::default();
let mut transaction = self.ensure_valid(transaction, pool_config)?;
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved

let inserted_tx_id = *transaction.id();
let mut state = TxState::default();
Expand Down
13 changes: 12 additions & 1 deletion crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ where
kzg_settings: Arc<KzgSettings>,
/// Marker for the transaction type
_marker: PhantomData<T>,
///
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
no_locals: bool,
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
}

// === impl EthTransactionValidatorInner ===
Expand Down Expand Up @@ -235,7 +237,7 @@ where

// Drop non-local transactions with a fee lower than the configured fee for acceptance into
// the pool.
if !origin.is_local() &&
if (!origin.is_local() || self.no_locals) &&
transaction.is_eip1559() &&
transaction.max_priority_fee_per_gas() < self.minimum_priority_fee
{
Expand Down Expand Up @@ -484,6 +486,8 @@ pub struct EthTransactionValidatorBuilder {

/// Stores the setup and parameters needed for validating KZG proofs.
kzg_settings: Arc<KzgSettings>,
/// Flag to enforce no local transaction exemptions
no_locals: bool,
}

impl EthTransactionValidatorBuilder {
Expand Down Expand Up @@ -511,13 +515,19 @@ impl EthTransactionValidatorBuilder {

// TODO: can hard enable by default once mainnet transitioned
cancun,
no_locals: false,
}
}

/// Disables the Cancun fork.
pub fn no_cancun(self) -> Self {
self.set_cancun(false)
}
/// Set tge no locals transactions.
DoTheBestToGetTheBest marked this conversation as resolved.
Show resolved Hide resolved
pub fn set_no_locals(mut self, no_locals: bool) -> Self {
self.no_locals = no_locals;
self
}

/// Set the Cancun fork.
pub fn set_cancun(mut self, cancun: bool) -> Self {
Expand Down Expand Up @@ -643,6 +653,7 @@ impl EthTransactionValidatorBuilder {
blob_store: Box::new(blob_store),
kzg_settings,
_marker: Default::default(),
no_locals: false,
};

EthTransactionValidator { inner: Arc::new(inner) }
Expand Down
Loading