Skip to content

Commit 7a951b1

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 a8d4cfa commit 7a951b1

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ be covered by functional tests.
8888
When refactoring, structure your PR to make it easy to review and don't
8989
hesitate to split it into multiple small, focused PRs.
9090

91-
The Minimum Supported Rust Version (MSRV) currently is 1.41.1 (enforced by
92-
our GitHub Actions). Also, the compatibility for LDK object serialization is
93-
currently ensured back to and including crate version 0.0.99 (see the
94-
[changelog](CHANGELOG.md)).
91+
The Minimum Supported Rust Version (MSRV) currently is 1.48.0 (enforced by
92+
our GitHub Actions). We support reading serialized LDK objects written by any
93+
version of LDK 0.0.99 and above. We support LDK versions 0.0.113 and above
94+
reading serialized LDK objects written by modern LDK. Any expected issues with
95+
upgrades or downgrades should be mentioned in the [changelog](CHANGELOG.md).
9596

9697
Commits should cover both the issue fixed and the solution's rationale. These
9798
[guidelines](https://chris.beams.io/posts/git-commit/) should be kept in mind.

lightning/src/ln/channel.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::chain::transaction::{OutPoint, TransactionData};
3939
use crate::sign::{EcdsaChannelSigner, WriteableEcdsaChannelSigner, EntropySource, ChannelSigner, SignerProvider, NodeSigner, Recipient};
4040
use crate::events::ClosureReason;
4141
use crate::routing::gossip::NodeId;
42-
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer, VecWriter};
42+
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer};
4343
use crate::util::logger::Logger;
4444
use crate::util::errors::APIError;
4545
use crate::util::config::{UserConfig, ChannelConfig, LegacyChannelConfig, ChannelHandshakeConfig, ChannelHandshakeLimits, MaxDustHTLCExposure};
@@ -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()) {

lightning/src/sign/type_resolver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ impl<ECS: EcdsaChannelSigner> ChannelSignerType<ECS>{
1818
}
1919
}
2020

21+
#[allow(unused)]
2122
pub(crate) fn as_ecdsa(&self) -> Option<&ECS> {
2223
match self {
2324
ChannelSignerType::Ecdsa(ecs) => Some(ecs)
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)