Skip to content

Commit 1708036

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 7303833 commit 1708036

File tree

5 files changed

+863
-13
lines changed

5 files changed

+863
-13
lines changed

lightning-types/src/features.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
//! (see the [`Trampoline` feature proposal](https://github.com/lightning/bolts/pull/836) for more information).
7373
//! - `DnsResolver` - supports resolving DNS names to TXT DNSSEC proofs for BIP 353 payments
7474
//! (see [bLIP 32](https://github.com/lightning/blips/blob/master/blip-0032.md) for more information).
75+
//! - `Quiescence` - protocol to quiesce a channel by indicating that "SomeThing Fundamental is Underway"
76+
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#channel-quiescence) for more information).
7577
//!
7678
//! LDK knows about the following features, but does not support them:
7779
//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be
@@ -150,7 +152,7 @@ mod sealed {
150152
// Byte 3
151153
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
152154
// Byte 4
153-
OnionMessages,
155+
Quiescence | OnionMessages,
154156
// Byte 5
155157
ChannelType | SCIDPrivacy,
156158
// Byte 6
@@ -171,7 +173,7 @@ mod sealed {
171173
// Byte 3
172174
RouteBlinding | ShutdownAnySegwit | DualFund | Taproot,
173175
// Byte 4
174-
OnionMessages,
176+
Quiescence | OnionMessages,
175177
// Byte 5
176178
ChannelType | SCIDPrivacy,
177179
// Byte 6
@@ -534,6 +536,16 @@ mod sealed {
534536
supports_taproot,
535537
requires_taproot
536538
);
539+
define_feature!(
540+
35,
541+
Quiescence,
542+
[InitContext, NodeContext],
543+
"Feature flags for `option_quiesce`.",
544+
set_quiescence_optional,
545+
set_quiescence_required,
546+
supports_quiescence,
547+
requires_quiescence
548+
);
537549
define_feature!(
538550
39,
539551
OnionMessages,
@@ -1175,6 +1187,7 @@ mod tests {
11751187
init_features.set_channel_type_optional();
11761188
init_features.set_scid_privacy_optional();
11771189
init_features.set_zero_conf_optional();
1190+
init_features.set_quiescence_optional();
11781191

11791192
assert!(init_features.initial_routing_sync());
11801193
assert!(!init_features.supports_upfront_shutdown_script());
@@ -1195,7 +1208,7 @@ mod tests {
11951208
assert_eq!(node_features.flags[1], 0b01010001);
11961209
assert_eq!(node_features.flags[2], 0b10001010);
11971210
assert_eq!(node_features.flags[3], 0b00001010);
1198-
assert_eq!(node_features.flags[4], 0b10000000);
1211+
assert_eq!(node_features.flags[4], 0b10001000);
11991212
assert_eq!(node_features.flags[5], 0b10100000);
12001213
assert_eq!(node_features.flags[6], 0b00001000);
12011214
}

0 commit comments

Comments
 (0)