Skip to content

fix(node): stop a top-up for one pool from joining a settling topUp for another #2496

Closed

Description

@thiras

Problem

The node has one top-up slot (topup_in_flight), and that slot does not record which pool its topUp funds.

join_or_spawn_topup(pool_id, ..) (crates/node/src/buyer_pool.rs) joins any topUp in flight. InFlightTopUp stores no pool_id, so the join does not compare pools.

Before #2492 a topUp held the slot only until its receipt arrived. Now settle_unconfirmed_top_up holds it until the chain resolves the topUp. That can take a long time, and the pool can be replaced meanwhile: it closes, and recovery opens a new one. In that case:

  • A recovery top-up for the new pool joins the old pool's topUp. That topUp escrows into the old pool, so it cannot fund the new one.
  • When the settle ends, it credits the old pool's row, which no longer exists. It ends with EscrowedUntracked. A joiner treats that error as final (retryable_join_error), so the new pool's recovery fails, and nothing escrows into the new pool.
  • A low-water refill of the new pool does nothing while the slot is held.

So funding for the new pool stops until the old pool's topUp settles.

Fix direction

Choose one:

  • Store the pool_id in InFlightTopUp. A caller for another pool does not join. It fails at once as a local fault, or it waits for the slot to free.
  • Key the slot by pool, so that a topUp for the new pool can run beside one that is settling for the old pool. One wallet sends both, so the second topUp takes a later nonce, and it cannot mine until the settling topUp's nonce is spent.

Either way, a join must never count headroom that a topUp escrowed into another pool.

Checks

  • A topUp for pool A is settling, and the row now tracks pool B. A recovery for B does not join A's topUp, and does not get A's EscrowedUntracked error.
  • The existing join and claim tests (top_up_at_least_*) still pass.

Follow-up from the #2492 review.

Activity

  1. self-assigned this
    on Oct 17, 2026
  2. assigned and unassigned on Oct 17, 2026
  3. moved this from Backlog to In progress in deCDNon Oct 17, 2026
  4. moved this from In progress to Done in deCDNon Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions