Skip to content

Handle retrying sign_counterparty_commitment failures - #2554

Closed
TheBlueMatt wants to merge 6 commits into
lightningdevkit:mainfrom
TheBlueMatt:2023-09-counterparty-sign-retry
Closed

Handle retrying sign_counterparty_commitment failures#2554
TheBlueMatt wants to merge 6 commits into
lightningdevkit:mainfrom
TheBlueMatt:2023-09-counterparty-sign-retry

Conversation

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

This adds implements this properly.

It is missing tests and even breaks a test, but I wrote it as a demo and I think it'd basically be land-able if there were tests. Up for grabs - if someone wants to write tests, do it, and I'll close this PR and let you replace it.

If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending later, rather than force-closing the
channel (which probably won't even work if the signer is missing).
Here we add initial handling of sign_counterparty_commitment
failing during normal channel operation, setting a new flag in
`ChannelContext` which indicates we should retry sending the
commitment update later. We don't yet add any ability to do that
retry.
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).
Here we add initial handling of sign_counterparty_commitment
failing during outbound channel funding, setting a new flag in
`ChannelContext` which indicates we should retry sending the
`funding_created` later. We don't yet add any ability to do that
retry.
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).
Here we add initial handling of sign_counterparty_commitment
failing during inbound channel funding, setting a flag in
`ChannelContext` which indicates we should retry sending the
`funding_signed` later. We don't yet add any ability to do that
retry.
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).
This commit adds initial retrying of failures, specifically
regenerating commitment updates, attempting to re-sign the
`CommitmentSigned` message, and sending it to our peers if we
succed.
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).
This commit adds retrying of outbound funding_created signing
failures, regenerating the `FundingCreated` message, attempting to
re-sign, and sending it to our peers if we succeed.
Comment threadlightning/src/ln/channel.rs

@watersonwaterson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All existing CI tests (in particular payment tests) pass with the change in channel.rs to fix the counterparty commitment transaction number we provide to the monitor.

If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).
This commit adds retrying of inbound funding_created signing
failures, regenerating the `FundingSigned` message, attempting to
re-sign, and sending it to our peers if we succeed.
@TheBlueMatt
TheBlueMattforce-pushed the 2023-09-counterparty-sign-retry branch from 237ceff to 48aafb5CompareSeptember 6, 2023 16:47
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Mmm, good catch, yea. I went ahead and took your change, but feel free to do whatever you want with this PR.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Patch coverage: 90.12% and no project coverage change.

Comparison is base (eb44d99) 90.61% compared to head (48aafb5) 90.61%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@ Coverage Diff @@## main #2554 +/- ##
=======================================
Coverage 90.61% 90.61% =======================================
Files 110 110 Lines 57573 57586 +13 Branches 57573 57586 +13 =======================================
+ Hits 52167 52180 +13 
Misses 5406 5406 
Files ChangedCoverage Δ
lightning/src/ln/channelmanager.rs87.17% <86.66%> (-0.01%)⬇️
lightning/src/ln/channel.rs89.96% <90.76%> (+0.10%)⬆️
lightning/src/ln/functional_tests.rs98.18% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Supersceded by #2558

Sign up for freeto 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.

3 participants

@TheBlueMatt@codecov-commenter@waterson