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

Combine InboundV2Channel and OutboundV2Channel #3498

Merged

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Dec 19, 2024

Pending v2 channels will need to be broken up into separate phases for constructing and signing the funding transaction; see #3423 (comment). To avoid increasing the number of phases, combine the InboundV2Channel and OutboundV2Channel types and corresponding ChannelPhase variants. Whether the channel is inbound or outbound can be inferred from the ChannelContext. Also, remove the InteractivelyFunded trait as it is now no longer needed.

@jkczyz jkczyz requested a review from dunxen December 19, 2024 23:39
dunxen
dunxen previously approved these changes Dec 20, 2024
Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

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

LGTM.

I've gone through each commit and it's pretty straightforward IMO.

For some more context for others: It made more sense to have these structs and phases combined as unfunded V2 channels are more "symmetric" than their V1 counterparts. Particularly, after the initial handshake, we go through the turn-based interactive tx construction, and then both exchange initial commitment_signed and tx_signatures.

EDIT: The incremental_mutants CI failures aren't newly introduced, so it's okay to ignore.

Comment on lines +7836 to +7840
ChannelPhase::UnfundedV2(chan) => {
// Outbound channels don't contribute to the unfunded count in the DoS context.
if chan.context.is_outbound() {
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

optout21
optout21 previously approved these changes Jan 6, 2025
Copy link
Contributor

@optout21 optout21 left a comment

Choose a reason for hiding this comment

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

LGTM

@wpaulino wpaulino self-requested a review January 6, 2025 20:03
lightning/src/ln/channel.rs Show resolved Hide resolved
@@ -1684,63 +1684,53 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for Channel<SP> where SP::Ta
}
}

pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider {
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't we need it for channel splices post-funding as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know, these won't use the funded Channel struct directly. @optout21 could probably comment on that a bit more.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, InteractivelyFunded was used only for OutboundV2Channel and InboundV2Channel, I saw no use in other place (for splicing).

Copy link
Contributor

Choose a reason for hiding this comment

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

Something similar will still need to exist though to interactively fund the splices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A previous draft of the splicing prototype did this, IIRC. Instead, I think we'd have the splicing phase hold one or more PendingV2Channels instead (or something like that), so it would just call the methods on those directly.

jkczyz added 3 commits January 8, 2025 14:08
Pending v2 channels will need to be broken up into separate phases for
constructing and signing the funding transaction. To avoid increasing
the number of phases, combine the InboundV2Channel and OutboundV2Channel
types so that the can be used in one phase. Whether the channel is
inbound or outbound can be inferred from the ChannelContext.
Now that InboundV2Channel and OutboundV2Channel have been combined into
a PendingV2Channel, the InteractivelyFunded trait is no longer needed.
Now that InboundV2Channel and OutboundV2Channel have been combined into
a PendingV2Channel, only one ChannelPhase variant is needed.
@jkczyz jkczyz dismissed stale reviews from optout21 and dunxen via d6637d7 January 8, 2025 20:13
@jkczyz jkczyz force-pushed the 2024-12-combine-inbound-v2-phases branch from 6972cf3 to d6637d7 Compare January 8, 2025 20:13
@jkczyz
Copy link
Contributor Author

jkczyz commented Jan 8, 2025

Fixed internal docs. PTAL.

@dunxen
Copy link
Contributor

dunxen commented Jan 9, 2025

The fuzz and ubuntu-latest, 1.63.0 tests fail with No space left on device so unrelated.

@dunxen dunxen merged commit 7c77daf into lightningdevkit:main Jan 9, 2025
16 of 19 checks passed
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.

4 participants