-
Notifications
You must be signed in to change notification settings - Fork 411
Add logging in route hint filtering #1770
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 logging in route hint filtering #1770
Conversation
e7d17e3
to
2545426
Compare
Codecov ReportBase: 90.91% // Head: 90.91% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1770 +/- ##
=======================================
Coverage 90.91% 90.91%
=======================================
Files 87 87
Lines 48048 48078 +30
Branches 48048 48078 +30
=======================================
+ Hits 43681 43711 +30
Misses 4367 4367
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Looks good and is definitely helpful :)! Just leaving some suggestions for clarifications for phantom invoice route hints filtering.
lightning-invoice/src/utils.rs
Outdated
continue; | ||
} | ||
|
||
if channel.is_public { | ||
// If any public channel exists, return no hints and let the sender | ||
// look at the public channels instead. | ||
log_debug!(logger, "Not including invoice route hints on account of public channel {}", |
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.
This wording will be pretty confusing for phantom invoices as well. Say a phantom invoice is generated using 3 participating nodes, where only one of the nodes have public channels, but the other 2 have only private channels. That invoice will include invoice route hints for the channels of the 2 participating nodes with private channels only, yet log this message due to the 3rd participating node with public channel(s), hence incorrectly indicating that no invoice route hints were included.
Also note that phantom invoices will include invoice route hints for every participating node even if all of them have public channels. Phantom hops with the node id for every participating node will be included in the invoice route hints due to:
rust-lightning/lightning-invoice/src/utils.rs
Line 178 in 6772609
route_hints.push(RouteHint(vec![])) |
Perhaps we could phrase this sentence as something like:
"Non of the considered channels are included in the invoice route hints on account of public channel {}."
Not sure what the best way to phrase this is though :)!
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.
Tweaked the wording. Should be clearer now with the additional logging, too.
lightning-invoice/src/utils.rs
Outdated
let has_enough_inbound_capacity = channel.inbound_capacity_msat >= min_inbound_capacity; | ||
let include_channel = !min_capacity_channel_exists || has_enough_inbound_capacity; | ||
if !include_channel { | ||
log_debug!(logger, "Ignoring channel {} without enough capacity for invoice route hints", | ||
log_bytes!(channel.channel_id)); | ||
} | ||
include_channel |
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.
This will clash a little with the cleanup in #1769 :). I have no preference for which version we go with, but could be worth considering by either version.
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.
Based on #1769 now though that may need some changes to the filtering logic still.
2545426
to
7bc5d46
Compare
Feel free to squash, basically LGTM but the super verbose channel-inclusion-exclusion stuff may make more sense as |
Hmm... seems like why a channel was excluded is more important than which channels were included given the latter can be gleaned from the invoice? I'm fine with making everything And anything logged outside |
7bc5d46
to
33a5b89
Compare
Squashed and changed all logging to |
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.
LGTM, leaving one suggestion that's just a nice to have!
lightning-invoice/src/utils.rs
Outdated
match filtered_channels.entry(channel.counterparty.node_id) { | ||
hash_map::Entry::Occupied(mut entry) => { | ||
let current_max_capacity = entry.get().inbound_capacity_msat; | ||
if channel.inbound_capacity_msat < current_max_capacity { | ||
continue; | ||
} | ||
log_trace!(logger, "Preferring channel {} ({} msats) over {} ({} msats) for invoice route hints", |
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.
Could also be worth mentioning the counterparty node id for the channel here, due to the filtering only including 1 channel per counterparty node.
} | ||
|
||
match filtered_channels.entry(channel.counterparty.node_id) { | ||
hash_map::Entry::Occupied(mut entry) => { | ||
let current_max_capacity = entry.get().inbound_capacity_msat; | ||
if channel.inbound_capacity_msat < current_max_capacity { |
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 sorry, we should probably log here that the channel is ignored, no?
If it's alright with Viktor, feel free to keep this one squashed so we can land it ASAP. |
That's ok for me @TheBlueMatt! The new changes looks good. They could possibly be dryed up a little instead of being repeated twice, but then again being this explicit makes it easier to read, so the current version is fine for me:). LGTM once squashed. |
Knowing why a channel was not included as an invoice route hint can be valuable. Add logging on the decisions made when filtering channels.
b75e111
to
90c9763
Compare
@@ -353,6 +375,8 @@ where | |||
if let Some(amt) = amt_msat { | |||
invoice = invoice.amount_milli_satoshis(amt); | |||
} | |||
|
|||
let route_hints = filter_channels(channels, amt_msat, &logger); |
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.
Some changes in this method seem unrelated
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.
I need the filter_channels
logging to come after the logging above, the latter of which needs payment_hash
.
Knowing why a channel was not included as an invoice route hint can be valuable. Add logging on the decisions made when filtering channels.