Skip to content

Commit f060839

Browse files
committed
Add logging whenever we set or clear signer pending state
Add trace-level logging when we change the state of a `signer_pending_*` variable.
1 parent d8348b7 commit f060839

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,11 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21052105
}
21062106
};
21072107

2108-
self.signer_pending_funding = false;
2108+
if self.signer_pending_funding {
2109+
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
2110+
self.signer_pending_funding = false;
2111+
}
2112+
21092113
Some(msgs::FundingCreated {
21102114
temporary_channel_id: self.temporary_channel_id.unwrap(),
21112115
funding_txid: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
@@ -2139,7 +2143,14 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21392143
partial_signature_with_nonce: None,
21402144
})
21412145
.ok();
2142-
self.signer_pending_funding = funding_signed.is_none();
2146+
2147+
if funding_signed.is_none() {
2148+
log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
2149+
self.signer_pending_funding = true;
2150+
} else if self.signer_pending_funding {
2151+
log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
2152+
self.signer_pending_funding = false;
2153+
}
21432154

21442155
// We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
21452156
(counterparty_initial_commitment_tx, funding_signed)
@@ -3980,6 +3991,13 @@ impl<SP: Deref> Channel<SP> where
39803991
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
39813992
self.context.get_funding_created_msg(logger)
39823993
} else { None };
3994+
3995+
log_trace!(logger, "Signer unblocked with {} commitment_update, {} funding_signed, {} funding_created, and {} channel_ready",
3996+
if commitment_update.is_some() { "a" } else { "no" },
3997+
if funding_signed.is_some() { "a" } else { "no" },
3998+
if funding_created.is_some() { "a" } else { "no" },
3999+
if channel_ready.is_some() { "a" } else { "no" });
4000+
39834001
SignerResumeUpdates {
39844002
commitment_update,
39854003
funding_signed,
@@ -4057,14 +4075,21 @@ impl<SP: Deref> Channel<SP> where
40574075
})
40584076
} else { None };
40594077

4060-
log_trace!(logger, "Regenerated latest commitment update in channel {} with{} {} update_adds, {} update_fulfills, {} update_fails, and {} update_fail_malformeds",
4078+
log_trace!(logger, "Regenerating latest commitment update in channel {} with{} {} update_adds, {} update_fulfills, {} update_fails, and {} update_fail_malformeds",
40614079
&self.context.channel_id(), if update_fee.is_some() { " update_fee," } else { "" },
40624080
update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len(), update_fail_malformed_htlcs.len());
4081+
40634082
let commitment_signed = if let Ok(update) = self.send_commitment_no_state_update(logger).map(|(cu, _)| cu) {
4064-
self.context.signer_pending_commitment_update = false;
4083+
if self.context.signer_pending_commitment_update {
4084+
log_trace!(logger, "Commitment update generated: clearing signer_pending_commitment_update");
4085+
self.context.signer_pending_commitment_update = false;
4086+
}
40654087
update
40664088
} else {
4067-
self.context.signer_pending_commitment_update = true;
4089+
if !self.context.signer_pending_commitment_update {
4090+
log_trace!(logger, "Commitment update awaiting signer: setting signer_pending_commitment_update");
4091+
self.context.signer_pending_commitment_update = true;
4092+
}
40684093
return Err(());
40694094
};
40704095
Ok(msgs::CommitmentUpdate {
@@ -6058,7 +6083,10 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
60586083

60596084
let funding_created = self.context.get_funding_created_msg(logger);
60606085
if funding_created.is_none() {
6061-
self.context.signer_pending_funding = true;
6086+
if !self.context.signer_pending_funding {
6087+
log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
6088+
self.context.signer_pending_funding = true;
6089+
}
60626090
}
60636091

60646092
let channel = Channel {

0 commit comments

Comments
 (0)