Skip to content

Commit f0bb900

Browse files
committed
Remove outpoint_to_peer map in ChannelManager
Now that we require `ChannelMonitor`s to track the channel's counterparty node ID, we can remove the `outpoint_to_peer` map that was used throughout `MonitorEvent` handling. This is a big win for a post-splicing future, as we'll no longer have to bother updating this map when a splice is proposed. Some existing tests providing coverage have been removed as a result.
1 parent 601bf4b commit f0bb900

File tree

4 files changed

+106
-281
lines changed

4 files changed

+106
-281
lines changed

lightning/src/ln/async_signer_tests.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use bitcoin::transaction::Version;
1818

1919
use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
2020
use crate::chain::ChannelMonitorUpdateStatus;
21-
use crate::chain::transaction::OutPoint;
2221
use crate::events::bump_transaction::WalletSource;
2322
use crate::events::{ClosureReason, Event};
2423
use crate::ln::chan_utils::ClosingTransaction;
@@ -1091,9 +1090,4 @@ fn do_test_closing_signed(extra_closing_signed: bool, reconnect: bool) {
10911090
assert!(nodes[1].node.list_channels().is_empty());
10921091
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
10931092
check_closed_event!(nodes[1], 1, ClosureReason::CounterpartyInitiatedCooperativeClosure, [nodes[0].node.get_our_node_id()], 100000);
1094-
1095-
// Check that our maps have been updated after async signing channel closure.
1096-
let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
1097-
assert!(nodes[0].node().outpoint_to_peer.lock().unwrap().get(&funding_outpoint).is_none());
1098-
assert!(nodes[1].node().outpoint_to_peer.lock().unwrap().get(&funding_outpoint).is_none());
10991093
}

lightning/src/ln/channel.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,6 +3457,18 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
34573457
!matches!(self.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH))
34583458
}
34593459

3460+
fn unset_funding_info(&mut self, funding: &mut FundingScope) {
3461+
debug_assert!(
3462+
matches!(self.channel_state, ChannelState::FundingNegotiated)
3463+
|| matches!(self.channel_state, ChannelState::AwaitingChannelReady(_))
3464+
);
3465+
funding.channel_transaction_parameters.funding_outpoint = None;
3466+
self.channel_id = self.temporary_channel_id.expect(
3467+
"temporary_channel_id should be set since unset_funding_info is only called on funded \
3468+
channels that were unfunded immediately beforehand"
3469+
);
3470+
}
3471+
34603472
fn validate_commitment_signed<L: Deref>(
34613473
&self, funding: &FundingScope, holder_commitment_point: &HolderCommitmentPoint,
34623474
msg: &msgs::CommitmentSigned, logger: &L,
@@ -5310,14 +5322,7 @@ impl<SP: Deref> FundedChannel<SP> where
53105322
/// Further, the channel must be immediately shut down after this with a call to
53115323
/// [`ChannelContext::force_shutdown`].
53125324
pub fn unset_funding_info(&mut self) {
5313-
debug_assert!(matches!(
5314-
self.context.channel_state, ChannelState::AwaitingChannelReady(_)
5315-
));
5316-
self.funding.channel_transaction_parameters.funding_outpoint = None;
5317-
self.context.channel_id = self.context.temporary_channel_id.expect(
5318-
"temporary_channel_id should be set since unset_funding_info is only called on funded \
5319-
channels that were unfunded immediately beforehand"
5320-
);
5325+
self.context.unset_funding_info(&mut self.funding);
53215326
}
53225327

53235328
/// Handles a channel_ready message from our peer. If we've already sent our channel_ready
@@ -9315,6 +9320,14 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
93159320
} else { None };
93169321
(open_channel, funding_created)
93179322
}
9323+
9324+
/// Unsets the existing funding information.
9325+
///
9326+
/// The channel must be immediately shut down after this with a call to
9327+
/// [`ChannelContext::force_shutdown`].
9328+
pub fn unset_funding_info(&mut self) {
9329+
self.context.unset_funding_info(&mut self.funding);
9330+
}
93189331
}
93199332

93209333
/// A not-yet-funded inbound (from counterparty) channel using V1 channel establishment.

0 commit comments

Comments
 (0)