]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Disable fuzzing-reachable debug assertions in `ChannelMonitor`s
authorMatt Corallo <git@bluematt.me>
Mon, 25 Dec 2023 00:54:45 +0000 (00:54 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 2 Feb 2024 18:04:51 +0000 (18:04 +0000)
lightning/src/chain/channelmonitor.rs
lightning/src/chain/onchaintx.rs

index 55b7b503fdb06b39e59358eedf917ad684e2147d..fb5c18eae97912db08efe73df26a363704e41ada 100644 (file)
@@ -3172,7 +3172,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                                                        (htlc, htlc_source.as_ref().map(|htlc_source| htlc_source.as_ref()))
                                                ), logger);
                                } else {
-                                       debug_assert!(false, "We should have per-commitment option for any recognized old commitment txn");
+                                       // Our fuzzers aren't contrained by pesky things like valid signatures, so can
+                                       // spend our funding output with a transaction which doesn't match our past
+                                       // commitment transactions. Thus, we can only debug-assert here when not
+                                       // fuzzing.
+                                       debug_assert!(cfg!(fuzzing), "We should have per-commitment option for any recognized old commitment txn");
                                        fail_unbroadcast_htlcs!(self, "revoked counterparty", commitment_txid, tx, height,
                                                block_hash, [].iter().map(|reference| *reference), logger);
                                }
index 59c98f05ebc4018f5915165d05e7be8facc697b9..108ff009355e9eed0eba171fef22bb1850132c60 100644 (file)
@@ -806,7 +806,9 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
                                                claim_id
                                        },
                                };
-                               debug_assert!(self.pending_claim_requests.get(&claim_id).is_none());
+                               // Because fuzzing can cause hash collisions, we can end up with conflicting claim
+                               // ids here, so we only assert when not fuzzing.
+                               debug_assert!(cfg!(fuzzing) || self.pending_claim_requests.get(&claim_id).is_none());
                                for k in req.outpoints() {
                                        log_info!(logger, "Registering claiming request for {}:{}", k.txid, k.vout);
                                        self.claimable_outpoints.insert(k.clone(), (claim_id, conf_height));