Skip to content
Merged
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
29 changes: 28 additions & 1 deletion crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ pub struct EthTransactionValidatorBuilder {
///
/// Default is 1
additional_tasks: usize,
/// Toggle to determine if a local transaction should be propagated
propagate_local_transactions: bool,
}

impl EthTransactionValidatorBuilder {
Expand All @@ -153,6 +155,7 @@ impl EthTransactionValidatorBuilder {
block_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
minimum_priority_fee: None,
additional_tasks: 1,
propagate_local_transactions: true,
}
}

Expand Down Expand Up @@ -188,6 +191,24 @@ impl EthTransactionValidatorBuilder {
self.eip1559 = eip1559;
self
}
/// Sets toggle to propagate transactions received locally by this client (e.g
/// transactions from `eth_sendRawTransaction` to this nodes' RPC server)
///
/// If set to false, only transactions received by network peers (via
/// p2p) will be marked as propagated in the local transaction pool and returned on a
/// GetPooledTransactions p2p request or broadcasted to peers.
pub fn set_propagate_local_transactions(mut self, propagate_local_txs: bool) -> Self {
self.propagate_local_transactions = propagate_local_txs;
self
}

/// Disables propagating transactions received locally by this client
///
/// For more information, check docs for set_propagate_local_transactions
pub fn no_local_transaction_propagation(mut self) -> Self {
self.propagate_local_transactions = false;
self
}

/// Sets a minimum priority fee that's enforced for acceptance into the pool.
pub fn with_minimum_priority_fee(mut self, minimum_priority_fee: u128) -> Self {
Expand Down Expand Up @@ -222,6 +243,7 @@ impl EthTransactionValidatorBuilder {
block_gas_limit,
minimum_priority_fee,
additional_tasks,
propagate_local_transactions,
} = self;

let inner = EthTransactionValidatorInner {
Expand All @@ -232,6 +254,7 @@ impl EthTransactionValidatorBuilder {
eip1559,
block_gas_limit,
minimum_priority_fee,
propagate_local_transactions,
_marker: Default::default(),
};

Expand Down Expand Up @@ -277,6 +300,8 @@ struct EthTransactionValidatorInner<Client, T> {
minimum_priority_fee: Option<u128>,
/// Marker for the transaction type
_marker: PhantomData<T>,
/// Toggle to determine if a local transaction should be propagated
propagate_local_transactions: bool,
}

// === impl EthTransactionValidatorInner ===
Expand Down Expand Up @@ -435,7 +460,9 @@ where
balance: account.balance,
state_nonce: account.nonce,
transaction,
propagate: true,
// by this point assume all external transactions should be propagated
propagate: matches!(origin, TransactionOrigin::External) ||
self.propagate_local_transactions,
}
}
}