Skip to content

Prefer direct routes when paying - alternate solution - #2168

Closed
ZmnSCPxj wants to merge 2 commits into
ElementsProject:masterfrom
ZmnSCPxj:pay-direct-alt
Closed

Prefer direct routes when paying - alternate solution#2168
ZmnSCPxj wants to merge 2 commits into
ElementsProject:masterfrom
ZmnSCPxj:pay-direct-alt

Conversation

@ZmnSCPxj

Copy link
Copy Markdown
Contributor

Fixes: #2119

Closes: #2144

Alternate solution that tweaks connection_fee so it gives 0 fees for direct channels.

@cdecker cdecker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much nicer than the other PR, but wouldn't just skipping the last fee computation have the same effect?

Comment thread gossipd/routing.c Outdated
* @param from - the node that is the ultimate source of the
* payment.
* @param chan - the channel to consider.
* @param idx - which half of the channel to consider. 0 or 1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We commonly call this direction.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data structure is called half_chan and the field is half[2], but I suppose direction (half_chan) would be okay.

Comment thread gossipd/routing.c
hops[i].amount = total_amount;
hops[i].delay = total_delay;
total_amount += connection_fee(c, total_amount);
total_amount += connection_fee(sourcenode, route[i], idx, total_amount);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should simply skip this addition if i==0 since that'd be the hop that we are in control over anyway. That'd avoid having to thread an additional argument in and do the check in another function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connection_fee is used in both this and bfg_one_edge.
We could argue for moving the check to bfg_one_edge, but properly, the source node charges no fee to itself for forwarding, so I thought, more appropriate at connection_fee.

@ZmnSCPxj

Copy link
Copy Markdown
Contributor Author

wouldn't just skipping the last fee computation have the same effect?

No, as that is done, once a route has been chosen.
We need to change, the way of choosing a route, so we need to change either connection_fee or bfg_one_edge.

…rging 0 fees.

Aside from being accurate, this strongly biases us towards direct channels.
@rustyrussell

Copy link
Copy Markdown
Contributor

In the initial implementation I decided to keep the weighting because I figured it reflected our own desires for usage (e.g. we dropped fee on one channel because we wanted more traffic there).

What I don't understand is why this would change anything? I suppose now the cost comparison is X vs 0, whereas it was 2X vs X?

@ZmnSCPxj

Copy link
Copy Markdown
Contributor Author

I suppose now the cost comparison is X vs 0, whereas it was 2X vs X?

Yes. Further, route randomization fuzz is a random multiplier, so 0 removes the effect of random fuzz.

@cdecker

cdecker commented Dec 13, 2018

Copy link
Copy Markdown
Member

Yes. Further, route randomization fuzz is a random multiplier, so 0 removes the effect of random fuzz.

Interesting. I forgot to ask about randomization, but a 0 here seems to solve this issue :-)

Any major objections @rustyrussell ?

@rustyrussell

Copy link
Copy Markdown
Contributor

I think we're addressing the symptoms; this is just the most obvious bad decision we make with routing.

By default we use riskfactor of 1, and fuzz of 5% (75% for getroute, though I have a patch pending for that). That means a 6-block delay is calculated to cost us about 0.01%, which is lost in the noise of typical fees on the network. In effect, if someone is offering a free route, we'll not bias against it.

Increasing the default riskfactor to a more-realistic 10 will change this to be comparable with the 0.1% people are charging in practice.

@NicolasDorier

Copy link
Copy Markdown
Contributor

I wish this was merged. I created direct channel in the expectation of having higher latency for payments to a specific party. I was bit sad to see it was not working that way. :(

@NicolasDorier

Copy link
Copy Markdown
Contributor

would be nice to get in 0.6.3

rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Jan 30, 2019
@ZmnSCPxj pointed out that we sometimes select indirect routes when a direct
route is available.  This is because the riskfactor is so small that it gets
overwhelmed in practice by our fuzzing of fees.

There were several proposed fixes, but it does imply in general that a
riskfactor of 1 is too low for the network.  This patch changes the default
and updates the recommendation in the getroute man page.

Closes: ElementsProject#2168
Closes: ElementsProject#2144
Fixes: ElementsProject#2119
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@cdecker cdecker closed this in #2307 Feb 6, 2019
@ZmnSCPxj
ZmnSCPxj deleted the pay-direct-alt branch May 20, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants