Skip to content

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Sep 5, 2025

This was pulled out of #4054 to ease review. It fixes an assortment of issues I ran into while writing the tests there.

@wpaulino wpaulino added this to the 0.2 milestone Sep 5, 2025
@wpaulino wpaulino self-assigned this Sep 5, 2025
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Sep 5, 2025

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

1 similar comment
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

}
removed_fulfilled_htlcs = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just run the loop below at this point and return rather than needing this variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just a small optimization to not remove HTLCs that have already been removed since we have duplicate data across FundingScopes. The loop below does need to run for every FundingScope though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but that is already inside the closure, which is called on each FundingScope.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, nevermind. Didn't see that removed_fulfilled_htlcs is used across all calls.

{
Some(interactive_tx_constructor)
} else {
None
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this also unreachable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we actually don't want any unreachables since they can be triggered by a buggy/malicious counterparty.

ChannelPhase::UnfundedOutboundV1(_) => unreachable!(),
ChannelPhase::UnfundedInboundV1(_) => unreachable!(),
ChannelPhase::UnfundedV2(pending_v2_channel) => {
pending_v2_channel.interactive_tx_constructor.take()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't recall if we eventually want to use FundingNegotiation here, too. Can wait, of course, but we may be able avoid these unreachables if we can take that at the call sites below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not quite using that yet for dual funding so I'd rather delay it until we do.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Basically LGTM

@@ -1782,7 +1964,7 @@ where

pub fn funding_tx_constructed<L: Deref>(
&mut self, logger: &L,
) -> Result<msgs::CommitmentSigned, msgs::TxAbort>
) -> Result<msgs::CommitmentSigned, AbortReason>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wanna make these methods non-pub now? Makes the logic more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I think it was just funding_tx_constructed and interactive_tx_constructor_mut?

@wpaulino wpaulino force-pushed the splice-misc-fixes branch 2 times, most recently from b1d97a1 to 9540ede Compare September 8, 2025 19:14
Otherwise we'll hit an assert that we do not already have an alternative
funding confirmation when reprocessing the transaction.
…cked

The `ChannelMonitor` now tracks its own set of channel parameters, but
in the event they change after a splice, we want to ensure they are
updated accordingly at the `OnchainTxHandler` level as well in case the
user downgrades after a locked splice has already occurred.
We only need to track the HTLC sources for the previous and current
counterparty commitments.
This commit reworks all interactive transaction construction methods to
mark the negotiation as failed upon a local/remote `TxAbort`, ensuring
the `InteractiveTxConstructor` is consumed. Along the way, we refactor
the handling of `tx_complete` such that we only have a single call into
the `Channel` from the `ChannelManager`.
The splice shared input weight should always be composed of the base
input weight (prevout & sequence), an empty `script_sig` weight, and the
multisig channel-type specific witness weight.
Although a splice out doesn't include inputs to sign, users still need
to call back with `funding_transaction_signed` to sign the shared splice
input.
Comment on lines 268 to 273
let events = initiator_node.node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 2);
assert_eq!(events.len(), 1);
match events[0] {
MessageSendEvent::SendTxComplete { .. } => {},
_ => panic!("Unexpected event {:?}", events[0]),
}
match events[1] {
MessageSendEvent::SendTxAbort { .. } => {},
_ => panic!("Unexpected event {:?}", events[1]),
_ => panic!("Unexpected event {:?}", events[0]),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The test is using the wrong variable in the handle_tx_complete call. It captures the latest tx_complete message as _tx_complete_msg (with an underscore), but then passes the earlier tx_complete_msg from line 244 to the handler. This could lead to incorrect behavior since it's processing the wrong message. The variable names should be consistent, and the latest message should be used in the handler call.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks to predate the PR, but shouldn't affect behavior given tx_complete only contains a channel id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this test is getting removed completely in #4054 anyway.

Comment on lines 268 to 273
let events = initiator_node.node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 2);
assert_eq!(events.len(), 1);
match events[0] {
MessageSendEvent::SendTxComplete { .. } => {},
_ => panic!("Unexpected event {:?}", events[0]),
}
match events[1] {
MessageSendEvent::SendTxAbort { .. } => {},
_ => panic!("Unexpected event {:?}", events[1]),
_ => panic!("Unexpected event {:?}", events[0]),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks to predate the PR, but shouldn't affect behavior given tx_complete only contains a channel id.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Gonna land this but think we need to fix the dual-funding failure handling.

ChannelPhase::Undefined => unreachable!(),
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => None,
ChannelPhase::UnfundedV2(pending_v2_channel) => {
pending_v2_channel.interactive_tx_constructor.take()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we really just blindly take this? Its set up in new for inbound channels, so we probably should be outright failing the channel here, not resetting the signing session?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same applies further down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dual funding hasn't been updated to use the new interactive tx path, it shouldn't even have an interactive tx constructor in new yet without calling FundingNegotiationContext::into_interactive_tx_constructor.

@TheBlueMatt TheBlueMatt merged commit 3324799 into lightningdevkit:main Sep 9, 2025
22 of 23 checks passed
@wpaulino wpaulino deleted the splice-misc-fixes branch September 9, 2025 19:57
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