Skip to content

Commit 73a99ff

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 2759682 commit 73a99ff

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
@@ -2116,7 +2116,11 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21162116
}
21172117
};
21182118

2119-
self.signer_pending_funding = false;
2119+
if self.signer_pending_funding {
2120+
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
2121+
self.signer_pending_funding = false;
2122+
}
2123+
21202124
Some(msgs::FundingCreated {
21212125
temporary_channel_id: self.temporary_channel_id.unwrap(),
21222126
funding_txid: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
@@ -2150,7 +2154,14 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21502154
partial_signature_with_nonce: None,
21512155
})
21522156
.ok();
2153-
self.signer_pending_funding = funding_signed.is_none();
2157+
2158+
if funding_signed.is_none() {
2159+
log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
2160+
self.signer_pending_funding = true;
2161+
} else if self.signer_pending_funding {
2162+
log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
2163+
self.signer_pending_funding = false;
2164+
}
21542165

21552166
// We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
21562167
(counterparty_initial_commitment_tx, funding_signed)
@@ -3994,6 +4005,13 @@ impl<SP: Deref> Channel<SP> where
39944005
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
39954006
self.context.get_funding_created_msg(logger)
39964007
} else { None };
4008+
4009+
log_trace!(logger, "Signer unblocked with {} commitment_update, {} funding_signed, {} funding_created, and {} channel_ready",
4010+
if commitment_update.is_some() { "a" } else { "no" },
4011+
if funding_signed.is_some() { "a" } else { "no" },
4012+
if funding_created.is_some() { "a" } else { "no" },
4013+
if channel_ready.is_some() { "a" } else { "no" });
4014+
39974015
SignerResumeUpdates {
39984016
commitment_update,
39994017
funding_signed,
@@ -4071,14 +4089,21 @@ impl<SP: Deref> Channel<SP> where
40714089
})
40724090
} else { None };
40734091

4074-
log_trace!(logger, "Regenerated latest commitment update in channel {} with{} {} update_adds, {} update_fulfills, {} update_fails, and {} update_fail_malformeds",
4092+
log_trace!(logger, "Regenerating latest commitment update in channel {} with{} {} update_adds, {} update_fulfills, {} update_fails, and {} update_fail_malformeds",
40754093
&self.context.channel_id(), if update_fee.is_some() { " update_fee," } else { "" },
40764094
update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len(), update_fail_malformed_htlcs.len());
4095+
40774096
let commitment_signed = if let Ok(update) = self.send_commitment_no_state_update(logger).map(|(cu, _)| cu) {
4078-
self.context.signer_pending_commitment_update = false;
4097+
if self.context.signer_pending_commitment_update {
4098+
log_trace!(logger, "Commitment update generated: clearing signer_pending_commitment_update");
4099+
self.context.signer_pending_commitment_update = false;
4100+
}
40794101
update
40804102
} else {
4081-
self.context.signer_pending_commitment_update = true;
4103+
if !self.context.signer_pending_commitment_update {
4104+
log_trace!(logger, "Commitment update awaiting signer: setting signer_pending_commitment_update");
4105+
self.context.signer_pending_commitment_update = true;
4106+
}
40824107
return Err(());
40834108
};
40844109
Ok(msgs::CommitmentUpdate {
@@ -6074,7 +6099,10 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
60746099

60756100
let funding_created = self.context.get_funding_created_msg(logger);
60766101
if funding_created.is_none() {
6077-
self.context.signer_pending_funding = true;
6102+
if !self.context.signer_pending_funding {
6103+
log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
6104+
self.context.signer_pending_funding = true;
6105+
}
60786106
}
60796107

60806108
let channel = Channel {

0 commit comments

Comments
 (0)