Skip to content

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

Conversation

dannydeezy
Copy link

See: #7360

@dannydeezy dannydeezy force-pushed the dannydeezy/opportunity-cost-of-local-channels-pathfinding branch from a690a02 to 6795bd4 Compare January 25, 2023 18:37
@dannydeezy
Copy link
Author

dannydeezy commented Jan 25, 2023

  • todo: write/update tests

@dannydeezy dannydeezy force-pushed the dannydeezy/opportunity-cost-of-local-channels-pathfinding branch from 6795bd4 to 5cd8016 Compare January 26, 2023 23:14
@dannydeezy dannydeezy changed the title [WIP] Consider opportunity cost of local channel fees in pathfinding Consider opportunity cost of local channel fees in pathfinding Jan 26, 2023
@dannydeezy
Copy link
Author

  • todo: Lint/formatting. maybe somebody can do this for me, make fmt and make lint aren't working for me...

Copy link
Collaborator

@GeorgeTsagk GeorgeTsagk left a 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.
Copy link
Collaborator

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,
Copy link
Collaborator

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?

Copy link
Author

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.
Copy link
Collaborator

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 {
Copy link
Collaborator

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

Copy link
Author

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 calculate totalFee on line 700 which might affect the actual amount sent, which is not what we want (because we don't actually pay this new opportunityCostFee)
  • we don't want to add the timeLockDelta of this edge to our total timelock calculation for a similar reason

Copy link
Collaborator

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) {
Copy link
Collaborator

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

@lightninglabs-deploy
Copy link

@dannydeezy, remember to re-request review from reviewers when ready

@lightninglabs-deploy
Copy link

Closing due to inactivity

2 similar comments
@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@ellemouton ellemouton closed this Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature]: add option for pathfinding to consider opportunity cost of using my channels' liquidity
4 participants