Skip to content

Commit 3d8bfd0

Browse files
committed
Stop writing signer data as a part of channels
This breaks backwards compatibility with versions of LDK prior to 0.0.113 as they expect to always read signer data. This also substantially reduces allocations during `ChannelManager` serialization, as we currently don't pre-allocate the `Vec` that the signer gets written in to. We could alternatively pre-allocate that `Vec`, but we've been set up to skip the write entirely for a while, and 0.0.113 was released nearly a year ago. Users downgrading to LDK 0.0.112 and before at this point should not be expected.
1 parent d36159c commit 3d8bfd0

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lightning/src/ln/channel.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6892,7 +6892,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
68926892
}
68936893

68946894
const SERIALIZATION_VERSION: u8 = 3;
6895-
const MIN_SERIALIZATION_VERSION: u8 = 2;
6895+
const MIN_SERIALIZATION_VERSION: u8 = 3;
68966896

68976897
impl_writeable_tlv_based_enum!(InboundHTLCRemovalReason,;
68986898
(0, FailRelay),
@@ -6972,14 +6972,6 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
69726972

69736973
self.context.latest_monitor_update_id.write(writer)?;
69746974

6975-
let mut key_data = VecWriter(Vec::new());
6976-
// TODO (taproot|arik): Introduce serialization distinction for non-ECDSA signers.
6977-
self.context.holder_signer.as_ecdsa().expect("Only ECDSA signers may be serialized").write(&mut key_data)?;
6978-
assert!(key_data.0.len() < core::usize::MAX);
6979-
assert!(key_data.0.len() < core::u32::MAX as usize);
6980-
(key_data.0.len() as u32).write(writer)?;
6981-
writer.write_all(&key_data.0[..])?;
6982-
69836975
// Write out the old serialization for shutdown_pubkey for backwards compatibility, if
69846976
// deserialized from that format.
69856977
match self.context.shutdown_scriptpubkey.as_ref().and_then(|script| script.as_legacy_pubkey()) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* `ChannelManager`s written with LDK 0.0.119 are no longer readable by versions
2+
of LDK prior to 0.0.113. Users wishing to downgrade to LDK 0.0.112 or before
3+
can read an 0.0.119-serialized `ChannelManager` with a version of LDK from
4+
0.0.113 to 0.0.118, re-serialize it, and then downgrade.

0 commit comments

Comments
 (0)