-
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
routing: fix fee limit condition #8941
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -697,7 +697,6 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, | |
// processEdge is a helper closure that will be used to make sure edges | ||
// satisfy our specific requirements. | ||
processEdge := func(fromVertex route.Vertex, | ||
fromFeatures *lnwire.FeatureVector, | ||
edge *unifiedEdge, toNodeDist *nodeWithDist) { | ||
|
||
edgesExpanded++ | ||
|
@@ -724,6 +723,24 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, | |
amountToSend := toNodeDist.netAmountReceived + | ||
lnwire.MilliSatoshi(inboundFee) | ||
|
||
// Check if accumulated fees would exceed fee limit when this | ||
// node would be added to the path. | ||
totalFee := int64(amountToSend) - int64(amt) | ||
|
||
log.Trace(lnutils.NewLogClosure(func() string { | ||
return fmt.Sprintf( | ||
"Checking fromVertex (%v) with "+ | ||
"minInboundFee=%v, inboundFee=%v, "+ | ||
"amountToSend=%v, amt=%v, totalFee=%v", | ||
fromVertex, minInboundFee, inboundFee, | ||
amountToSend, amt, totalFee, | ||
) | ||
})) | ||
|
||
if totalFee > 0 && lnwire.MilliSatoshi(totalFee) > r.FeeLimit { | ||
return | ||
} | ||
|
||
// Request the success probability for this edge. | ||
edgeProbability := r.ProbabilitySource( | ||
fromVertex, toNodeDist.node, amountToSend, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also correct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in that case it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the fee is just passed in there to be converted to |
||
|
@@ -780,13 +797,6 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, | |
netAmountToReceive := amountToSend + | ||
lnwire.MilliSatoshi(outboundFee) | ||
|
||
// Check if accumulated fees would exceed fee limit when this | ||
// node would be added to the path. | ||
totalFee := int64(netAmountToReceive) - int64(amt) | ||
if totalFee > 0 && lnwire.MilliSatoshi(totalFee) > r.FeeLimit { | ||
return | ||
} | ||
|
||
// Calculate total probability of successfully reaching target | ||
// by multiplying the probabilities. Both this edge and the rest | ||
// of the route must succeed. | ||
|
@@ -813,7 +823,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, | |
// weight composed of the fee that this node will charge and | ||
// the amount that will be locked for timeLockDelta blocks in | ||
// the HTLC that is handed out to fromVertex. | ||
weight := edgeWeight(netAmountToReceive, fee, timeLockDelta) | ||
weight := edgeWeight(amountToSend, fee, timeLockDelta) | ||
|
||
// Compute the tentative weight to this new channel/edge | ||
// which is the weight from our toNode to the target node | ||
|
@@ -1035,7 +1045,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, | |
|
||
// Check if this candidate node is better than what we | ||
// already have. | ||
processEdge(fromNode, fromFeatures, edge, partialPath) | ||
processEdge(fromNode, edge, partialPath) | ||
} | ||
|
||
if nodeHeap.Len() == 0 { | ||
|
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 find this log helpful when checking the behavior from the itest,
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.
+1 for the trace log, would be helpful when debugging inbound fees.
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 added the trace log to be visible in both itest cases (without and with the fix)