]> git.bitcoin.ninja Git - rust-lightning/commit
Make `impl_writeable_tlv_based_enum*` actually upgradable
authorMatt Corallo <git@bluematt.me>
Mon, 8 Jul 2024 19:21:19 +0000 (19:21 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 17 Jul 2024 15:02:13 +0000 (15:02 +0000)
commit72f883e0a1a5d2286aa996f6e7bb80a54ca916c0
treeaa08ff1d795092191038d03b8c89bf1f5d273920
parent6035c83a1d797133b723a084abe6a55bfb4b9f62
Make `impl_writeable_tlv_based_enum*` actually upgradable

In cc78b77c715d6ef62693d4c1bc7190da990ec0fa it was discovered that
`impl_writeable_tlv_based_enum_upgradable` wasn't actually
upgradable - tuple variants weren't written with length-prefixes,
causing downgrades with new tuple variants to be unreadable by
older clients as they wouldn't know where to stop reading.

This was fixed by simply assuming that any new variants will be
non-tuple variants with a length prefix, but no code write-side
changes were made, allowing new code to freely continue to use the
broken tuple-variant serialization.

Here we address this be defining yet more serialization macros
which aren't broken, and convert existing usage of the existing
macros using non-length-prefixed tuple variants to renamed
`*_legacy` macros.

Note that this changes the serialization format of
`impl_writeable_tlv_based_enum[_upgradable]` when tuple fields are
written, and as such deliberately changes the call semantics for
such tuples.

Only the serialization format of `MessageContext` is changed here
which is fine as it has not yet reached a release of LDK.
15 files changed:
lightning/src/blinded_path/message.rs
lightning/src/blinded_path/payment.rs
lightning/src/chain/channelmonitor.rs
lightning/src/chain/package.rs
lightning/src/events/mod.rs
lightning/src/ln/channel.rs
lightning/src/ln/channel_state.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/onion_utils.rs
lightning/src/ln/outbound_payment.rs
lightning/src/ln/script.rs
lightning/src/sign/mod.rs
lightning/src/util/config.rs
lightning/src/util/ser_macros.rs
lightning/src/util/sweep.rs