-
Notifications
You must be signed in to change notification settings - Fork 386
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 fallible commitment secret #3152
Merged
TheBlueMatt
merged 2 commits into
lightningdevkit:main
from
alecchendev:2024-06-async-commit-secret-raa
Jul 18, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5500,32 +5500,42 @@ impl<SP: Deref> Channel<SP> where | |
fn get_last_revoke_and_ack<L: Deref>(&mut self, logger: &L) -> Option<msgs::RevokeAndACK> where L::Target: Logger { | ||
debug_assert!(self.context.holder_commitment_point.transaction_number() <= INITIAL_COMMITMENT_NUMBER - 2); | ||
self.context.holder_commitment_point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger); | ||
let per_commitment_secret = self.context.holder_signer.as_ref().release_commitment_secret(self.context.holder_commitment_point.transaction_number() + 2); | ||
if let HolderCommitmentPoint::Available { transaction_number: _, current, next: _ } = self.context.holder_commitment_point { | ||
let per_commitment_secret = self.context.holder_signer.as_ref() | ||
.release_commitment_secret(self.context.holder_commitment_point.transaction_number() + 2).ok(); | ||
valentinewallace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if let (HolderCommitmentPoint::Available { current, .. }, Some(per_commitment_secret)) = | ||
(self.context.holder_commitment_point, per_commitment_secret) { | ||
self.context.signer_pending_revoke_and_ack = false; | ||
Some(msgs::RevokeAndACK { | ||
return Some(msgs::RevokeAndACK { | ||
channel_id: self.context.channel_id, | ||
per_commitment_secret, | ||
next_per_commitment_point: current, | ||
#[cfg(taproot)] | ||
next_local_nonce: None, | ||
}) | ||
} else { | ||
#[cfg(not(async_signing))] { | ||
panic!("Holder commitment point must be Available when generating revoke_and_ack"); | ||
} | ||
#[cfg(async_signing)] { | ||
// Technically if we're at HolderCommitmentPoint::PendingNext, | ||
// we have a commitment point ready to send in an RAA, however we | ||
// choose to wait since if we send RAA now, we could get another | ||
// CS before we have any commitment point available. Blocking our | ||
// RAA here is a convenient way to make sure that post-funding | ||
// we're only ever waiting on one commitment point at a time. | ||
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available", | ||
&self.context.channel_id(), self.context.holder_commitment_point.transaction_number()); | ||
self.context.signer_pending_revoke_and_ack = true; | ||
None | ||
} | ||
} | ||
if !self.context.holder_commitment_point.is_available() { | ||
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available", | ||
&self.context.channel_id(), self.context.holder_commitment_point.transaction_number()); | ||
} | ||
if per_commitment_secret.is_none() { | ||
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment secret for {} is not available", | ||
&self.context.channel_id(), self.context.holder_commitment_point.transaction_number(), | ||
self.context.holder_commitment_point.transaction_number() + 2); | ||
} | ||
#[cfg(not(async_signing))] { | ||
panic!("Holder commitment point and per commitment secret must be available when generating revoke_and_ack"); | ||
} | ||
#[cfg(async_signing)] { | ||
// Technically if we're at HolderCommitmentPoint::PendingNext, | ||
// we have a commitment point ready to send in an RAA, however we | ||
// choose to wait since if we send RAA now, we could get another | ||
// CS before we have any commitment point available. Blocking our | ||
// RAA here is a convenient way to make sure that post-funding | ||
// we're only ever waiting on one commitment point at a time. | ||
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available", | ||
&self.context.channel_id(), self.context.holder_commitment_point.transaction_number()); | ||
Comment on lines
+5535
to
+5536
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think this log is redundant with the ones above |
||
self.context.signer_pending_revoke_and_ack = true; | ||
None | ||
} | ||
} | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in most files we have a
use crate::prelude::*;
, which I believe would avoid thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, think that means this file will fail to build no-std, though we can also fix that when we drop the cfg flag.