@@ -26,6 +26,7 @@ operation, and closing.
26
26
* [ Completing the Transition to the Updated State: ` revoke_and_ack ` ] ( #completing-the-transition-to-the-updated-state-revoke_and_ack )
27
27
* [ Updating Fees: ` update_fee ` ] ( #updating-fees-update_fee )
28
28
* [ Message Retransmission: ` channel_reestablish ` message] ( #message-retransmission )
29
+ * [ Upgrading Channels] ( #upgrading-channels )
29
30
* [ Authors] ( #authors )
30
31
31
32
# Channel
@@ -1243,22 +1244,30 @@ messages are), they are independent of requirements here.
1243
1244
1 . type: 1 (` next_to_send ` )
1244
1245
2 . data:
1245
1246
* [ ` tu64 ` :` commitment_number ` ]
1246
- 1 . type: 3 (` desired_features ` )
1247
+ 1 . type: 3 (` desired_type ` )
1247
1248
2 . data:
1248
- * [ ` ...*byte ` :` features ` ]
1249
- 1 . type: 5 (` current_features ` )
1249
+ * [ ` channel_type ` :` type ` ]
1250
+ 1 . type: 5 (` current_type ` )
1250
1251
2 . data:
1251
- * [ ` ...*byte ` :` features ` ]
1252
- 1 . type: 7 (` upgradable_features ` )
1252
+ * [ ` channel_type ` :` type ` ]
1253
+ 1 . type: 7 (` upgradable ` )
1253
1254
2 . data:
1254
- * [ ` ...*byte ` :` features ` ]
1255
+ * [ ` ...*channel_type ` :` upgrades ` ]
1256
+
1257
+ 1 . subtype: ` channel_type `
1258
+ 2 . data:
1259
+ * [ ` u16 ` :` len ` ]
1260
+ * [ ` len*byte ` :` features ` ]
1255
1261
1256
1262
` next_commitment_number ` : A commitment number is a 48-bit
1257
1263
incrementing counter for each commitment transaction; counters
1258
1264
are independent for each peer in the channel and start at 0.
1259
1265
They're only explicitly relayed to the other node in the case of
1260
1266
re-establishment, otherwise they are implicit.
1261
1267
1268
+ See [ Upgrading Channels] ( #upgrading-channels ) for the requirements
1269
+ of some of the optional fields.
1270
+
1262
1271
### Requirements
1263
1272
1264
1273
A funding node:
@@ -1473,29 +1482,23 @@ channel upgraded and the other not. But this will eventually be
1473
1482
resolved: the channel cannot progress until both sides have received
1474
1483
` channel_reestablish ` anyway.
1475
1484
1476
- Channel features are currently defined as:
1477
- - ` option_static_remotekey `
1478
- - ` option_anchor_outputs `
1485
+ Channel features are explicitly enumerated as ` channel_type `
1486
+ bitfields, using odd features bits. The currently defined types are:
1487
+ - no features (no bits set)
1488
+ - ` option_static_remotekey ` (bit 13)
1489
+ - ` option_anchor_outputs ` and ` option_static_remotekey ` (bits 21 and 13)
1490
+ - ` option_anchors_zero_fee_htlc_tx ` and ` option_static_remotekey ` (bits 23 and 13)
1479
1491
1480
1492
#### Requirements
1481
1493
1482
- A node writing a ` features ` field:
1483
- - MUST set features using odd bits if an upgrade is optional.
1484
- - Otherwise, MUST close the connection (and MAY fail the channel) if the upgrade fails.
1485
- - MUST NOT set dependent features for any feature, unless that feature is also upgradable separately.
1486
-
1487
- A node reading a ` features ` field:
1488
- - SHOULD close the connection if there is an even bit it does not understand.
1489
- - Otherwise, SHOULD treat odd and even bits the same.
1490
-
1491
1494
A node sending ` channel_reestablish ` , if it supports upgrading channels:
1492
1495
- MUST set ` next_to_send ` the commitment number of the next ` commitment_signed ` it expects to send.
1493
1496
- if it initiated the channel:
1494
- - MUST set ` desired_features ` to the features it wants for the channel.
1495
- - MUST set ` desired_features ` equal to or an upgrade from the current channel features.
1497
+ - MUST set ` desired_type ` to the channel_type it wants for the channel.
1496
1498
- otherwise:
1497
- - MUST set ` current_features ` to the features which could be upgraded for the channel.
1498
- - MUST set ` upgradable_features ` to the features which could be upgraded for the channel.
1499
+ - MUST set ` current_type ` to the current channel_type of the channel.
1500
+ - MUST set ` upgradable ` to the channel types it could change to.
1501
+ - MAY not set ` upgradable ` if it would be empty.
1499
1502
1500
1503
A node receiving ` channel_reestablish ` :
1501
1504
- if it has to retransmit ` commitment_signed ` or ` revoke_and_ack ` :
@@ -1505,10 +1508,12 @@ A node receiving `channel_reestablish`:
1505
1508
- if updates are pending on either sides' commitment transaction:
1506
1509
- MUST consider the channel feature change failed.
1507
1510
- otherwise:
1508
- - if ` desired_features ` is a valid combination of ` current_features ` , either modified or not by ` upgradable_features ` :
1509
- - MUST consider the channel features to be ` desired_features ` .
1510
- - otherwise (including if there is no ` current_features ` or ` upgradable_features ` :
1511
+ - if ` desired_type ` matches ` current_type ` or any ` upgradable ` ` upgrades ` :
1512
+ - MUST consider the channel type to be ` desired_type ` .
1513
+ - otherwise:
1511
1514
- MUST consider the channel feature change failed.
1515
+ - if there is a ` current_type ` field:
1516
+ - MUST consider the channel type to be ` current_type ` .
1512
1517
1513
1518
#### Rationale
1514
1519
@@ -1517,11 +1522,6 @@ sent a new set of updates and `commitment_signed` which we didn't see
1517
1522
before disconnection (i.e. retransmissions are incoming). Existing logic
1518
1523
already tells us if we need to send retransmissions.
1519
1524
1520
- A node may decide only to offer ` option_anchor_outputs ` as an upgrade,
1521
- without supporting ` option_static_remotekey ` alone, even though
1522
- ` option_anchor_outputs ` implies it. This why dependent features are
1523
- not flagged explicitly.
1524
-
1525
1525
If reconnection is aborted, there are four possibilities: both side
1526
1526
receive the ` channel_reestablish ` and are upgraded, neither side
1527
1527
receives the ` channel_reestablish ` and neither are upgraded, and the
@@ -1530,20 +1530,19 @@ this is fine as long as it is resolved before any channel operations
1530
1530
are attempted (all of which require successful exchange of
1531
1531
` channel_reestablish ` messages).
1532
1532
1533
- If only the initiator is upgraded, it will reflect this upgrade in the
1534
- next ` desired_features ` , causing the non-initiator to upgrade. If
1535
- only the non-initiator is upgraded, it will be reflected in
1536
- ` current_features ` and the combination of ` current_features ` and
1537
- ` upgradable_features ` will match ` desired_features ` and the initiator
1538
- will consider itself upgraded.
1539
-
1540
- There are, however, theoretical cases where a second upgrade is
1541
- attempted immediately following (i.e. the non-initiator doesn't even
1542
- think the first one occurred), or incompatible upgrades are attempted,
1543
- which could cause desynchronization on these cases. This could be
1544
- avoided after the first upgrade by the sending an ` update_fee ` at the
1545
- current feerate followed by a ` commitment_signed ` , which has the
1546
- effect of forcing synchronization.
1533
+ On reconnect, if only the initiator is upgraded, it will reflect this
1534
+ upgrade in the next ` desired_type ` , causing the non-initiator to
1535
+ upgrade. If only the non-initiator is upgraded, it will be reflected
1536
+ in ` current_type ` and the initiator will consider itself upgraded.
1537
+
1538
+ There can be desynchronization across multiple upgrades. Both nodes
1539
+ start on channel_type A, initiator sets ` desired_type ` B, receives
1540
+ ` channel_reestablish ` from A which has B in ` upgradable ` , but B
1541
+ doesn't receive ` channel_reestablish ` . On reconnect, initiator tries
1542
+ to upgrade again, setting ` desired_type ` to C, which is not in B's
1543
+ ` upgradable ` so fails. This is why, on such a failed upgrade, the
1544
+ initiator considers the ` current_type ` given by the non-initiator to
1545
+ be canonical.
1547
1546
1548
1547
# Authors
1549
1548
0 commit comments