Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle retrying sign_counterparty_commitment failures #2554

Conversation

TheBlueMatt
Copy link
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.
Copy link
Contributor

@waterson waterson left a comment

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 TheBlueMatt force-pushed the 2023-09-counterparty-sign-retry branch from 237ceff to 48aafb5 Compare September 6, 2023 16:47
@TheBlueMatt
Copy link
Collaborator Author

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

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 Changed Coverage Δ
lightning/src/ln/channelmanager.rs 87.17% <86.66%> (-0.01%) ⬇️
lightning/src/ln/channel.rs 89.96% <90.76%> (+0.10%) ⬆️
lightning/src/ln/functional_tests.rs 98.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
Collaborator Author

Supersceded by #2558

@TheBlueMatt TheBlueMatt closed this Sep 6, 2023
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.

3 participants