Repository navigation
round: queue board triggers with AskThen instead of Await - #1379
Merged
Merged
Conversation
Roasbeef
force-pushed
the
round-board-askthen
branch
from
October 3, 2026 22:19
7966c13 to
92db711
Compare
Roasbeef
force-pushed
the
round-board-askthen
branch
2 times, most recently
from
October 5, 2026 23:59
8123e12 to
a60509d
Compare
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
force-pushed
the
round-board-askthen
branch
from
October 6, 2026 00:33
a60509d to
a605225
Compare
Roasbeef
marked this pull request as ready for review
October 6, 2026 01:10
litbot-9000
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
handleTriggerBoardasked 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 30sdefaultWalletAskTimeoutfires. 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.handleTriggerBoardvalidates 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 internalboardingIntentsReplymessage, 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
AskThendelivery 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
RegisterIntentMsgand waits for the reply before answering the boarding query. Both complete well under a second. With the old blockingaskWalletput 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.