Skip to content

feat(mempool): tip-based eviction and nonce-ordered lanes #1123

Open

Description

@erhant

Problem

Follow-ups from the tip-ordered mempool in #880. Two related gaps:

1. No tip-based eviction. A full pool rejects every arrival, whatever its tip. Zero-tip transactions can fill the pool and keep any higher bid out, so tip ordering does not hold under load. The pool cannot evict at admission today: MemPoolHandle is only a channel sender and does not see what the pool holds.

2. Lanes follow arrival order, not nonce. If a signer's nonce n+1 arrives before nonce n, it heads the lane, fails the nonce check and is dropped. This now happens routinely: resubmit_orphaned puts reorged transactions back with try_push, at the back. If Alice's orphaned nonce 5 comes back after her nonce 6 is already in the pool, nonce 6 is dropped.

Why they are coupled

Ordering lanes by nonce can deadlock with several signers:

tx1: {Alice: 0, Bob: 1}
tx2: {Alice: 1, Bob: 0}

Each waits on the other, so both would stay in the pool for ever. Ordering by arrival avoids this by dropping on mismatch. Ordering by nonce needs eviction or expiry to clear such transactions.

Open questions

  • Admission semantics. With eviction, a transaction that was accepted can be dropped later. Is that acceptable for RPC and gossip submitters? Should the RPC say "queued" rather than "accepted"?
  • Admission access. Share the pool behind a lock so admission can compare against what it holds, or enforce a minimum tip at admission once the pool passes a high-water mark?
  • What to evict. Only lane tails (items no other item waits on), so no nonce gap opens. Lowest priority first, where priority is tip per declared gas (fix(sequencer): prioritize fee tips on tx ordering #880).
  • Expiry. A time or block-count TTL, so stuck transactions (deadlocked, parked, or with a nonce gap) eventually leave.
  • Nonce lanes. lanes_of could return (signer, nonce) and lanes would sort by nonce. A gap then blocks the lane until it is filled or the head expires.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions