Skip to content

round: queue board triggers with AskThen instead of Await - #1379

Merged
Roasbeef merged 1 commit into
mainfrom
round-board-askthen
Oct 6, 2026
Merged

Roasbeef merged 1 commit into
mainfrom
round-board-askthen

Conversation

@Roasbeef

@Roasbeef Roasbeef commented Oct 3, 2026

Copy link
Copy Markdown
Member

In this PR, we remove a circular wait between the round actor and the wallet actor. It is stacked on #1373 (it uses AskThen), and is independent of the policy and lint work above it in the stack.

When the wallet triggers boarding, the round actor's handleTriggerBoard asked the wallet for its confirmed boarding intents and awaited the answer inside the receive turn. The wallet's own handlers (refresh, leave, send, the send replayer) ask the round actor to register an intent and await that. If the two overlap, each actor sits on the other's reply until the 30s defaultWalletAskTimeout fires. The comment above that constant already described this, and the timeout was the only thing breaking it. Under the await-in-turn policy at Error, or the wait-cycle detector, the board attempt would instead fail outright, with a retry only at the next daemon start.

The change

Only the round to wallet edge on the trigger path moves to AskThen. handleTriggerBoard validates the amounts and puts the trigger in a FIFO queue, and only the head has a wallet fetch in flight. The reply returns as an internal boardingIntentsReply message, and the existing post-fetch logic (filtering, building the VTXO request, finding or creating the assembling round) runs unchanged in that later turn. The one-fetch-at-a-time rule keeps today's serialization: two concurrent fetches could both see the same outpoint as confirmed and register it twice.

Because AskThen delivery is at most once, the queue head has its own expiry (twice the ask timeout). It is checked when the next trigger arrives, which drops and logs a stale head and sends the next fetch. Replies carry a sequence number, so a late reply from a dropped head is ignored. Start's boot-time registration ask is not in a turn and is unchanged.

Testing

The key test runs the round actor on a real actor system. Its mock wallet asks the round actor RegisterIntentMsg and waits for the reply before answering the boarding query. Both complete well under a second. With the old blocking askWallet put back, the test fails on its guard. Further tests cover FIFO order with one fetch in flight, a wallet error that doesn't block the next queued trigger, and the expired-head drop. The existing board tests go through a new harness helper that delivers the self reply.

A caveat: a board trigger now returns Ok immediately, and a post-fetch registration failure surfaces only in the reply turn. Fetch failures are logged at Error, as before.

@Roasbeef
Roasbeef added this pull request to stack #1378 October 3, 2026 01:17
@Roasbeef
Roasbeef force-pushed the round-board-askthen branch from 7966c13 to 92db711 Compare October 3, 2026 22:19
Base automatically changed from actor-wait-cycle to main October 5, 2026 23:50
@Roasbeef
Roasbeef force-pushed the round-board-askthen branch 2 times, most recently from 8123e12 to a60509d Compare October 5, 2026 23:59
In this commit, we convert the round actor's board trigger path from
a blocking Ask of the wallet actor to actor.AskThen. The wallet Asks
the round actor with RegisterIntentMsg from several handlers, so a
round turn that waited on the wallet's boarding query could overlap
with them and leave each actor sitting on the other's reply until the
30s bound fired. Under the await-in-turn policy or the wait-cycle
detector that overlap would fail the board attempt instead.

handleTriggerBoard now validates the amounts, appends the trigger to
a FIFO queue, and sends the query for the head with AskThen. The
registration runs in a later turn when the boardingIntentsReply
arrives. At most one query is in flight, which preserves the old
serialization: concurrent fetches could let two triggers naming the
same outpoint both see it as confirmed. No FSM or keyring state is
touched before the reply turn, so a lost or late reply leaves nothing
half done. A failed fetch is logged at error level and the next
queued trigger proceeds.

The queue entries are never expired. AskThen always delivers exactly
one reply, the wallet's answer or an ask-timeout error, to a live
actor. A reply is lost only if the actor stopped or the mailbox
overflow hard cap was hit, both already-failed states, and an expiry
would instead drop a good reply that is merely queued behind a
backlog. A reply therefore always belongs to the head. Errors from
registering a board are logged in the reply turn, since the turn loop
discards a Tell handler's result. Start's registration Ask runs on the
boot goroutine while the receive loop already serves the wallet, so it
forms no circular wait and is unchanged.

The tests spawn the round actor on a real mailbox with a wallet whose
boarding query handler Asks the round actor RegisterIntentMsg first.
They also cover FIFO with one fetch in flight, a wallet error that
does not block the next trigger. The existing
board tests now deliver the reply through a harness helper. The
defaultWalletAskTimeout comment and the round package docs describe
the new behavior.
@Roasbeef
Roasbeef force-pushed the round-board-askthen branch from a60509d to a605225 Compare October 6, 2026 00:33
@Roasbeef
Roasbeef marked this pull request as ready for review October 6, 2026 01:10
@Roasbeef
Roasbeef merged commit 2939a69 into main Oct 6, 2026
52 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants