-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
routerrpc: fix estimateroutefee for public route hints #9433
base: master
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
b3d97b5
to
eb1d56a
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 for the quick fix, looking good.
I think a unit-test might be worthwhile for the new behaviour.
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.
Concept ACK, in principle, a single public hop hint doesn't lead to fee estimation errors, I think. The advantage in checking if we know the last hop is that we'll also probe it and know if it supports the payment as opposed to the case when we assume an LSP.
lnrpc/routerrpc/router_server.go
Outdated
if len(routeHints) == 0 || len(routeHints[0]) == 0 { | ||
return false | ||
} | ||
|
||
refNodeID := routeHints[0][len(routeHints[0])-1].NodeID | ||
refHint := routeHints[0][len(routeHints[0])-1] |
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 we rename the ref
prefixes to something that's more explanatory?
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.
still ref
used ?
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.
renamed it to destHopHint
and also referenced that in the comments.
7be7d83
to
ec2132b
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.
Nice, LGTM.
Please update the documentation otherwise good-to-go
lnrpc/routerrpc/router_server.go
Outdated
if len(routeHints) == 0 || len(routeHints[0]) == 0 { | ||
return false | ||
} | ||
|
||
refNodeID := routeHints[0][len(routeHints[0])-1].NodeID | ||
refHint := routeHints[0][len(routeHints[0])-1] |
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.
still ref
used ?
ec2132b
to
8c8e852
Compare
@gijswijs: review reminder |
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.
Had 1 question and 1 remark: I think there's an unneeded definition in the lspTestCases
struct. I would just remove it.
Apart from that, LGTM 🎉
} | ||
|
||
// Returns ErrEdgeNotFound for private channels. | ||
fetchChannelEndpoints := func(chanID uint64) (route.Vertex, |
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.
👍 Nice mock func.
@@ -284,6 +294,7 @@ func TestIsLsp(t *testing.T) { | |||
isLsp bool | |||
expectedHints [][]zpay32.HopHint | |||
expectedLspHop *zpay32.HopHint | |||
channelID uint64 |
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.
Why is channelID
defined? It appears to not been used anywhere.
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.
removed
lnrpc/routerrpc/router_server.go
Outdated
func isLSP(routeHints [][]zpay32.HopHint) bool { | ||
// true if the destination hop hint in each route hint has the same node id, | ||
// false otherwise. If the destination hop hint of the first route hint contains | ||
// a public channel, the function returns false because we can directly send a |
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.
For my understanding, if there is a public channel in the route hints, it is always in the first route hint?
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.
Not necessarily, I think it would be more robust if we'd check if we know about any last hop to exclude an LSP, because a receiver could in principle mix private and public channels. I think it's also not too inefficient since we only have to check a few hints most of the time. So we should catch the case [[private via nodeX], [public via nodeX], [public via nodeX]]
to not classify nodeX
as an LSP, which could be added as a test.
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 @gijswijs and @bitromortac for this improvement to the robustness of isLSP
. I've added the public channel check for each final hop hint of each route hint as suggested and added a testcase to cover it.
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.
Nice, I think it would be better to check if we know any public last hop to rule out an LSP, see comment, other than that, it looks good 🙏.
lnrpc/routerrpc/router_server.go
Outdated
func isLSP(routeHints [][]zpay32.HopHint) bool { | ||
// true if the destination hop hint in each route hint has the same node id, | ||
// false otherwise. If the destination hop hint of the first route hint contains | ||
// a public channel, the function returns false because we can directly send a |
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.
Not necessarily, I think it would be more robust if we'd check if we know about any last hop to exclude an LSP, because a receiver could in principle mix private and public channels. I think it's also not too inefficient since we only have to check a few hints most of the time. So we should catch the case [[private via nodeX], [public via nodeX], [public via nodeX]]
to not classify nodeX
as an LSP, which could be added as a test.
8c8e852
to
4ecb5e8
Compare
This PR attempts to fix #9431, an edge case in
EstimateRouteFee
.We want to send a probe in case a route hint contains a public edge.