Skip to content

Commit

Permalink
feat: Exclude private txs for pending block (paradigmxyz#6015)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
supernovahs and mattsse authored Jan 11, 2024
1 parent 4660da4 commit 6430731
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions crates/rpc/rpc/src/eth/api/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ impl PendingBlockEnv {
continue
}

if pool_tx.origin.is_private() {
// we don't want to leak any state changes made by private transactions, so we mark
// them as invalid here which removes all dependent transactions from the iterator
// before we can continue
best_txs.mark_invalid(&pool_tx);
continue;
}

// convert tx to a signed transaction
let tx = pool_tx.to_recovered_transaction();

Expand Down
11 changes: 10 additions & 1 deletion crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,18 @@ pub enum TransactionOrigin {

impl TransactionOrigin {
/// Whether the transaction originates from a local source.
pub fn is_local(&self) -> bool {
pub const fn is_local(&self) -> bool {
matches!(self, TransactionOrigin::Local)
}

/// Whether the transaction originates from an external source.
pub const fn is_external(&self) -> bool {
matches!(self, TransactionOrigin::External)
}
/// Whether the transaction originates from a private source.
pub const fn is_private(&self) -> bool {
matches!(self, TransactionOrigin::Private)
}
}

/// Represents changes after a new canonical block or range of canonical blocks was added to the
Expand Down

0 comments on commit 6430731

Please sign in to comment.