Skip to content

Commit c50518a

Browse files
Don't persist inbound committed onions in prod
A few PRs ago, we started persisting inbound committed HTLC onions in Channels. These onions were persisted to lay groundwork for reconstructing the ChannelManager's pending HTLC maps from them in a future version. However, we've since discovered a different direction where we can instead reconstruct these same maps using persistent monitor events, which may mean that we don't need to persist these onions. Since persisting a bunch of onions on every manager write is a big commitment that we're not fully confident in yet, switch it off for now until we either confirm the monitor events direction and can delete all this onion persisting code OR realize that we definitely do need it.
1 parent 4cbd074 commit c50518a

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15570,6 +15570,7 @@ impl<SP: SignerProvider> Writeable for FundedChannel<SP> {
1557015570
}
1557115571
}
1557215572
let mut removed_htlc_attribution_data: Vec<&Option<AttributionData>> = Vec::new();
15573+
#[cfg_attr(not(test), allow(unused_mut))]
1557315574
let mut inbound_committed_update_adds: Vec<&InboundUpdateAdd> = Vec::new();
1557415575
(self.context.pending_inbound_htlcs.len() as u64 - dropped_inbound_htlcs).write(writer)?;
1557515576
for htlc in self.context.pending_inbound_htlcs.iter() {
@@ -15590,9 +15591,10 @@ impl<SP: SignerProvider> Writeable for FundedChannel<SP> {
1559015591
2u8.write(writer)?;
1559115592
htlc_resolution.write(writer)?;
1559215593
},
15593-
&InboundHTLCState::Committed { ref update_add_htlc } => {
15594+
&InboundHTLCState::Committed { update_add_htlc: ref _update_add } => {
1559415595
3u8.write(writer)?;
15595-
inbound_committed_update_adds.push(update_add_htlc);
15596+
#[cfg(test)]
15597+
inbound_committed_update_adds.push(_update_add);
1559615598
},
1559715599
&InboundHTLCState::LocalRemoved(ref removal_reason) => {
1559815600
4u8.write(writer)?;

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17600,15 +17600,13 @@ pub fn provided_init_features(config: &UserConfig) -> InitFeatures {
1760017600
const SERIALIZATION_VERSION: u8 = 1;
1760117601
const MIN_SERIALIZATION_VERSION: u8 = 1;
1760217602

17603-
// We plan to start writing this version in 0.5.
17603+
// We plan to start writing this version a few versions after we start writing inbound committed
17604+
// payment onions in `Channel`, which is already done in tests but not yet switched on in prod.
1760417605
//
17605-
// LDK 0.5+ will reconstruct the set of pending HTLCs from `Channel{Monitor}` data that started
17606-
// being written in 0.3, ignoring legacy `ChannelManager` HTLC maps on read and not writing them.
17607-
// LDK 0.5+ will automatically fail to read if the pending HTLC set cannot be reconstructed, i.e.
17608-
// if we were last written with pending HTLCs on 0.2- or if the new 0.3+ fields are missing.
17609-
//
17610-
// If 0.3 or 0.4 reads this manager version, it knows that the legacy maps were not written and
17611-
// acts accordingly.
17606+
// If `version == 2` on read, we will use said onions when reconstructing the set of pending HTLCs,
17607+
// ignoring legacy `ChannelManager` HTLC maps on read and not writing them. We'll also
17608+
// automatically fail to read if the pending HTLC set cannot be reconstructed, i.e. if the new
17609+
// payment onion field is missing.
1761217610
const RECONSTRUCT_HTLCS_FROM_CHANS_VERSION: u8 = 2;
1761317611

1761417612
impl_writeable_tlv_based!(PhantomRouteHints, {

0 commit comments

Comments
 (0)