-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Consider opportunity cost of local channel fees in pathfinding #7361
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
Consider opportunity cost of local channel fees in pathfinding #7361
Conversation
a690a02
to
6795bd4
Compare
|
6795bd4
to
5cd8016
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.
cACK
I'll leave the path finding details up to the path finding wizards 🧙♂️
I think it's not that much of a big change, plus it's configurable thus the ACK
P.S: another nit: make sure your commits follow the guidelines, i.e. <package>: <message describing change>
// LocalOpportunityCost defines whether to consider the local fee rate | ||
// of the first hop channel when evaluating routes. While you do not | ||
// pay this fee since it is your channel, you might want to consider | ||
// it in order to preserve valuale liquidity. |
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: typo "valuale" -> "valuable"
AprioriWeight: cfg.AprioriWeight, | ||
MinRouteProbability: cfg.MinRouteProbability, | ||
LocalOpportunityCost: cfg.LocalOpportunityCost, | ||
AttemptCost: cfg.AttemptCost, |
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 did formatting break here?
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'm not sure, the formatting doesn't seem to work on my machine currently
@@ -660,7 +669,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, | |||
// | |||
// Source node has no predecessor to pay a fee. Therefore set | |||
// fee to zero, because it should not be included in the fee | |||
// limit check and edge weight. | |||
// limit check and edge weight. |
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: extra space
// LocalOpportunityCost is true, then we account for the | ||
// fee on this channel. | ||
var opportunityCostFee lnwire.MilliSatoshi | ||
if cfg.LocalOpportunityCost && fromVertex == source { |
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.
instead of adding a new block of code you could merge this logic with line 679 like this
if fromVertex != source && cfg.LocalOpportunityCost {
fee = edge.policy.ComputeFee(amountToSend)
timeLockDelta = edge.policy.TimeLockDelta
}
not mandatory but imo it's cleaner and the fee is set only once there
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 was looking at doing something like that, but couple issues:
- i dont think we want to edit
fee
because that is used to calculatetotalFee
on line 700 which might affect the actual amount sent, which is not what we want (because we don't actually pay this newopportunityCostFee
) - we don't want to add the timeLockDelta of this edge to our total timelock calculation for a similar reason
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.
gotcha
@@ -970,6 +973,94 @@ func runFindLowestFeePath(t *testing.T, useCache bool) { | |||
} | |||
} | |||
|
|||
func runFindPathWithOpportunityCost(t *testing.T, useCache bool) { |
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: add a short godoc describing what your test checks
@dannydeezy, remember to re-request review from reviewers when ready |
Closing due to inactivity |
2 similar comments
Closing due to inactivity |
Closing due to inactivity |
See: #7360