-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PaymentHash
to Record
#2930
Add PaymentHash
to Record
#2930
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2930 +/- ##
==========================================
+ Coverage 89.85% 89.89% +0.04%
==========================================
Files 116 116
Lines 96303 97456 +1153
Branches 96303 97456 +1153
==========================================
+ Hits 86529 87608 +1079
- Misses 7217 7294 +77
+ Partials 2557 2554 -3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! This looks good as a first step, but there's obviously a ton of logs that are missing payment hash info after this. Could you do a pass of all the logs in chain (eg channelmonitor) and channel and see what needs payment hash fields?
@@ -2008,7 +2008,7 @@ macro_rules! handle_error { | |||
let counterparty_node_id = shutdown_res.counterparty_node_id; | |||
let channel_id = shutdown_res.channel_id; | |||
let logger = WithContext::from( | |||
&$self.logger, Some(counterparty_node_id), Some(channel_id), | |||
&$self.logger, Some(counterparty_node_id), Some(channel_id), None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we don't want to always have no payment_hash here, eg this can be called handling an update_add_htlc
which we presumably want to log as associated with a payment hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I get a hold on the payment_hash
here? or identify the update_add_htlc
call ?
lightning/src/ln/channelmanager.rs
Outdated
@@ -6511,7 +6511,8 @@ where | |||
let logger = WithContext::from( | |||
&self.logger, | |||
Some(chan.context.get_counterparty_node_id()), | |||
Some(chan.context.channel_id()) | |||
Some(chan.context.channel_id()), | |||
None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indentation is wrong.
lightning/src/util/logger.rs
Outdated
@@ -120,6 +120,8 @@ pub struct Record<$($args)?> { | |||
pub file: &'static str, | |||
/// The line containing the message. | |||
pub line: u32, | |||
/// The payment hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some real docs here (and maybe move it up to be next to channel/peer_ids).
7091aeb
to
835f5aa
Compare
Thanks for the reivew! Regarding changes in impl<'a, L: Deref> Logger for WithChannelMonitor<'a, L> where L::Target: Logger {
fn log(&self, mut record: Record) {
record.peer_id = self.peer_id;
record.channel_id = self.channel_id;
// record.payment_hash = self.payment_hash;
self.logger.log(record)
}
} For the Regarding |
We could go one of two ways with CHannelMonitor, we could either use |
Hmm? There's no changes in this PR that pass payment hashes to logging in channel.rs, and the wrapping loggers passed into channel.rs methods don't always set a payment hash. We should actually set a payment hash if we're logging something relevant to a payment. |
5c67d47
to
6ceae20
Compare
64dc482
to
1e4b75f
Compare
Ugh, okay, sorry this kinda got put on the back burner during the release rush. Needs a rebase now then we can land it quickly. When you do rebase, please do a quick read-through of at least all the logging calls in channel.rs, channelmanager.rs, and channelmonitor.rs/onchaintx.rs and check that if they need a payment hash they have it. |
1e4b75f
to
7df3773
Compare
Adding the `payment_hash` to `Record` so we are able to track it in logs.
7df3773
to
99539d7
Compare
rebased + went through the mentioned files and it looks good to me. I couldn't find anything relevant in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK if we drop the last two commits. I want to get these tags in messages in peer_handler but they're currently missing so its fine. There'a few places here where we really should have a payment_hash but we currently only have the payment_preimage in scope. In a followup we should consider if we can pass the payment_hash in.
/// | ||
/// Note that this is only filled in for logs pertaining to a specific payment, and will be | ||
/// `None` for logs which are not directly related to a payment. | ||
pub payment_hash: Option<PaymentHash>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a followup, we should put this next to chanel_id
/peer_id
so its not hanging out here all on its own. Same for the Record constructor.
lightning/src/ln/channelmanager.rs
Outdated
let mut msg_event = None; | ||
|
||
if let Some((shutdown_res, update_option)) = shutdown_finish { | ||
let counterparty_node_id = shutdown_res.counterparty_node_id; | ||
let channel_id = shutdown_res.channel_id; | ||
let logger = WithContext::from( | ||
&$self.logger, Some(counterparty_node_id), Some(channel_id), None | ||
&$self.logger, Some(counterparty_node_id), Some(channel_id), payment_hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually not sure if Force-closing channel
should be logged with a payment_hash given its not specific to that payment but now broad.
@@ -5278,6 +5299,7 @@ where | |||
}, skimmed_fee_msat, .. | |||
}, | |||
}) => { | |||
let logger = WithChannelContext::from(&self.logger, &chan.context, Some(payment_hash)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this method in the check_total_value
macro and elsewhere, could use the contextual logger rather than self.logger
. Those logs do currently contain the payment hash anyway, but I think they may print bytes instead of hex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -6468,7 +6490,7 @@ where | |||
if let hash_map::Entry::Occupied(mut chan_phase_entry) = peer_state.channel_by_id.entry(chan_id) { | |||
if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() { | |||
let counterparty_node_id = chan.context.get_counterparty_node_id(); | |||
let logger = WithChannelContext::from(&self.logger, &chan.context); | |||
let logger = WithChannelContext::from(&self.logger, &chan.context, None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we do have the payment_preimage
in this method, which means we could calculate the payment hash. Not sure if worth it but we could. Similar in internal_update_fulfill_htlc
.
99539d7
to
fe7f548
Compare
@TheBlueMatt @valentinewallace I just took out the last two commit but unfortunately wont have time today to look into the rest of the review. feel free to fixup changes if you want this merged, otherwise will handle it tomorrow |
can you please say more about the first part? in which messages in peer_handler we would expect to have payment preimage/hash? there are a couple of places in channel_manager where payment_preimage is defined and I converted that to payment_hash(see last commit) |
571e452
to
f2d9eb5
Compare
Specifically the
Let's not re-hash the payment preimage, I'd rather just leave it out for now. In at least some of the cases we have the payment hash a few functions up in the stack trace and we should look into passing it down, but we don't have to do it right now, it can come in a followup so this doesn't need rebased again. |
f2d9eb5
to
5776c43
Compare
Took out the preimage->hash commit. @valentinewallace would appreciate your input about the last two commits. |
Thanks for adding that. Looks like a promising direction, but tend to agree with Matt that we should land the first two commits on their own to avoid delaying landing this and save them for follow-up :) |
5776c43
to
fe7f548
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Glad we can land this but also looking forward to followup :)
resolves #2767