swapclientserver: scope reconnect waiting - #952
Conversation
|
@claude Please review this follow-up with the regression context from #951 and #949 in mind. The key invariant is that durable/state-changing swap RPCs must still wait through a late swapd start or reconnect, while optional reads such as |
|
Claude finished @bhandras's task in 2m 4s —— View job Review —
|
There was a problem hiding this comment.
Code Review
This pull request replaces the global WaitForReady gRPC dial option with a unary interceptor (swapServerWaitForReadyInterceptor) that selectively applies the reconnect policy. This ensures that only protocol-advancing swap operations wait for the server to reconnect, while read-only queries (such as quotes and credit snapshots) fail fast to prevent consuming the caller's context deadline. Accompanying unit tests have been added to verify this behavior. I have no feedback to provide as the implementation is clean and well-tested.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
A channel-wide wait-for-ready setting caused optional credit balance reads to block until their parent wallet RPC timed out whenever the swap server was unavailable. Apply wait-for-ready only to operations that create or advance swap state. Keep quotes, credit snapshots, and unrelated mailbox calls fail-fast so callers can apply their existing fallback behavior. Cover both sides of the policy: state-changing calls still survive a late server start, while ListCredits returns Unavailable before its context expires.
c39722d to
4491be7
Compare
|
@claude Thanks, all three non-blocking suggestions are folded into the original commit:
After folding, the focused package tests, formatter check, commit-message lint, and local lint all pass. I also reran swapdk-server's exact downstream |
|
Claude finished @bhandras's task in 44s —— View job Re-review —
|
Problem
The daemon configures one gRPC channel for swapd. PR #949 made that entire channel use
WaitForReady(true)so a state-changing swap RPC can survive swapd starting or reconnecting after the daemon.That channel-wide policy also changed optional read-only calls. In particular,
swapwallet.Service.fetchBalancefirst obtains the Ark balance and then callsListCreditsas an optional enrichment. The wallet deliberately ignores a failed credit read and can return the Ark balance alone. With the global wait-for-ready option, however, an unavailable swapd makesListCreditsconsume the parent request's full deadline. The already-computed balance can no longer be returned because the wallet RPC context has expired.This surfaced in swapdk-server PR #228 as
TestWalletBalanceSurfacesUnilateralExitfailing its first balance request withDeadlineExceeded.Changes
QuoteInSwap,ListCredits, mailbox calls, and unknown methods fail-fast.CreateInSwapand the other durable protocol operations.Policy
Wait for swapd to become ready:
RequestChannelIdCreateInSwapCreateCreditRedeemCreditAuthorizeInSwapRefundAcknowledgeOutSwapHtlcSignInSwapForfeitSubmitOutSwapForfeitSignatureFail fast when swapd is unavailable:
QuoteInSwapListCreditsTests
Added an unavailable-server regression proving
ListCreditsreturnsUnavailablebefore its context expires.Added a table test that locks down the method-level reconnect policy.
Preserved and reran the swapclientserver: Wait for swapd reconnects #949 regression proving
CreateInSwapwaits through a late server start.Reran the exact downstream failure against swapdk-server PR btcwbackend: add neutrino+btcwallet wallet mode #228:
TestWalletBalanceSurfacesUnilateralExitpassed in 37.2 seconds.go test -tags='swapruntime' ./swapclientserver -count=1make fmt-changed-check base=origin/mainmake lint-localmake commitmsg-lint range=origin/main..HEADFixes #951.