Skip to content

Commit 7be9947

Browse files
committed
BOLT 2: remove channel_type subtype, only allow one upgrade.
We also define channel type elsewhere, so we can remove the now-outdated one. And clarify the example. Signed-off-by: Rusty Russell <[email protected]>
1 parent abc7c16 commit 7be9947

File tree

1 file changed

+28
-40
lines changed

1 file changed

+28
-40
lines changed

02-peer-protocol.md

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,20 +1329,15 @@ messages are), they are independent of requirements here.
13291329
1. type: 1 (`next_to_send`)
13301330
2. data:
13311331
* [`tu64`:`commitment_number`]
1332-
1. type: 3 (`desired_type`)
1332+
1. type: 3 (`desired_channel_type`)
13331333
2. data:
1334-
* [`channel_type`:`type`]
1335-
1. type: 5 (`current_type`)
1334+
* [`...*byte`:`type`]
1335+
1. type: 5 (`current_channel_type`)
13361336
2. data:
1337-
* [`channel_type`:`type`]
1338-
1. type: 7 (`upgradable`)
1337+
* [`...*byte`:`type`]
1338+
1. type: 7 (`upgradable_channel_type`)
13391339
2. data:
1340-
* [`...*channel_type`:`upgrades`]
1341-
1342-
1. subtype: `channel_type`
1343-
2. data:
1344-
* [`u16`:`len`]
1345-
* [`len*byte`:`features`]
1340+
* [`...*byte`:`type`]
13461341

13471342
`next_commitment_number`: A commitment number is a 48-bit
13481343
incrementing counter for each commitment transaction; counters
@@ -1569,38 +1564,31 @@ channel upgraded and the other not. But this will eventually be
15691564
resolved: the channel cannot progress until both sides have received
15701565
`channel_reestablish` anyway.
15711566

1572-
Channel features are explicitly enumerated as `channel_type`
1573-
bitfields, using odd features bits. The currently defined types are:
1574-
- no features (no bits set)
1575-
- `option_static_remotekey` (bit 13)
1576-
- `option_anchor_outputs` and `option_static_remotekey` (bits 21 and 13)
1577-
- `option_anchors_zero_fee_htlc_tx` and `option_static_remotekey` (bits 23 and 13)
1578-
15791567
#### Requirements
15801568

15811569
A node sending `channel_reestablish`, if it supports upgrading channels:
15821570
- MUST set `next_to_send` the commitment number of the next `commitment_signed` it expects to send.
15831571
- if it initiated the channel:
1584-
- MUST set `desired_type` to the channel_type it wants for the channel.
1572+
- MUST set `desired_channel_type` to the defined channel type it wants for the channel.
15851573
- otherwise:
1586-
- MUST set `current_type` to the current channel_type of the channel.
1587-
- MUST set `upgradable` to the channel types it could change to.
1588-
- MAY not set `upgradable` if it would be empty.
1574+
- MUST set `current_channel_type` to the current channel type of the channel.
1575+
- If it sets `upgradable_channel_type`:
1576+
- MUST set it to a defined channel type it could change to.
15891577

15901578
A node receiving `channel_reestablish`:
15911579
- if it has to retransmit `commitment_signed` or `revoke_and_ack`:
1592-
- MUST consider the channel feature change failed.
1580+
- MUST consider the channel type change failed.
15931581
- if `next_to_send` is missing, or not equal to the `next_commitment_number` it sent:
1594-
- MUST consider the channel feature change failed.
1582+
- MUST consider the channel type change failed.
15951583
- if updates are pending on either sides' commitment transaction:
1596-
- MUST consider the channel feature change failed.
1584+
- MUST consider the channel type change failed.
15971585
- otherwise:
1598-
- if `desired_type` matches `current_type` or any `upgradable` `upgrades`:
1599-
- MUST consider the channel type to be `desired_type`.
1586+
- if `desired_channel_type` matches `current_channel_type` or `upgradable_channel_type`:
1587+
- MUST consider the channel type to be `desired_channel_type`.
16001588
- otherwise:
1601-
- MUST consider the channel feature change failed.
1602-
- if there is a `current_type` field:
1603-
- MUST consider the channel type to be `current_type`.
1589+
- MUST consider the channel type change failed.
1590+
- if there is a `current_channel_type` field:
1591+
- MUST consider the channel type to be `current_channel_type`.
16041592

16051593
#### Rationale
16061594

@@ -1618,17 +1606,17 @@ are attempted (all of which require successful exchange of
16181606
`channel_reestablish` messages).
16191607

16201608
On reconnect, if only the initiator is upgraded, it will reflect this
1621-
upgrade in the next `desired_type`, causing the non-initiator to
1609+
upgrade in the next `desired_channel_type`, causing the non-initiator to
16221610
upgrade. If only the non-initiator is upgraded, it will be reflected
1623-
in `current_type` and the initiator will consider itself upgraded.
1624-
1625-
There can be desynchronization across multiple upgrades. Both nodes
1626-
start on channel_type A, initiator sets `desired_type` B, receives
1627-
`channel_reestablish` from A which has B in `upgradable`, but B
1628-
doesn't receive `channel_reestablish`. On reconnect, initiator tries
1629-
to upgrade again, setting `desired_type` to C, which is not in B's
1630-
`upgradable` so fails. This is why, on such a failed upgrade, the
1631-
initiator considers the `current_type` given by the non-initiator to
1611+
in `current_channel_type` and the initiator will consider itself upgraded.
1612+
1613+
There can be desynchronization across multiple upgrades. Both A and B nodes
1614+
start on channel_type T1, A sets `desired_channel_type` T2, receives
1615+
`channel_reestablish` from B which has `upgradable_channel_type` T2, but B
1616+
doesn't receive `channel_reestablish`. On reconnect, A tries
1617+
to upgrade again, setting `desired_channel_type` to T3, which is not equal
1618+
to B's `upgradable_channel_type` so fails. This is why, on such a failed upgrade, the
1619+
initiator considers the `current_channel_type` given by the non-initiator to
16321620
be canonical.
16331621

16341622
# Authors

0 commit comments

Comments
 (0)