Skip to content

Commit a866ba7

Browse files
committed
cfg-gate async signing logic
We are intending to release without having completed our async signing logic, which sadly means we need to cfg-gate it to ensure we restore the previous state of panicking on signer errors, rather than putting us in a stuck state with no way to recover. Here we add a new `async_signing` cfg flag and use it to gate all the new logic from lightningdevkit#2558 effectively reverting commits 1da2929 through 014a336.
1 parent 304224e commit a866ba7

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

ci/check-cfg-flags.py

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def check_cfg_tag(cfg):
8686
pass
8787
elif cfg == "taproot":
8888
pass
89+
elif cfg == "async_signing":
90+
pass
8991
elif cfg == "require_route_graph_test":
9092
pass
9193
else:

ci/ci-tests.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ if [ -f "$(which arm-none-eabi-gcc)" ]; then
171171
popd
172172
fi
173173

174-
echo -e "\n\nTest Taproot builds"
175-
pushd lightning
174+
echo -e "\n\nTest cfg-flag builds"
176175
RUSTFLAGS="$RUSTFLAGS --cfg=taproot" cargo test --verbose --color always -p lightning
177-
popd
176+
RUSTFLAGS="$RUSTFLAGS --cfg=async_signing" cargo test --verbose --color always -p lightning

lightning/src/ln/channel.rs

+26-11
Original file line numberDiff line numberDiff line change
@@ -2434,8 +2434,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
24342434
.ok();
24352435

24362436
if funding_signed.is_none() {
2437-
log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
2438-
self.signer_pending_funding = true;
2437+
#[cfg(not(async_signing))] {
2438+
panic!("Failed to get signature for funding_signed");
2439+
}
2440+
#[cfg(async_signing)] {
2441+
log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
2442+
self.signer_pending_funding = true;
2443+
}
24392444
} else if self.signer_pending_funding {
24402445
log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
24412446
self.signer_pending_funding = false;
@@ -4259,7 +4264,7 @@ impl<SP: Deref> Channel<SP> where
42594264

42604265
/// Indicates that the signer may have some signatures for us, so we should retry if we're
42614266
/// blocked.
4262-
#[allow(unused)]
4267+
#[cfg(async_signing)]
42634268
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> SignerResumeUpdates where L::Target: Logger {
42644269
let commitment_update = if self.context.signer_pending_commitment_update {
42654270
self.get_last_commitment_update_for_send(logger).ok()
@@ -4363,11 +4368,16 @@ impl<SP: Deref> Channel<SP> where
43634368
}
43644369
update
43654370
} else {
4366-
if !self.context.signer_pending_commitment_update {
4367-
log_trace!(logger, "Commitment update awaiting signer: setting signer_pending_commitment_update");
4368-
self.context.signer_pending_commitment_update = true;
4371+
#[cfg(not(async_signing))] {
4372+
panic!("Failed to get signature for new commitment state");
4373+
}
4374+
#[cfg(async_signing)] {
4375+
if !self.context.signer_pending_commitment_update {
4376+
log_trace!(logger, "Commitment update awaiting signer: setting signer_pending_commitment_update");
4377+
self.context.signer_pending_commitment_update = true;
4378+
}
4379+
return Err(());
43694380
}
4370-
return Err(());
43714381
};
43724382
Ok(msgs::CommitmentUpdate {
43734383
update_add_htlcs, update_fulfill_htlcs, update_fail_htlcs, update_fail_malformed_htlcs, update_fee,
@@ -6448,9 +6458,14 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
64486458

64496459
let funding_created = self.get_funding_created_msg(logger);
64506460
if funding_created.is_none() {
6451-
if !self.context.signer_pending_funding {
6452-
log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
6453-
self.context.signer_pending_funding = true;
6461+
#[cfg(not(async_signing))] {
6462+
panic!("Failed to get signature for new funding creation");
6463+
}
6464+
#[cfg(async_signing)] {
6465+
if !self.context.signer_pending_funding {
6466+
log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
6467+
self.context.signer_pending_funding = true;
6468+
}
64546469
}
64556470
}
64566471

@@ -6796,7 +6811,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
67966811

67976812
/// Indicates that the signer may have some signatures for us, so we should retry if we're
67986813
/// blocked.
6799-
#[allow(unused)]
6814+
#[cfg(async_signing)]
68006815
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
68016816
if self.context.signer_pending_funding && self.context.is_outbound() {
68026817
log_trace!(logger, "Signer unblocked a funding_created");

lightning/src/ln/channelmanager.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7322,8 +7322,7 @@ where
73227322
/// attempted in every channel, or in the specifically provided channel.
73237323
///
73247324
/// [`ChannelSigner`]: crate::sign::ChannelSigner
7325-
#[cfg(test)] // This is only implemented for one signer method, and should be private until we
7326-
// actually finish implementing it fully.
7325+
#[cfg(async_signing)]
73277326
pub fn signer_unblocked(&self, channel_opt: Option<(PublicKey, ChannelId)>) {
73287327
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
73297328

lightning/src/ln/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ mod monitor_tests;
7676
#[cfg(test)]
7777
#[allow(unused_mut)]
7878
mod shutdown_tests;
79-
#[cfg(test)]
79+
#[cfg(all(test, async_signing))]
8080
#[allow(unused_mut)]
8181
mod async_signer_tests;
8282

0 commit comments

Comments
 (0)