From: Matt Corallo Date: Wed, 13 Dec 2023 22:55:32 +0000 (+0000) Subject: cfg-gate async signing logic X-Git-Tag: v0.0.119~7^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=refs%2Fheads%2F2023-12-no-async-signing;p=rust-lightning 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 #2558 effectively reverting commits 1da29290e7af03a5dfc207ee6a5c848a9740bd32 through 014a336e592bfc8cb49929b799b9d6d9286dab16. --- diff --git a/ci/check-cfg-flags.py b/ci/check-cfg-flags.py index 85cbde853..02b598cd4 100755 --- a/ci/check-cfg-flags.py +++ b/ci/check-cfg-flags.py @@ -86,6 +86,8 @@ def check_cfg_tag(cfg): pass elif cfg == "taproot": pass + elif cfg == "async_signing": + pass elif cfg == "require_route_graph_test": pass else: diff --git a/ci/ci-tests.sh b/ci/ci-tests.sh index 11934a830..374e3616c 100755 --- a/ci/ci-tests.sh +++ b/ci/ci-tests.sh @@ -171,7 +171,6 @@ if [ -f "$(which arm-none-eabi-gcc)" ]; then popd fi -echo -e "\n\nTest Taproot builds" -pushd lightning +echo -e "\n\nTest cfg-flag builds" RUSTFLAGS="$RUSTFLAGS --cfg=taproot" cargo test --verbose --color always -p lightning -popd +RUSTFLAGS="$RUSTFLAGS --cfg=async_signing" cargo test --verbose --color always -p lightning diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 375beb6d6..050585ef2 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -2434,8 +2434,13 @@ impl ChannelContext where SP::Target: SignerProvider { .ok(); if funding_signed.is_none() { - log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding"); - self.signer_pending_funding = true; + #[cfg(not(async_signing))] { + panic!("Failed to get signature for funding_signed"); + } + #[cfg(async_signing)] { + log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding"); + self.signer_pending_funding = true; + } } else if self.signer_pending_funding { log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding"); self.signer_pending_funding = false; @@ -4259,7 +4264,7 @@ impl Channel where /// Indicates that the signer may have some signatures for us, so we should retry if we're /// blocked. - #[allow(unused)] + #[cfg(async_signing)] pub fn signer_maybe_unblocked(&mut self, logger: &L) -> SignerResumeUpdates where L::Target: Logger { let commitment_update = if self.context.signer_pending_commitment_update { self.get_last_commitment_update_for_send(logger).ok() @@ -4363,11 +4368,16 @@ impl Channel where } update } else { - if !self.context.signer_pending_commitment_update { - log_trace!(logger, "Commitment update awaiting signer: setting signer_pending_commitment_update"); - self.context.signer_pending_commitment_update = true; + #[cfg(not(async_signing))] { + panic!("Failed to get signature for new commitment state"); + } + #[cfg(async_signing)] { + if !self.context.signer_pending_commitment_update { + log_trace!(logger, "Commitment update awaiting signer: setting signer_pending_commitment_update"); + self.context.signer_pending_commitment_update = true; + } + return Err(()); } - return Err(()); }; Ok(msgs::CommitmentUpdate { update_add_htlcs, update_fulfill_htlcs, update_fail_htlcs, update_fail_malformed_htlcs, update_fee, @@ -6448,9 +6458,14 @@ impl OutboundV1Channel where SP::Target: SignerProvider { let funding_created = self.get_funding_created_msg(logger); if funding_created.is_none() { - if !self.context.signer_pending_funding { - log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding"); - self.context.signer_pending_funding = true; + #[cfg(not(async_signing))] { + panic!("Failed to get signature for new funding creation"); + } + #[cfg(async_signing)] { + if !self.context.signer_pending_funding { + log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding"); + self.context.signer_pending_funding = true; + } } } @@ -6796,7 +6811,7 @@ impl OutboundV1Channel where SP::Target: SignerProvider { /// Indicates that the signer may have some signatures for us, so we should retry if we're /// blocked. - #[allow(unused)] + #[cfg(async_signing)] pub fn signer_maybe_unblocked(&mut self, logger: &L) -> Option where L::Target: Logger { if self.context.signer_pending_funding && self.context.is_outbound() { log_trace!(logger, "Signer unblocked a funding_created"); diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index f08096426..9536a9366 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -7322,8 +7322,7 @@ where /// attempted in every channel, or in the specifically provided channel. /// /// [`ChannelSigner`]: crate::sign::ChannelSigner - #[cfg(test)] // This is only implemented for one signer method, and should be private until we - // actually finish implementing it fully. + #[cfg(async_signing)] pub fn signer_unblocked(&self, channel_opt: Option<(PublicKey, ChannelId)>) { let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self); diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs index 827d77419..43ec34eaf 100644 --- a/lightning/src/ln/mod.rs +++ b/lightning/src/ln/mod.rs @@ -76,7 +76,7 @@ mod monitor_tests; #[cfg(test)] #[allow(unused_mut)] mod shutdown_tests; -#[cfg(test)] +#[cfg(all(test, async_signing))] #[allow(unused_mut)] mod async_signer_tests;