GeezerVison is showing github.com — staticaddr/loopin: keep watching the timeout sweep after a notifier error by claravanstaden · Pull Request #1305 · lightninglabs/loop
Conversation
A static address loop-in that waits for its published HTLC timeout sweep to confirm moved to Failed when the chain notifier failed to register the confirmation watch or reported an error on it. The refund was already published at that point.
Fix
- Helper:
utils.WatchConfirmation watches one transaction until it confirms. It registers again after a delay when the registration or the stream fails, and stops when the caller cancels. The confirmation arrives on a channel, so a caller can select on several watches and on other events while a watch reconnects. It takes a clock for the retry delay and a callback per failed attempt, so the caller decides how to log. A missing retry delay defaults to 10 seconds.
- First user:
MonitorHtlcTimeoutSweepAction watches the timeout sweep with the helper and retries every 10 seconds. It logs a warning on the first failure and then about every five minutes. The loop-in config gets an optional Clock for tests.
The helper is meant to be reused by other confirmation watches, in this repo and by the server, which have the same pattern.
Tests
TestWatchConfirmation: the watch passes its parameters to the notifier, delivers the confirmation and releases the registration.
TestWatchConfirmationRetries: a registration error, a stream error, a closed channel and a nil confirmation each lead to a new registration after the delay, and the confirmation is still delivered.
TestWatchConfirmationStopsOnCancel: a canceled watch doesn't report an error or register again.
TestWatchConfirmationDefaultDelay: a watch without a retry delay waits for the default delay.
TestWatchConfirmationDefaultClock: the watch works without a clock.
TestMonitorHtlcTimeoutSweepActionRetriesNotifierError: registration and stream errors don't end the action, and the confirmation that follows finalizes the deposits. Fails with the old action body (OnError).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
A confirmation watch ends when the chain notifier fails to register it
or reports an error on its stream. Callers that treat this as fatal
abandon a transaction they already published.
WatchConfirmation watches one transaction until it confirms. It
registers again after a delay when the registration or the stream
fails, and stops when the caller cancels. The confirmation arrives on a
channel, so a caller can select on several watches and on other events
while a watch reconnects.
MonitorHtlcTimeoutSweepAction moved the loop-in to Failed when the
chain notifier failed to register the confirmation watch or reported an
error on it. The refund is already published at that point, so the
deposits were left in a failed swap although they were being swept
back.
Watch the confirmation with utils.WatchConfirmation, which registers
again after a delay.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.