Skip to content

Commit 9c32cc2

Browse files
authored
Remove deprecated serialization format and fields (#685)
The v4 serialization format was released in July 2023 with better support for backwards-compatibility: the v2 and v3 formats used kotlin's serialization, which prevents us from removing legacy classes and requires additional code whenever we change something in the channel state. Users who haven't migrated their data to the v4 format will not be able to deserialize their channel data: they will need to use a previous version of the app to read their old channel data, write it to the v4 format and then upgrade to the latest version. We also remove a bunch of fields/options that were deprecated a while ago: - legacy channel funding states - unused legacy features - legacy node events - legacy encrypted channel backup
1 parent dc983d7 commit 9c32cc2

File tree

132 files changed

+2170
-12522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+2170
-12522
lines changed

modules/core/src/commonMain/kotlin/fr/acinq/lightning/Features.kt

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,6 @@ sealed class Feature {
154154
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Invoice)
155155
}
156156

157-
// We historically used the following feature bit in our invoices.
158-
// However, the spec assigned the same feature bit to `option_scid_alias` (https://github.com/lightning/bolts/pull/910).
159-
// We're moving this feature bit to 148, but we have to keep supporting it until enough wallet users have migrated, then we can remove it.
160-
// We cannot rename that object otherwise we will not be able to read old serialized data.
161-
@Serializable
162-
object TrampolinePayment : Feature() {
163-
override val rfcName get() = "trampoline_payment_backwards_compat"
164-
override val mandatory get() = 50
165-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node, FeatureScope.Invoice)
166-
}
167-
168157
@Serializable
169158
object SimpleClose : Feature() {
170159
override val rfcName get() = "option_simple_close"
@@ -182,14 +171,6 @@ sealed class Feature {
182171
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
183172
}
184173

185-
/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
186-
@Serializable
187-
object ZeroConfChannels : Feature() {
188-
override val rfcName get() = "zero_conf_channels"
189-
override val mandatory get() = 130
190-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
191-
}
192-
193174
/** This feature bit should be activated when a mobile node supports waking up via push notifications. */
194175
@Serializable
195176
object WakeUpNotificationClient : Feature() {
@@ -206,54 +187,6 @@ sealed class Feature {
206187
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
207188
}
208189

209-
/** DEPRECATED: this feature bit was used for the legacy pay-to-open protocol. */
210-
@Serializable
211-
object PayToOpenClient : Feature() {
212-
override val rfcName get() = "pay_to_open_client"
213-
override val mandatory get() = 136
214-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init)
215-
}
216-
217-
/** DEPRECATED: this feature bit was used for the legacy pay-to-open protocol. */
218-
@Serializable
219-
object PayToOpenProvider : Feature() {
220-
override val rfcName get() = "pay_to_open_provider"
221-
override val mandatory get() = 138
222-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
223-
}
224-
225-
/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
226-
@Serializable
227-
object TrustedSwapInClient : Feature() {
228-
override val rfcName get() = "trusted_swap_in_client"
229-
override val mandatory get() = 140
230-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init)
231-
}
232-
233-
/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
234-
@Serializable
235-
object TrustedSwapInProvider : Feature() {
236-
override val rfcName get() = "trusted_swap_in_provider"
237-
override val mandatory get() = 142
238-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
239-
}
240-
241-
/** This feature is deprecated but must be kept to allow deserialization of old backups. */
242-
@Serializable
243-
object ChannelBackupClient : Feature() {
244-
override val rfcName get() = "channel_backup_client"
245-
override val mandatory get() = 144
246-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init)
247-
}
248-
249-
/** This feature is deprecated but must be kept to allow deserialization of old backups. */
250-
@Serializable
251-
object ChannelBackupProvider : Feature() {
252-
override val rfcName get() = "channel_backup_provider"
253-
override val mandatory get() = 146
254-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
255-
}
256-
257190
// The version of trampoline enabled by this feature bit does not match the latest spec PR: once the spec is accepted,
258191
// we will introduce a new version of trampoline that will work in parallel to this one, until we can safely deprecate it.
259192
@Serializable
@@ -354,19 +287,11 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
354287
Feature.ProvideStorage,
355288
Feature.ChannelType,
356289
Feature.PaymentMetadata,
357-
Feature.TrampolinePayment,
358290
Feature.SimpleClose,
359291
Feature.ExperimentalTrampolinePayment,
360292
Feature.ZeroReserveChannels,
361-
Feature.ZeroConfChannels,
362293
Feature.WakeUpNotificationClient,
363294
Feature.WakeUpNotificationProvider,
364-
Feature.PayToOpenClient,
365-
Feature.PayToOpenProvider,
366-
Feature.TrustedSwapInClient,
367-
Feature.TrustedSwapInProvider,
368-
Feature.ChannelBackupClient,
369-
Feature.ChannelBackupProvider,
370295
Feature.ExperimentalSplice,
371296
Feature.OnTheFlyFunding,
372297
Feature.FundingFeeCredit
@@ -401,7 +326,6 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
401326
Feature.BasicMultiPartPayment to listOf(Feature.PaymentSecret),
402327
Feature.AnchorOutputs to listOf(Feature.StaticRemoteKey),
403328
Feature.SimpleClose to listOf(Feature.ShutdownAnySegwit),
404-
Feature.TrampolinePayment to listOf(Feature.PaymentSecret),
405329
Feature.ExperimentalTrampolinePayment to listOf(Feature.PaymentSecret),
406330
Feature.OnTheFlyFunding to listOf(Feature.ExperimentalSplice),
407331
Feature.FundingFeeCredit to listOf(Feature.OnTheFlyFunding)

modules/core/src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,6 @@ data class NodeParams(
180180
require(features.hasFeature(Feature.RouteBlinding)) { "${Feature.RouteBlinding.rfcName} should be supported" }
181181
require(features.hasFeature(Feature.ShutdownAnySegwit, FeatureSupport.Mandatory)) { "${Feature.ShutdownAnySegwit.rfcName} should be mandatory" }
182182
require(features.hasFeature(Feature.SimpleClose, FeatureSupport.Mandatory)) { "${Feature.SimpleClose.rfcName} should be mandatory" }
183-
require(!features.hasFeature(Feature.ZeroConfChannels)) { "${Feature.ZeroConfChannels.rfcName} has been deprecated: use the zeroConfPeers whitelist instead" }
184-
require(!features.hasFeature(Feature.TrustedSwapInClient)) { "${Feature.TrustedSwapInClient.rfcName} has been deprecated" }
185-
require(!features.hasFeature(Feature.TrustedSwapInProvider)) { "${Feature.TrustedSwapInProvider.rfcName} has been deprecated" }
186-
require(!features.hasFeature(Feature.PayToOpenClient)) { "${Feature.PayToOpenClient.rfcName} has been deprecated" }
187-
require(!features.hasFeature(Feature.PayToOpenProvider)) { "${Feature.PayToOpenProvider.rfcName} has been deprecated" }
188183
Features.validateFeatureGraph(features)
189184
// Verify expiry parameters are consistent with each other.
190185
require((fulfillSafetyBeforeTimeoutBlocks * 2) < minFinalCltvExpiryDelta) { "min_final_expiry_delta must be at least twice as long as fulfill_safety_before_timeout_blocks" }

modules/core/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Channel.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ sealed class ChannelState {
248248
is Offline -> state.run { handleLocalError(cmd, t) }
249249
is Syncing -> state.run { handleLocalError(cmd, t) }
250250
is WaitForRemotePublishFutureCommitment -> Pair(state, emptyList())
251-
is LegacyWaitForFundingConfirmed -> forceClose(state)
252-
is LegacyWaitForFundingLocked -> forceClose(state)
253251
}
254252
}
255253

modules/core/src/commonMain/kotlin/fr/acinq/lightning/channel/states/LegacyWaitForFundingConfirmed.kt

Lines changed: 0 additions & 88 deletions
This file was deleted.

modules/core/src/commonMain/kotlin/fr/acinq/lightning/channel/states/LegacyWaitForFundingLocked.kt

Lines changed: 0 additions & 83 deletions
This file was deleted.

modules/core/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Syncing.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ data class Syncing(val state: PersistedChannelState, val channelReestablishSent:
2525
is ChannelCommand.MessageReceived -> when (cmd.message) {
2626
is ChannelReestablish -> {
2727
val (nextState, actions) = when (state) {
28-
is LegacyWaitForFundingConfirmed -> {
29-
Pair(state, listOf())
30-
}
3128
is WaitForFundingSigned -> {
3229
val actions = buildList {
3330
if (cmd.message.nextFundingTxId == state.signingSession.fundingTx.txId && cmd.message.nextLocalCommitmentNumber == 0L) {
@@ -117,13 +114,6 @@ data class Syncing(val state: PersistedChannelState, val channelReestablishSent:
117114
actions.add(ChannelAction.Message.Send(channelReady))
118115
Pair(state, actions)
119116
}
120-
is LegacyWaitForFundingLocked -> {
121-
logger.debug { "re-sending channel_ready" }
122-
val nextPerCommitmentPoint = channelKeys().commitmentPoint(1)
123-
val channelReady = ChannelReady(state.commitments.channelId, nextPerCommitmentPoint)
124-
val actions = listOf(ChannelAction.Message.Send(channelReady))
125-
Pair(state, actions)
126-
}
127117
is Normal -> {
128118
when (val syncResult = handleSync(state.commitments, cmd.message)) {
129119
is SyncResult.Failure -> handleSyncFailure(state.commitments, cmd.message, syncResult)

modules/core/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class Peer(
333333
}
334334
launch {
335335
// we don't restore closed channels
336-
val bootChannels = db.channels.listLocalChannels().filterNot { it is Closed || it is LegacyWaitForFundingConfirmed }
336+
val bootChannels = db.channels.listLocalChannels().filterNot { it is Closed }
337337
_bootChannelsFlow.value = bootChannels.associateBy { it.channelId }
338338
val channelIds = bootChannels.map {
339339
logger.info { "restoring channel ${it.channelId} from local storage" }

0 commit comments

Comments
 (0)