Skip to content

Commit 99670ec

Browse files
committed
Implement quiescence protocol
Quiescence is a new protocol feature that allows for channels to undergo "fundamental" changes (i.e., protocol upgrade) while there are no pending updates on either side. Its first use case will be to carry out channel splices, to ensure new HTLC/fee updates are not made while a splice is being negotiated. Each side of the channel is allowed to send a `stfu` message if any of their outbound updates are not pending for either side (i.e., irrevocably committed on both commitment transactions). Once both sides exchange `stfu`, the channel becomes quiescent. A message timeout is enforced during the quiescence handshake to ensure we can eventually re-establish the channel and propose new HTLC/fee updates again. Several new state flags have been added to `ChannelState::ChannelReady` to track the progress of the quiescence handshake. Once the channel becomes quiescent, all flags related to the handshake are cleared, and the `QUIESCENT` flag is enabled. While quiescence is not a persistent protocol (it implicitly terminates upon peer disconnection), and updates cannot be made, we still need to track `MONITOR_UPDATE_IN_PROGRESS` as it may be required by the quiescence-dependent protocol, like in the case of splicing.
1 parent 506367e commit 99670ec

File tree

5 files changed

+850
-13
lines changed

5 files changed

+850
-13
lines changed

lightning-types/src/features.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
//! (see [bLIP 32](https://github.com/lightning/blips/blob/master/blip-0032.md) for more information).
7575
//! - `ProvideStorage` - Indicates that we offer the capability to store data of our peers
7676
//! (see https://github.com/lightning/bolts/pull/1110 for more info).
77+
//! - `Quiescence` - protocol to quiesce a channel by indicating that "SomeThing Fundamental is Underway"
78+
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#channel-quiescence) for more information).
7779
//!
7880
//! LDK knows about the following features, but does not support them:
7981
//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be
@@ -152,7 +154,7 @@ mod sealed {
152154
// Byte 3
153155
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
154156
// Byte 4
155-
OnionMessages,
157+
Quiescence | OnionMessages,
156158
// Byte 5
157159
ProvideStorage | ChannelType | SCIDPrivacy,
158160
// Byte 6
@@ -173,7 +175,7 @@ mod sealed {
173175
// Byte 3
174176
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
175177
// Byte 4
176-
OnionMessages,
178+
Quiescence | OnionMessages,
177179
// Byte 5
178180
ProvideStorage | ChannelType | SCIDPrivacy,
179181
// Byte 6
@@ -536,6 +538,16 @@ mod sealed {
536538
supports_taproot,
537539
requires_taproot
538540
);
541+
define_feature!(
542+
35,
543+
Quiescence,
544+
[InitContext, NodeContext],
545+
"Feature flags for `option_quiesce`.",
546+
set_quiescence_optional,
547+
set_quiescence_required,
548+
supports_quiescence,
549+
requires_quiescence
550+
);
539551
define_feature!(
540552
39,
541553
OnionMessages,
@@ -1195,6 +1207,7 @@ mod tests {
11951207
init_features.set_channel_type_optional();
11961208
init_features.set_scid_privacy_optional();
11971209
init_features.set_zero_conf_optional();
1210+
init_features.set_quiescence_optional();
11981211

11991212
assert!(init_features.initial_routing_sync());
12001213
assert!(!init_features.supports_upfront_shutdown_script());
@@ -1215,7 +1228,7 @@ mod tests {
12151228
assert_eq!(node_features.flags[1], 0b01010001);
12161229
assert_eq!(node_features.flags[2], 0b10001010);
12171230
assert_eq!(node_features.flags[3], 0b00001010);
1218-
assert_eq!(node_features.flags[4], 0b10000000);
1231+
assert_eq!(node_features.flags[4], 0b10001000);
12191232
assert_eq!(node_features.flags[5], 0b10100000);
12201233
assert_eq!(node_features.flags[6], 0b00001000);
12211234
}

0 commit comments

Comments
 (0)