Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

RouteBoost: Adding 'r=' fields to BOLT 11 invoices to flag capacity

15 messages, Sep 20 to Oct 10, 2018. Started by Rusty Russell.

Rusty Russell (5), Johan Torås Halseth (3), Olaoluwa Osuntokun (2), Pierre (2), Christian Decker, Matt Corallo, ZmnSCPxj

Permalink First message in the Wayback Machine

Rusty Russell permalink original

Hi all,

        I'm considering a change to c-lightning, where `invoice` would
automatically append an 'r' field for a channel which has sufficient
*incoming* capacity for the amount (using a weighted probability across
our peers).
         This isn't quite what 'r' was for, but it would be a useful
hint for payment routing and also potentially for establishing an
initial channel.  This is an issue for the Blockstream Store which
deliberately doesn't advertize an address any more to avoid
centralization.

Thoughts welcome! Rusty.

Johan Torås Halseth in reply to Rusty Russell permalink original

Any reason not to include _all_ (up to a limit) incoming channels with sufficient capacity?

Cheers, Johan

On Thu, Sep 20, 2018 at 4:12 AM Rusty Russell <rusty at blockstream.com> wrote:

Quoted text (20 lines)
> Hi all,
>
>         I'm considering a change to c-lightning, where `invoice` would
> automatically append an 'r' field for a channel which has sufficient
> *incoming* capacity for the amount (using a weighted probability across
> our peers).
>
>          This isn't quite what 'r' was for, but it would be a useful
> hint for payment routing and also potentially for establishing an
> initial channel.  This is an issue for the Blockstream Store which
> deliberately doesn't advertize an address any more to avoid
> centralization.
>
> Thoughts welcome!
> Rusty.
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Christian Decker in reply to Johan Torås Halseth permalink original

That might not be so desirable, since it leaks the current channel capacity to the user. Depending on how fine grained the amount in the invoice is and how the user can control it, he could do a binary search over capacities and very reliably tell how much capacity you have and track it over time. That is still the case for a single channel, but if you always chose the same channel it reduces how much info is leaked.

Cheers, Christian

Johan Torås Halseth <johanth at gmail.com> writes:

Quoted text (32 lines)
> Any reason not to include _all_ (up to a limit) incoming channels with
> sufficient capacity?
>
> Cheers,
> Johan
>
> On Thu, Sep 20, 2018 at 4:12 AM Rusty Russell <rusty at blockstream.com> wrote:
>
>> Hi all,
>>
>>         I'm considering a change to c-lightning, where `invoice` would
>> automatically append an 'r' field for a channel which has sufficient
>> *incoming* capacity for the amount (using a weighted probability across
>> our peers).
>>
>>          This isn't quite what 'r' was for, but it would be a useful
>> hint for payment routing and also potentially for establishing an
>> initial channel.  This is an issue for the Blockstream Store which
>> deliberately doesn't advertize an address any more to avoid
>> centralization.
>>
>> Thoughts welcome!
>> Rusty.
>> _______________________________________________
>> Lightning-dev mailing list
>> Lightning-dev at lists.linuxfoundation.org
>> https://www.learnbitcoin.com/archive/lists/lightning-dev
>>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Johan Torås Halseth in reply to Christian Decker permalink original

I was thinking you could just make many requests to get the same information, but if you always choose the same channel as long as its capacity meets the requirement, then not much is learnt :)

On Thu, Sep 20, 2018 at 9:26 AM Christian Decker <decker.christian at gmail.com> wrote:

Quoted text (45 lines)
> That might not be so desirable, since it leaks the current channel
> capacity to the user. Depending on how fine grained the amount in the
> invoice is and how the user can control it, he could do a binary search
> over capacities and very reliably tell how much capacity you have and
> track it over time. That is still the case for a single channel, but if
> you always chose the same channel it reduces how much info is leaked.
>
> Cheers,
> Christian
>
> Johan Torås Halseth <johanth at gmail.com> writes:
> > Any reason not to include _all_ (up to a limit) incoming channels with
> > sufficient capacity?
> >
> > Cheers,
> > Johan
> >
> > On Thu, Sep 20, 2018 at 4:12 AM Rusty Russell <rusty at blockstream.com>
> wrote:
> >
> >> Hi all,
> >>
> >>         I'm considering a change to c-lightning, where `invoice` would
> >> automatically append an 'r' field for a channel which has sufficient
> >> *incoming* capacity for the amount (using a weighted probability across
> >> our peers).
> >>
> >>          This isn't quite what 'r' was for, but it would be a useful
> >> hint for payment routing and also potentially for establishing an
> >> initial channel.  This is an issue for the Blockstream Store which
> >> deliberately doesn't advertize an address any more to avoid
> >> centralization.
> >>
> >> Thoughts welcome!
> >> Rusty.
> >> _______________________________________________
> >> Lightning-dev mailing list
> >> Lightning-dev at lists.linuxfoundation.org
> >> https://www.learnbitcoin.com/archive/lists/lightning-dev
> >>
> > _______________________________________________
> > Lightning-dev mailing list
> > Lightning-dev at lists.linuxfoundation.org
> > https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Olaoluwa Osuntokun in reply to Johan Torås Halseth permalink original
Quoted text (3 lines)
> That might not be so desirable, since it leaks the current channel
> capacity to the user

>From my PoV, the only way a node can protect the _instantaneous_ available

bandwidth in their channel is to randomly reject packets, even if they have the bandwidth to actually accept and forward them.

Observe that if a "prober" learns that you've _accepted_ a packet, then they know you have at least that amount as available bandwidth. As a result, I can simply send varying sat packet sizes over to you, either with the wrong timelock, or an unknown payment hash. Since we don't yet have the "unadd" feature in the protocol, you _must_ accept the HTLC before you can cancel it. This is mitigated a bit by the max_htlc value in the channel update (basically our version of an MTU), but I can still just send _multiple_ HTLC's rather than one big one to attempt to ascertain your available bandwidth.

-- Laolu

On Thu, Sep 20, 2018 at 1:31 AM Johan Torås Halseth <johanth at gmail.com> wrote:

Quoted text (59 lines)
> I was thinking you could just make many requests to get the same
> information, but if you always choose the same channel as long as its
> capacity meets the requirement, then not much is learnt :)
>
>
>
> On Thu, Sep 20, 2018 at 9:26 AM Christian Decker <
> decker.christian at gmail.com> wrote:
>
>> That might not be so desirable, since it leaks the current channel
>> capacity to the user. Depending on how fine grained the amount in the
>> invoice is and how the user can control it, he could do a binary search
>> over capacities and very reliably tell how much capacity you have and
>> track it over time. That is still the case for a single channel, but if
>> you always chose the same channel it reduces how much info is leaked.
>>
>> Cheers,
>> Christian
>>
>> Johan Torås Halseth <johanth at gmail.com> writes:
>> > Any reason not to include _all_ (up to a limit) incoming channels with
>> > sufficient capacity?
>> >
>> > Cheers,
>> > Johan
>> >
>> > On Thu, Sep 20, 2018 at 4:12 AM Rusty Russell <rusty at blockstream.com>
>> wrote:
>> >
>> >> Hi all,
>> >>
>> >>         I'm considering a change to c-lightning, where `invoice` would
>> >> automatically append an 'r' field for a channel which has sufficient
>> >> *incoming* capacity for the amount (using a weighted probability across
>> >> our peers).
>> >>
>> >>          This isn't quite what 'r' was for, but it would be a useful
>> >> hint for payment routing and also potentially for establishing an
>> >> initial channel.  This is an issue for the Blockstream Store which
>> >> deliberately doesn't advertize an address any more to avoid
>> >> centralization.
>> >>
>> >> Thoughts welcome!
>> >> Rusty.
>> >> _______________________________________________
>> >> Lightning-dev mailing list
>> >> Lightning-dev at lists.linuxfoundation.org
>> >> https://www.learnbitcoin.com/archive/lists/lightning-dev
>> >>
>> > _______________________________________________
>> > Lightning-dev mailing list
>> > Lightning-dev at lists.linuxfoundation.org
>> > https://www.learnbitcoin.com/archive/lists/lightning-dev
>>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Rusty Russell in reply to Olaoluwa Osuntokun permalink original

Olaoluwa Osuntokun <laolu32 at gmail.com> writes:

Quoted text (11 lines)
>> That might not be so desirable, since it leaks the current channel
>> capacity to the user
>
>>From my PoV, the only way a node can protect the _instantaneous_ available
> bandwidth in their channel is to randomly reject packets, even if they have
> the bandwidth to actually accept and forward them.
>
> Observe that if a "prober" learns that you've _accepted_  a packet, then
> they know you have at least that amount as available bandwidth. As a result,
> I can simply send varying sat packet sizes over to you, either with the
> wrong timelock, or an unknown payment hash.

Yes. You have to have a false capacity floor, which must vary periodically, to protect against this kind of probing (randomly failing attempts as you get close to zero capaicty is also subject to probing, AFAICT).

Quoted text (6 lines)
> Since we don't yet have the
> "unadd" feature in the protocol, you _must_ accept the HTLC before you can
> cancel it. This is mitigated a bit by the max_htlc value in the channel
> update (basically our version of an MTU), but I can still just send
> _multiple_ HTLC's rather than one big one to attempt to ascertain your
> available bandwidth.

This is orothogonal. There's no point probing your own channel, you're presumably probing someone else's.

Cheers, Rusty.

Rusty Russell in reply to Rusty Russell permalink original
This is now implemented (server side) in c-lightning/master:
        https://github.com/ElementsProject/lightning/pull/1982

(Note that c-lightning doesn't yet *use* the r= information: implementations should start doing that now though!)

You can test against both my mainnet and testnet nodes:

mainnet: id: 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605 alias: BLUEIRON-v0.6.1rc2-81-g3ce53ab addresses: 128.199.202.168, 2400:6180:0:d0::5cd2:a001, vww5i3z3fvfkxylz.onion

testnet: id: 031a3478d481b92e3c28810228252898c5f0d82fc4d07f5210c4f34d4aba56b769 alias: SLICKERMASTER- addresses: 165.227.30.200, 2604:a880:2:d0::2065:5001

You can autogenerate an invoice for testnet with:
        http://165.227.30.200:8000/cgi-bin/payreq.sh

If there's insufficient incoming capacity, this *won't* produce an 'r' hint, but will issue a warning.

Cheers, Rusty.

Rusty Russell <rusty at blockstream.com> writes:

Quoted text (15 lines)
> Hi all,
>
>         I'm considering a change to c-lightning, where `invoice` would
> automatically append an 'r' field for a channel which has sufficient
> *incoming* capacity for the amount (using a weighted probability across
> our peers).
>
>          This isn't quite what 'r' was for, but it would be a useful
> hint for payment routing and also potentially for establishing an
> initial channel.  This is an issue for the Blockstream Store which
> deliberately doesn't advertize an address any more to avoid
> centralization.
>
> Thoughts welcome!
> Rusty.
Olaoluwa Osuntokun in reply to Rusty Russell permalink original
Quoted text (2 lines)
> This is orothogonal.  There's no point probing your own channel, you're
> presumably probing someone else's.

In my scenario, you're receiving a new HTLC, from some remote party unbeknownst to you. I was replying to cdecker's reply to johan that one wouldn't always add this new type of routing hint for all channels since it leaks available bandwidth information. Without something like an "unadd" you can't do anything against an individual attempting to prob you other than drop packets (drop as in don't even add to your commit, resulting in an HTLC timeout), as if you cancel back, then they know that you had enough bandwidth to _accept_ the HTLC in the first place.

-- Laolu

On Wed, Sep 26, 2018 at 5:54 PM Rusty Russell <rusty at blockstream.com> wrote:

Quoted text (35 lines)
> Olaoluwa Osuntokun <laolu32 at gmail.com> writes:
> >> That might not be so desirable, since it leaks the current channel
> >> capacity to the user
> >
> >>From my PoV, the only way a node can protect the _instantaneous_
> available
> > bandwidth in their channel is to randomly reject packets, even if they
> have
> > the bandwidth to actually accept and forward them.
> >
> > Observe that if a "prober" learns that you've _accepted_  a packet, then
> > they know you have at least that amount as available bandwidth. As a
> result,
> > I can simply send varying sat packet sizes over to you, either with the
> > wrong timelock, or an unknown payment hash.
>
> Yes.  You have to have a false capacity floor, which must vary
> periodically, to protect against this kind of probing (randomly failing
> attempts as you get close to zero capaicty is also subject to probing,
> AFAICT).
>
> > Since we don't yet have the
> > "unadd" feature in the protocol, you _must_ accept the HTLC before you
> can
> > cancel it. This is mitigated a bit by the max_htlc value in the channel
> > update (basically our version of an MTU), but I can still just send
> > _multiple_ HTLC's rather than one big one to attempt to ascertain your
> > available bandwidth.
>
> This is orothogonal.  There's no point probing your own channel, you're
> presumably probing someone else's.
>
> Cheers,
> Rusty.
>
Pierre in reply to Rusty Russell permalink original

Ha! I actually came up with the idea two months ago (but you beat me to it on the implementation so we're even :-)

https://github.com/ACINQ/eclair-wallet/issues/101#issuecomment-408619207

Le jeu. 20 sept. 2018 à 04:12, Rusty Russell <rusty at blockstream.com> a écrit :

Quoted text (20 lines)
>
> Hi all,
>
>         I'm considering a change to c-lightning, where `invoice` would
> automatically append an 'r' field for a channel which has sufficient
> *incoming* capacity for the amount (using a weighted probability across
> our peers).
>
>          This isn't quite what 'r' was for, but it would be a useful
> hint for payment routing and also potentially for establishing an
> initial channel.  This is an issue for the Blockstream Store which
> deliberately doesn't advertize an address any more to avoid
> centralization.
>
> Thoughts welcome!
> Rusty.
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Matt Corallo in reply to Rusty Russell permalink original

Resending due to ML bugs....

On a related note, it would be nice to get some clarity on appropriate usage of the r= field here. The way I had implemented it initially was that if an invoice had an r= field any publicly-discovered last-hop routes would be ignored as the r= data is most likely more up-to-date than any public route rumor information. However, if it's only used as a hint and only one or two out of potentially many channels are included in it, that may make little sense.

Not really sure what the appropriate guidance should be, probably something like SHOULD prefer to use invoice-r=-provided-hints over publicly-discovered routes however MAY use other last-hops in case a substantially better route is known?

Matt

On 09/19/18 22:10, Rusty Russell wrote:

Quoted text (20 lines)
> Hi all,
>
>         I'm considering a change to c-lightning, where `invoice` would
> automatically append an 'r' field for a channel which has sufficient
> *incoming* capacity for the amount (using a weighted probability across
> our peers).
>
>          This isn't quite what 'r' was for, but it would be a useful
> hint for payment routing and also potentially for establishing an
> initial channel.  This is an issue for the Blockstream Store which
> deliberately doesn't advertize an address any more to avoid
> centralization.
>
> Thoughts welcome!
> Rusty.
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Rusty Russell in reply to Matt Corallo permalink original

Matt Corallo <lf-lists at mattcorallo.com> writes:

Quoted text (7 lines)
> On a related note, it would be nice to get some clarity on appropriate
> usage of the r= field here.
> The way I had implemented it initially was that if an invoice had an r=
> field any publicly-discovered last-hop routes would be ignored as the r=
> data is most likely more up-to-date than any public route rumor information.

> However, if it's only used as a hint and only one or two out of
> potentially many channels are included in it, that may make little sense.

There were originally two proposed uses of r=:

1. For payments via unannounced channels.
2. For routing hints for nodes which don't have a complete topology.
Quoted text (4 lines)
> Not really sure what the appropriate guidance should be, probably
> something like SHOULD prefer to use invoice-r=-provided-hints over
> publicly-discovered routes however MAY use other last-hops in case a
> substantially better route is known?

Note that r can provide zero-or-more full routes, not just a single hop as is done here. But there's no reason to believe that the invoicer has more knowledge about all but the last hop.

So, I'd recommend that the payer SHOULD prefer to use the final hops specified in `r` fields over other equivalent routes it knows.

(Note the weasel word "equivalent" here: you might bias against these due to fees, timeouts, or even privacy concerns. Also note that I haven't implemented this yet!).

Cheers, Rusty.

ZmnSCPxj in reply to Matt Corallo permalink original

Good morning Matt,

In my implementation that might get into c-lightning (i.e. my pull request, which I should probably update some time before universe heat death) the r= fields are preferred, but if unable to find routes to the nodes indicated in the r= fields, we always fall back to our known node map before failing completely.

Basically, we retry each r= field until all routes to the node indicated have failed (no more viable routes), then move to the next r= field (if exists), or if no more r= fields, try finding the node itself directly in the node map.

Regards, ZmnSCPxj

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Monday, October 8, 2018 12:38 PM, Matt Corallo <lf-lists at mattcorallo.com> wrote:

Quoted text (45 lines)
> Resending due to ML bugs....
>
> On a related note, it would be nice to get some clarity on appropriate
> usage of the r= field here.
> The way I had implemented it initially was that if an invoice had an r=
> field any publicly-discovered last-hop routes would be ignored as the r=
> data is most likely more up-to-date than any public route rumor information.
> However, if it's only used as a hint and only one or two out of
> potentially many channels are included in it, that may make little sense.
>
> Not really sure what the appropriate guidance should be, probably
> something like SHOULD prefer to use invoice-r=-provided-hints over
> publicly-discovered routes however MAY use other last-hops in case a
> substantially better route is known?
>
> Matt
>
> On 09/19/18 22:10, Rusty Russell wrote:
>
> > Hi all,
> >
> >         I'm considering a change to c-lightning, where `invoice` would
> >
> >
> > automatically append an 'r' field for a channel which has sufficient
> > incoming capacity for the amount (using a weighted probability across
> > our peers).
> >
> >          This isn't quite what 'r' was for, but it would be a useful
> >
> >
> > hint for payment routing and also potentially for establishing an
> > initial channel. This is an issue for the Blockstream Store which
> > deliberately doesn't advertize an address any more to avoid
> > centralization.
> > Thoughts welcome!
> > Rusty.
> >
> > Lightning-dev mailing list
> > Lightning-dev at lists.linuxfoundation.org
> > https://www.learnbitcoin.com/archive/lists/lightning-dev
>
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Pierre in reply to Rusty Russell permalink original
Quoted text (1 line)
> But there's no reason to believe that the invoicer has more knowledge about all but the last hop.

I disagree: there is a good chance that the receiver is a 24/7 running merchant/website, with a full up-to-date view of the network, whereas the payer is most likely a mobile wallet with less accurate/partial/out of date information.

At least this is what we are seeing on the current mainnet. Routing table sync is hard on mobile clients, and I think that it makes sense that receivers "help" senders, after all incentives are aligned.

Cheers,

Pierre

Rusty Russell in reply to Pierre permalink original

Pierre <pm+lists at acinq.fr> writes:

Quoted text (10 lines)
>> But there's no reason to believe that the invoicer has more knowledge about all but the last hop.
>
> I disagree: there is a good chance that the receiver is a 24/7 running
> merchant/website, with a full up-to-date view of the network, whereas
> the payer is most likely a mobile wallet with less
> accurate/partial/out of date information.
>
> At least this is what we are seeing on the current mainnet. Routing
> table sync is hard on mobile clients, and I think that it makes sense
> that receivers "help" senders, after all incentives are aligned.

Good qualification; I agree. Certainly if the payer knows its information is less reliable it should prefer the provided route.

Cheers, Rusty.

Johan Torås Halseth in reply to Rusty Russell permalink original

I agree the r-fields are useful to populate for public channels in many situations, but care must be taken to not _always_ try them first without accounting for potentially high fees on those channels.

- Johan On Wed, Oct 10, 2018 at 5:46 AM Rusty Russell <rusty at blockstream.com> wrote:

Quoted text (23 lines)
> Pierre <pm+lists at acinq.fr> writes:
> >> But there's no reason to believe that the invoicer has more knowledge
> about all but the last hop.
> >
> > I disagree: there is a good chance that the receiver is a 24/7 running
> > merchant/website, with a full up-to-date view of the network, whereas
> > the payer is most likely a mobile wallet with less
> > accurate/partial/out of date information.
> >
> > At least this is what we are seeing on the current mainnet. Routing
> > table sync is hard on mobile clients, and I think that it makes sense
> > that receivers "help" senders, after all incentives are aligned.
>
> Good qualification; I agree.  Certainly if the payer knows its
> information is less reliable it should prefer the provided route.
>
> Cheers,
> Rusty.
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>