Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Ionization Protocol: Flood Routing

16 messages, Sep 19 to 30, 2015. Started by Amos Bairn.

Rusty Russell (7), Anthony Towns (7), Amos Bairn (2)

Permalink First message in the Wayback Machine

Amos Bairn permalink original

Here is a scheme I thought of for flood based route finding. If it can be pulled off it would allow efficient route finding while keeping the shape of the network hidden, as well as giving onion like anonymity.

After writing it up a realized that it has a trivial denial of service attack, that could render it a non-starter.

I'm throwing it out there anyway, because this could have significant potential if the DoS problem can be solved.

https://github.com/Eylrid/ionization/blob/master/ionization.mediawiki

Rusty Russell in reply to Amos Bairn permalink original

Hi Amos,

   I'm delighted that someone else is thinking about routing!

I like the information hiding features, but I don't think this will scale if everyone floods the network before sending a transaction.

I do, however, have an alternate scheme which is something of a middleman, which I'd appreciate your feedback on.

We regularly choose a dozen "beacon" nodes at random (using proximity to the SHA of latest block hash or something). Everyone propagates the cheapest route to & from those nodes (which is pretty efficient, similar to your scheme).

To receive a payment, B picks a few beacon nodes at random and sends those routes (beacons -> B) to A. Presumably A knows its route to all the beacon nodes and thus can choose the best.

There are some twisty details here:

1) How many beacon nodes?
   12, and increase on a log scale with network size.  That size can
   be derived from previous beacons.
2) How long between selection and a beacon becoming active?
   10 blocks.  That gives time for others to connect to beacon node.
3) How long before a beacon node is invalid?
   No idea.  Let's keep a day's worth for the moment?
4) How to avoid fake beacons?
   Require a signature attached to an unspent bitcoin TX from before
   beacon selection?  That TXID is actually what competes to be close
   to the beacon selector.
5) How to update beacon routing?
   Particularly for fee changes, this is important.  Best effort,
   with ratelimiting.  I hope eventually we'll have reasonable traffic
   models so a node can say "I'm going to ramp up/down my fees for
   this long at this rate" and have a reasonable chance that it's true.
Cheers,
Rusty.
PS.  For the immediate term, we'll use a global comms mechanism like
     IRC, but that's just a prototype hack.

Amos Bairn <eylrid at gmail.com> writes:

Quoted text (15 lines)
> Here is a scheme I thought of for flood based route finding. If it can be
> pulled off it would allow efficient route finding while keeping the shape
> of the network hidden, as well as giving onion like anonymity.
>
> After writing it up a realized that it has a trivial denial of service
> attack, that could render it a non-starter.
>
> I'm throwing it out there anyway, because this could have significant
> potential if the DoS problem can be solved.
>
> https://github.com/Eylrid/ionization/blob/master/ionization.mediawiki
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Anthony Towns in reply to Amos Bairn permalink original

On Sat, Sep 19, 2015 at 01:13:03PM -0700, Amos Bairn wrote:

Quoted text (1 line)
> https://github.com/Eylrid/ionization/blob/master/ionization.mediawiki

Even assuming nodes are honest, afaics you could discover the shape of the network simply by doing lots of probes with k1/h1, but never actually send the k2/h2 transactions through ("oh, it's always too expensive").

Cheers, aj

Anthony Towns in reply to Rusty Russell permalink original

On Mon, Sep 21, 2015 at 11:46:13AM +0930, Rusty Russell wrote:

Quoted text (4 lines)
> We regularly choose a dozen "beacon" nodes at random (using proximity to
> the SHA of latest block hash or something).  Everyone propagates the
> cheapest route to & from those nodes (which is pretty efficient, similar
> to your scheme).

I think what you're implicitly assuming here is:

 a) global p2p network of lightning nodes; at a minimum each node has
    a connection to every node it has a channel open with

b) consensus protocol for choosing an ordering of potential beacons

 c) potential beacons have to have committed to a beacon id prior to
    ordering being chosen (with spam/flooding protection)
 d) gossip protocol to announce potential beacons and compare against
    ordering, keeping the top few in memory.

e) sharing routes to beacons with direct neighbours

 f) distributed hash to store/lookup route recommendations, keyed by
    beacon/endpoint

g) distributed hash to lookup fees for hops keyed by hop ends

I think (a) is trivial; and you already called out (b).

For (c), not having a commitment means that people could generate a new node id that does well in the ordering algorithm after the fact; if it's SHA comparisons, that means miners would likely monopolise being a beacon.

Quoted text (4 lines)
> 4) How to avoid fake beacons?
>    Require a signature attached to an unspent bitcoin TX from before
>    beacon selection?  That TXID is actually what competes to be close
>    to the beacon selector.

This might as well be the (an) anchor transaction. It's already in the blockchain, it's already associated with a channel. You couldn't just use the txid directly, because that wouldn't differentiate between endpoints though. This would give an advantage to nodes with lots of channels open; not sure whether that's desirable? Probably it is?

For (d), once you've got the ordering, nodes tell each other about their 12 favourite beacons, and if they hear about better ones, they pass those on too. That needs to be global knowledge, but it doesn't matter too much if we have slightly different sets of 12 beacons at any point. 12 beacon ids is a fine amount of information to pass around globally, too.

For (e), I don't think you want to gossip globally about routes -- that's too much information to pass around if it's not necessary; but you still have to share your routes to beacons with your neighbours in order to figure anything out. Nodes announcing their best routes to their neighbours is basically just Dijkstra's algorithm in parallel I think.

But just knowing your neighbours' routes isn't enough; you need to be able to lookup a route for anyone, and that (by definition I think) means you need (f) a DHT of routes-to-beacons. Note that looking up a route has privacy implications, in that it implies you're probably going to make a payment along that route!

Quoted text (3 lines)
> To receive a payment, B picks a few beacon nodes at random and sends
> those routes (beacons -> B) to A.  Presumably A knows its route to all
> the beacon nodes and thus can choose the best.

A trivial DHT would be to have each node store its routes locally, and just make a TCP/IP connection to the node directly to ask for its routes. That seems like it'd be pretty bad for privacy though. I'm a fan of being able to route to/through nodes you can't reach via IP, and this would prevent that too.

Finally for (g), I don't think you want to store fees in the routes directly, since updating fees would require updating an unknown number of routes; but fees have to be queryable, so that's a separate DHT. This one doesn't need to be updated when new beacons are elected though. This DHT would want to be fairly high performance, because you're doing 2*B*L lookups everytime you want to find a route, and it has to accept and propogate updates fairly quickly if fees change.

Quoted text (4 lines)
> There are some twisty details here:
> 1) How many beacon nodes?
>    12, and increase on a log scale with network size.  That size can
>    be derived from previous beacons.

I think it's also something you could set per-node, like the minrelaytxfee.

Quoted text (2 lines)
> 2) How long between selection and a beacon becoming active?
>    10 blocks.  That gives time for others to connect to beacon node.

Beacons can be "active" as soon as you can route through them, and that's just a DHT lookup to determine, and then a matter of comparing fees to what the old beacons give you. So I think no artificial delay is needed, and the real question is just when you expire your routes to/from the old beacons?

Quoted text (2 lines)
> 3) How long before a beacon node is invalid?
>    No idea.  Let's keep a day's worth for the moment?

Sounds fine; also mostly a client side parameter. (Though if the routing DHT is non-trivial, old beacons should expire from there after some interval too to deal with nodes that disappear)

Quoted text (5 lines)
> 5) How to update beacon routing?
>    Particularly for fee changes, this is important.  Best effort,
>    with ratelimiting.  I hope eventually we'll have reasonable traffic
>    models so a node can say "I'm going to ramp up/down my fees for
>    this long at this rate" and have a reasonable chance that it's true.

I think this is reinventing DHTs, though maybe none of the existing ones work well enough for this use case?

I think rate limiting decreases in fees is always safe (it won't prevent any transactions going through, it will only prevent them being started).

(I'm not sure a programmed ramp-up/down of fees makes sense; though maybe it would be a good way to perform price discovery)

Quoted text (2 lines)
> PS.  For the immediate term, we'll use a global comms mechanism like
>      IRC, but that's just a prototype hack.

Hmm. Counterproposal: no beacons or routing DHT, just fees by gossip protocol (or IRC channel as prototype hack). Everyone has a complete (but possibly slightly out of date) database of node-node (but not node-wallet) channel fees, and changes are propogated by gossip. Back of the envelope maths:

  everyone uses lightning ==> 8B wallets (5B teens/adults, 3B businesses)
  every wallet has ~4 channels ==> 32B node-wallet channels
  100k wallet channels per node on average ==> 320k nodes
  16 channels to other nodes per node ==> 2.5M node-node channels
  (average path length between nodes ~= 4 hops)
  128b id per node, 32b fee per direction ==> ~100MB of graph data

An update rate of 10kB/s allows fees to update up to once every three hours on average; 100kB/s would be once every 20 minutes or so. Those numbers aren't /great/ but don't seem completely infeasible. Probably needs some signatures or similar to avoid DoS by spam which would slow things down by maybe a factor of two.

If you do know the entire graph, you don't need to give away any information about who you want to pay prior to sending the transaction. Knowing the graph is potentially interesting for commercial and academic reasons beyond wanting privacy. (Knowing the fees others charge helps you work out what fees you should charge; but just querying your neighbours' routes is probably sufficient to work that out too)

You can even do it so that only nodes (not wallets) need to know the full graph, I think. If you're running a wallet without the full graph, when finding a route, you:

 - get a list of most/all nodes (about 5MB; maybe you already have this,
   or can just rsync changes)
 - determine how oniony you want to be, picking n nodes, including your
   desired destination, and one or more of the nodes you have channels
   open with
 - ask for the shortest path between each pair of those nodes
 - build a cheap path out of that data

Even if n=2 (your node and their node), you only reveal you're paying one of 100k wallets; and with larger n, any particular node could just be being used for onion routing, so you're adding ~100k potential recipient wallets with each additional node. (Initially, it won't be "100k" per node so that doesn't work so well, but initially you could happily run a full node rather than a wallet anyway)

When asking for payment, you just indicate your id, and one or more nodes you have a channel open to. You probably have to indicate the final hop fee for each node as well, since that can't be looked up in the graph.

Cheers, aj

Rusty Russell in reply to Anthony Towns permalink original

Anthony Towns <aj at erisian.com.au> writes:

Quoted text (55 lines)
> On Mon, Sep 21, 2015 at 11:46:13AM +0930, Rusty Russell wrote:
>> We regularly choose a dozen "beacon" nodes at random (using proximity to
>> the SHA of latest block hash or something).  Everyone propagates the
>> cheapest route to & from those nodes (which is pretty efficient, similar
>> to your scheme).
>
> I think what you're implicitly assuming here is:
>
>  a) global p2p network of lightning nodes; at a minimum each node has
>     a connection to every node it has a channel open with
>
>  b) consensus protocol for choosing an ordering of potential beacons
>
>  c) potential beacons have to have committed to a beacon id prior to
>     ordering being chosen (with spam/flooding protection)
>
>  d) gossip protocol to announce potential beacons and compare against
>     ordering, keeping the top few in memory.
>
>  e) sharing routes to beacons with direct neighbours
>
>  f) distributed hash to store/lookup route recommendations, keyed by
>     beacon/endpoint
>
>  g) distributed hash to lookup fees for hops keyed by hop ends
>
>
> I think (a) is trivial; and you already called out (b).
>
> For (c), not having a commitment means that people could generate a new
> node id that does well in the ordering algorithm after the fact; if it's
> SHA comparisons, that means miners would likely monopolise being a beacon.
>
>> 4) How to avoid fake beacons?
>>    Require a signature attached to an unspent bitcoin TX from before
>>    beacon selection?  That TXID is actually what competes to be close
>>    to the beacon selector.
>
> This might as well be the (an) anchor transaction. It's already in the
> blockchain, it's already associated with a channel. You couldn't just
> use the txid directly, because that wouldn't differentiate between
> endpoints though. This would give an advantage to nodes with lots of
> channels open; not sure whether that's desirable? Probably it is?
>
> For (d), once you've got the ordering, nodes tell each other about their
> 12 favourite beacons, and if they hear about better ones, they pass those
> on too. That needs to be global knowledge, but it doesn't matter too much
> if we have slightly different sets of 12 beacons at any point.  12 beacon
> ids is a fine amount of information to pass around globally, too.
>
> For (e), I don't think you want to gossip globally about routes --
> that's too much information to pass around if it's not necessary; but
> you still have to share your routes to beacons with your neighbours in
> order to figure anything out. Nodes announcing their best routes to their
> neighbours is basically just Dijkstra's algorithm in parallel I think.

Indeed, it's trivial (and I've already implemented a simple simulator to do it). The initial spamminess can be mitigated by waiting before broadcasting depending on how likely you are a beacon.

Quoted text (5 lines)
> But just knowing your neighbours' routes isn't enough; you need to be
> able to lookup a route for anyone, and that (by definition I think)
> means you need (f) a DHT of routes-to-beacons. Note that looking up a
> route has privacy implications, in that it implies you're probably going
> to make a payment along that route!

That's why the recipient provides a set of routes from (some subset of) beacons to them. You know routes to all beacons, so pathfinding solved.

Quoted text (9 lines)
>> To receive a payment, B picks a few beacon nodes at random and sends
>> those routes (beacons -> B) to A.  Presumably A knows its route to all
>> the beacon nodes and thus can choose the best.
>
> A trivial DHT would be to have each node store its routes locally,
> and just make a TCP/IP connection to the node directly to ask for its
> routes. That seems like it'd be pretty bad for privacy though. I'm a
> fan of being able to route to/through nodes you can't reach via IP, and
> this would prevent that too.

Yes, that's a bad idea. And I'm not sure why you need this?

Quoted text (7 lines)
> Finally for (g), I don't think you want to store fees in the routes
> directly, since updating fees would require updating an unknown number
> of routes; but fees have to be queryable, so that's a separate DHT. This
> one doesn't need to be updated when new beacons are elected though. This
> DHT would want to be fairly high performance, because you're doing 2*B*L
> lookups everytime you want to find a route, and it has to accept and
> propogate updates fairly quickly if fees change.

Well, propagating fee updates for (say) 1200 routes isn't too bad, as long as they're not changing too fast.

Quoted text (7 lines)
>> There are some twisty details here:
>> 1) How many beacon nodes?
>>    12, and increase on a log scale with network size.  That size can
>>    be derived from previous beacons.
>
> I think it's also something you could set per-node, like the
> minrelaytxfee.

That doesn't make sense, since we need to agree on who is a beacon.

Quoted text (8 lines)
>> 2) How long between selection and a beacon becoming active?
>>    10 blocks.  That gives time for others to connect to beacon node.
>
> Beacons can be "active" as soon as you can route through them, and that's
> just a DHT lookup to determine, and then a matter of comparing fees to
> what the old beacons give you. So I think no artificial delay is needed,
> and the real question is just when you expire your routes to/from the
> old beacons?

No. Beacons will get saturated fast unless they have a chance to prepare. In particular, the network will want to establish channels with new beacons, and beacons may well want to bring offline funds online to handle the anticipated capacity.

Quoted text (15 lines)
>> 3) How long before a beacon node is invalid?
>>    No idea.  Let's keep a day's worth for the moment?
>
> Sounds fine; also mostly a client side parameter. (Though if the routing
> DHT is non-trivial, old beacons should expire from there after some
> interval too to deal with nodes that disappear)
>
>> 5) How to update beacon routing?
>>    Particularly for fee changes, this is important.  Best effort,
>>    with ratelimiting.  I hope eventually we'll have reasonable traffic
>>    models so a node can say "I'm going to ramp up/down my fees for
>>    this long at this rate" and have a reasonable chance that it's true.
>
> I think this is reinventing DHTs, though maybe none of the existing ones
> work well enough for this use case?

What's the fascination with DHTs?

Quoted text (18 lines)
> I think rate limiting decreases in fees is always safe (it won't prevent
> any transactions going through, it will only prevent them being started).
>
> (I'm not sure a programmed ramp-up/down of fees makes sense; though
> maybe it would be a good way to perform price discovery)
>
>> PS.  For the immediate term, we'll use a global comms mechanism like
>>      IRC, but that's just a prototype hack.
>
> Hmm. Counterproposal: no beacons or routing DHT, just fees by gossip
> protocol (or IRC channel as prototype hack). Everyone has a complete
> (but possibly slightly out of date) database of node-node (but not
> node-wallet) channel fees, and changes are propogated by gossip. Back
> of the envelope maths:
>
>   everyone uses lightning ==> 8B wallets (5B teens/adults, 3B businesses)
>   every wallet has ~4 channels ==> 32B node-wallet channels
>   100k wallet channels per node on average ==> 320k nodes

Um, so each wallet isn't a node? That's a very different architecture, which uses hosted wallets or something? I don't think that's very interesting.

Cheers, Rusty.

Amos Bairn in reply to Rusty Russell permalink original

The obvious problem with having the whole network use the same set of beacons at the same time is that those nodes will get slammed. A possible solution is to have each user pick their own set of beacons (at random), but make the beacon set large enough so that any two users are likely to share a few. That way the all of nodes would share the load roughly evenly.

The size needed should be something on the order of the square root of the number of nodes. Some math could be done to see what set size would be needed to have a given probability of two users having an intersection of at least a given size.

If you went with that you wouldn't have to worry about the extra mess of making sure everyone has consensus on the official beacon set.

On Sun, Sep 20, 2015 at 7:16 PM, Rusty Russell <rusty at rustcorp.com.au> wrote:

Quoted text (64 lines)
> Hi Amos,
>
>    I'm delighted that someone else is thinking about routing!
>
> I like the information hiding features, but I don't think this will
> scale if everyone floods the network before sending a transaction.
>
> I do, however, have an alternate scheme which is something of a
> middleman, which I'd appreciate your feedback on.
>
> We regularly choose a dozen "beacon" nodes at random (using proximity to
> the SHA of latest block hash or something).  Everyone propagates the
> cheapest route to & from those nodes (which is pretty efficient, similar
> to your scheme).
>
> To receive a payment, B picks a few beacon nodes at random and sends
> those routes (beacons -> B) to A.  Presumably A knows its route to all
> the beacon nodes and thus can choose the best.
>
> There are some twisty details here:
>
> 1) How many beacon nodes?
>    12, and increase on a log scale with network size.  That size can
>    be derived from previous beacons.
>
> 2) How long between selection and a beacon becoming active?
>    10 blocks.  That gives time for others to connect to beacon node.
>
> 3) How long before a beacon node is invalid?
>    No idea.  Let's keep a day's worth for the moment?
>
> 4) How to avoid fake beacons?
>    Require a signature attached to an unspent bitcoin TX from before
>    beacon selection?  That TXID is actually what competes to be close
>    to the beacon selector.
>
> 5) How to update beacon routing?
>    Particularly for fee changes, this is important.  Best effort,
>    with ratelimiting.  I hope eventually we'll have reasonable traffic
>    models so a node can say "I'm going to ramp up/down my fees for
>    this long at this rate" and have a reasonable chance that it's true.
>
> Cheers,
> Rusty.
> PS.  For the immediate term, we'll use a global comms mechanism like
>      IRC, but that's just a prototype hack.
>
> Amos Bairn <eylrid at gmail.com> writes:
> > Here is a scheme I thought of for flood based route finding. If it can be
> > pulled off it would allow efficient route finding while keeping the shape
> > of the network hidden, as well as giving onion like anonymity.
> >
> > After writing it up a realized that it has a trivial denial of service
> > attack, that could render it a non-starter.
> >
> > I'm throwing it out there anyway, because this could have significant
> > potential if the DoS problem can be solved.
> >
> > https://github.com/Eylrid/ionization/blob/master/ionization.mediawiki
> > _______________________________________________
> > Lightning-dev mailing list
> > Lightning-dev at lists.linuxfoundation.org
> > https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Anthony Towns in reply to Rusty Russell permalink original

On Wed, Sep 23, 2015 at 12:12:57PM +0930, Rusty Russell wrote:

Quoted text (17 lines)
> Anthony Towns <aj at erisian.com.au> writes:
> > On Mon, Sep 21, 2015 at 11:46:13AM +0930, Rusty Russell wrote:
> >> We regularly choose a dozen "beacon" nodes at random (using proximity to
> >> the SHA of latest block hash or something).  Everyone propagates the
> >> cheapest route to & from those nodes (which is pretty efficient, similar
> >> to your scheme).
> > I think what you're implicitly assuming here is:
> >  a) global p2p network of lightning nodes; at a minimum each node has
> >     a connection to every node it has a channel open with
> >  b) consensus protocol for choosing an ordering of potential beacons
> >  c) potential beacons have to have committed to a beacon id prior to
> >     ordering being chosen (with spam/flooding protection)
> >  d) gossip protocol to announce potential beacons and compare against
> >     ordering, keeping the top few in memory.
> >  e) sharing routes to beacons with direct neighbours

> >  f) distributed hash to store/lookup route recommendations, keyed by
> >     beacon/endpoint

So this one's incorrect. I think instead you're assuming:

 f) when asking for a payment to be made to you, you provide your
    lightning public key, and a set of low-cost paths from the current
    beacons to you. (ie, your "address" for payments includes full
    routing and fee info)
Quoted text (1 line)
> >  g) distributed hash to lookup fees for hops keyed by hop ends

When fees change, which path to a beacon is low cost will often change too, so this really doesn't do you any good.

Quoted text (3 lines)
> > Finally for (g), I don't think you want to store fees in the routes
> Well, propagating fee updates for (say) 1200 routes isn't too bad,
> as long as they're not changing too fast.

So forgetting the DHTs, then fee updates take effect via the dijkstra-routing-gossip protocol. I don't have any idea how well that would perform... If an average channel's fee updates U times per day, there are C channels, and N nodes, does that mean a background noise of O(log(N)*U*C) fee update traffic or something? (dividing by N to get the traffic an individual node sees)

It does mean that the "payment info" has to be provided by the payee "shortly" before the transaction; otherwise the route and fee information would be out of date and the payment becomes "likely" to fail due to closed channels or raised fees.

Quoted text (7 lines)
> >> There are some twisty details here:
> >> 1) How many beacon nodes?
> >>    12, and increase on a log scale with network size.  That size can
> >>    be derived from previous beacons.
> > I think it's also something you could set per-node, like the
> > minrelaytxfee.
> That doesn't make sense, since we need to agree on who is a beacon.

If you have the top 10 beacons and I have the top 14 beacons, we have the top 10 beacons in common. During the gossip phase, if either of us see someone in the top 10, we pass it along; I pass along a few more as well.

Quoted text (9 lines)
> >> 2) How long between selection and a beacon becoming active?
> >>    10 blocks.  That gives time for others to connect to beacon node.
> > Beacons can be "active" as soon as you can route through them, and that's
> > just a DHT lookup to determine, and then a matter of comparing fees to
> > what the old beacons give you. So I think no artificial delay is needed,
> > and the real question is just when you expire your routes to/from the
> > old beacons?
> No.  Beacons will get saturated fast unless they have a chance to
> prepare.

Sure. I was thinking you have to volunteer to be a beacon, ie something like:

  1) commit to node id (anchor transaction in blockchain)
  2) commit to ordering (abs difference of node id versus
     sha of latest blockchain block with (depth % 2016 == 0))
  3) volunteer to be a beacon (sign "imma beacon! depth $n anchor
     $txid")
  4) gossip (including your signed volunteer statement) and hope you're
     in the top 12

Any preparation (opening new channels etc happens between (2) and (3)), transactions happen immediately after (4).

If other nodes can "force" you to be a beacon, I think that causes problems anyway (maybe you just don't have the bandwidth to deal with a high transaction volume), so I think the "volunteering" step is needed.

Quoted text (3 lines)
> In particular, the network will want to establish channels
> with new beacons, and beacons may well want to bring offline funds
> online to handle the anticipated capacity.

So... doesn't this provide a /really/ juicy target for hackers? Either of the "let's steal funds" variety, or of the "let's find out as much info about every transaction as we can" type?

If you just have to hack 12 systems to observe/DoS 100% of lightning network transactions, that seems worrying to me. I think I'd want to avoid being a beacon in that case, just to avoid painting a target on my system.

I'm not sure if it's a realistic attack model, but if you can observe:

  Bob -> Alice: pay me $20 to R (routes to current beacons: ...)

and have control of the beacon Alice ends up using, then you can both observe that Alice is trying to make the payment (you see an HTLC with $20 and R), and prevent Alice from making the payment (you can just not forward any transactions involving R).

Without beacons (but routing still being possible somehow!), Bob could anonymously post prices and R values in public; Alice could observe them anonymously without giving away that she was observing them, and Mallory could not prevent Alice from paying Bob, without controlling Alice or Bob, or a large proportion of the lightning network as a whole. Bob could be a dissident asking for donations in this scenario, eg.

With beacons, Mallory could somewhat plausibly gain control of the beacons Bob is advertising, and then block any payments with those published R values from going through. This could happen by subpoena or national security letter rather than buffer overflow too.

Quoted text (10 lines)
> > Hmm. Counterproposal: no beacons or routing DHT, just fees by gossip
> > protocol (or IRC channel as prototype hack). Everyone has a complete
> > (but possibly slightly out of date) database of node-node (but not
> > node-wallet) channel fees, and changes are propogated by gossip. Back
> > of the envelope maths:
> >
> >   everyone uses lightning ==> 8B wallets (5B teens/adults, 3B businesses)
> >   every wallet has ~4 channels ==> 32B node-wallet channels
> >   100k wallet channels per node on average ==> 320k nodes
> Um, so each wallet isn't a node?

Err, yeah; I've been using those terms mutually exclusively, ie "you're running a full node, or you're just a wallet, you're never both":

13:47 <rusty> kanzure: Aside: Joseph has been avoiding the term hub in
        favour of simply "nodes".  I've been following suit, since I
        think it directs thinking in the right non-centralized direction.
13:47 <kanzure> but hub is more fun to pronounce
13:47 <kanzure> bah fine i'll use node then
13:48 <rusty> kanzure: Me too.  I have a bub, he likes to say hub.
        But I'll just have to teach him....
13:48 <aj> rusty: i feel like "just spending/receiving money with as
        little thought/effort as possible" and "being an active
        participant" needs different words... leaf node and node
        don't really work for me
13:48 <kanzure> "wallet"
13:49 <aj> wallets and nodes? hmm

ie, nodes do payment forwarding; wallets just spend/recieve. You'd use your phone as just a wallet, but you might run a node at home or in the cloud. Wallets still do the lightning protocol themselves, they just don't earn fees by forwarding payments.

Aside: "mesh network" seems to be a much better description than hub-and-spoke... cf

https://www.reddit.com/r/Bitcoin/comments/3lo8mb/serious_question_for_blockstreamcom_will_you_let/

Quoted text (1 line)
> That's a very different architecture,

I'm just using it as terminology (I think...).

The only architectural implication is that I'm assuming "most" people (24999 out of 25000) don't end up doing routing. Given routing nodes have to be online with hot keys and thus risk being hacked and having their funds drained, I think that's fairly plausible?

(Or going the other way; if you're making money running a node, I think it's pretty reasonable you'll try to serve on the order of 100k users -- much less than that and you'll be under utilising your hardware. But with only 8B potential customers, there's a limit on the number of nodes that can actually do that, as calculated above. I'm assuming economics somehow ends up enforcing that limit effectively)

Quoted text (2 lines)
> which uses hosted wallets or something?  I don't think that's very
> interesting.

Not hosted wallets; more along the lines of SPV clients, where you're relying on the network to do most of the work (in this case working out a cheap route, rather than verifying txns)?

Does that make it more interesting?

Cheers, aj

Rusty Russell in reply to Anthony Towns permalink original

Anthony Towns <aj at erisian.com.au> writes:

Quoted text (10 lines)
>> > Finally for (g), I don't think you want to store fees in the routes
>> Well, propagating fee updates for (say) 1200 routes isn't too bad,
>> as long as they're not changing too fast.
>
> So forgetting the DHTs, then fee updates take effect via the
> dijkstra-routing-gossip protocol. I don't have any idea how well that
> would perform... If an average channel's fee updates U times per day,
> there are C channels, and N nodes, does that mean a background noise of
> O(log(N)*U*C) fee update traffic or something? (dividing by N to get the
> traffic an individual node sees)

That sounds about right. There's a tradeoff between redundancy, bandwidth and latency.

Quoted text (4 lines)
> It does mean that the "payment info" has to be provided by the payee
> "shortly" before the transaction; otherwise the route and fee information
> would be out of date and the payment becomes "likely" to fail due to
> closed channels or raised fees.

True. Though in the case of raised fees you get feedback, and can adjust.

Quoted text (12 lines)
>> >> There are some twisty details here:
>> >> 1) How many beacon nodes?
>> >>    12, and increase on a log scale with network size.  That size can
>> >>    be derived from previous beacons.
>> > I think it's also something you could set per-node, like the
>> > minrelaytxfee.
>> That doesn't make sense, since we need to agree on who is a beacon.
>
> If you have the top 10 beacons and I have the top 14 beacons, we have
> the top 10 beacons in common. During the gossip phase, if either of us
> see someone in the top 10, we pass it along; I pass along a few more as
> well.

If I want to pay you, and you give me those 4 beacons I don't accept, we break down.

Quoted text (23 lines)
>> >> 2) How long between selection and a beacon becoming active?
>> >>    10 blocks.  That gives time for others to connect to beacon node.
>> > Beacons can be "active" as soon as you can route through them, and that's
>> > just a DHT lookup to determine, and then a matter of comparing fees to
>> > what the old beacons give you. So I think no artificial delay is needed,
>> > and the real question is just when you expire your routes to/from the
>> > old beacons?
>> No.  Beacons will get saturated fast unless they have a chance to
>> prepare.
>
> Sure. I was thinking you have to volunteer to be a beacon, ie something
> like:
>
>   1) commit to node id (anchor transaction in blockchain)
>   2) commit to ordering (abs difference of node id versus
>      sha of latest blockchain block with (depth % 2016 == 0))
>   3) volunteer to be a beacon (sign "imma beacon! depth $n anchor
>      $txid")
>   4) gossip (including your signed volunteer statement) and hope you're
>      in the top 12
>
> Any preparation (opening new channels etc happens between (2) and (3)),
> transactions happen immediately after (4).

We don't want to have to maintain a table of volunteers, hence 3 & 4 are merged (simple optimization: delay advertising yourself as a beacon longer if it's less likely).

Then by convention you delay 10 blocks before using a beacon. By that time, routes should be sufficient.

So, it comes down to the following if you want to be a beacon:

1) Use same key anchor tx to sign a message linking your node id to the
   tx.
2) Broadcast that, and signed routes as normal.
Quoted text (20 lines)
>> In particular, the network will want to establish channels
>> with new beacons, and beacons may well want to bring offline funds
>> online to handle the anticipated capacity.
>
> So... doesn't this provide a /really/ juicy target for hackers? Either
> of the "let's steal funds" variety, or of the "let's find out as much
> info about every transaction as we can" type?
>
> If you just have to hack 12 systems to observe/DoS 100% of lightning
> network transactions, that seems worrying to me. I think I'd want to avoid
> being a beacon in that case, just to avoid painting a target on my system.
>
> I'm not sure if it's a realistic attack model, but if you can observe:
>
>   Bob -> Alice: pay me $20 to R (routes to current beacons: ...)
>
> and have control of the beacon Alice ends up using, then you can both
> observe that Alice is trying to make the payment (you see an HTLC with
> $20 and R), and prevent Alice from making the payment (you can just not
> forward any transactions involving R).

Sure. But if you can observe the private conversation between Bob and Alice, *and* you control enough nodes that you're likely to be the beacon they choose, you don't need to be a beacon to block them :)

Quoted text (6 lines)
> Without beacons (but routing still being possible somehow!), Bob could
> anonymously post prices and R values in public; Alice could observe them
> anonymously without giving away that she was observing them, and Mallory
> could not prevent Alice from paying Bob, without controlling Alice or Bob,
> or a large proportion of the lightning network as a whole. Bob could be
> a dissident asking for donations in this scenario, eg.

Yes! I've been wondering about this kind of "donation address" scenario. Turns out you can encode the R value in the onion routed message you send, too. Only the final recipient can read it anyway.

That doesn't help with routing to the donation address; maybe we will need a best-effort DHT for that?

Quoted text (4 lines)
> ie, nodes do payment forwarding; wallets just spend/recieve. You'd use
> your phone as just a wallet, but you might run a node at home or in
> the cloud. Wallets still do the lightning protocol themselves, they just
> don't earn fees by forwarding payments.

I think you do want to

Quoted text (5 lines)
>
> Aside: "mesh network" seems to be a much better description than
> hub-and-spoke... cf
>
> https://www.reddit.com/r/Bitcoin/comments/3lo8mb/serious_question_for_blockstreamcom_will_you_let/

Thanks for that: I'd somehow missed that troll.

Quoted text (8 lines)
>> That's a very different architecture,
>
> I'm just using it as terminology (I think...).
>
> The only architectural implication is that I'm assuming "most" people
> (24999 out of 25000) don't end up doing routing. Given routing nodes
> have to be online with hot keys and thus risk being hacked and having
> their funds drained, I think that's fairly plausible?

But that risk also describes a wallet. And if you route, you potentially gain funds as well as privacy. It's more a connectivity issue, I think.

Quoted text (13 lines)
> (Or going the other way; if you're making money running a node, I think
> it's pretty reasonable you'll try to serve on the order of 100k users
> -- much less than that and you'll be under utilising your hardware. But
> with only 8B potential customers, there's a limit on the number of nodes
> that can actually do that, as calculated above. I'm assuming economics
> somehow ends up enforcing that limit effectively)
>
>> which uses hosted wallets or something?  I don't think that's very
>> interesting.
>
> Not hosted wallets; more along the lines of SPV clients, where you're
> relying on the network to do most of the work (in this case working out
> a cheap route, rather than verifying txns)?

But the "give me a cheap route" question is exactly the same whatever your role. It's "give me all your routes to beacons". That's a few hundred routes. If we're clever it's "give me changes since last time", which is easy given that it's finite.

This has the advantage that you can't even tell if I'm routing or not.

Cheers, Rusty.

Rusty Russell in reply to Amos Bairn permalink original

Amos Bairn <eylrid at gmail.com> writes:

Quoted text (5 lines)
> The obvious problem with having the whole network use the same set of
> beacons at the same time is that those nodes will get slammed. A possible
> solution is to have each user pick their own set of beacons (at random),
> but make the beacon set large enough so that any two users are likely to
> share a few. That way the all of nodes would share the load roughly evenly.

The core scaling problem is propagating current fee information (ie. the dynamic part of route information) across the network. That's easy with agreed beacons. Hard with random beacons.

Beacons are going to get slammed, but it's not clear how bad it is. Getting slammed from all directions doesn't use up channels; it's only computational and bandwidth limits.

Their neighbors will want to buff up, too (they'll take some load off the beacon if both parties route through them).

A semi-realistic simulation would be interesting. If payments cluster by geography and some random channels are established by proximity (ie. low latency) that may take some of load off the beacons too.

Cheers, Rusty.

Anthony Towns in reply to Rusty Russell permalink original

On Fri, Sep 25, 2015 at 11:23:42AM +0930, Rusty Russell wrote:

Quoted text (3 lines)
> Beacons are going to get slammed, but it's not clear how bad it is.
> Getting slammed from all directions doesn't use up channels; it's only
> computational and bandwidth limits.

It does actually use up channels -- if you've got 5 channels with 100 BTC in them collectively in total, and you own 20 BTC of that, and collect a 0.1% fee on each transaction, you'll gain 80 BTC after 80,000 BTC are forwarded through you, and nobody will be able to send you funds any more.

As a beacon, you'll probably be tempted to raise your fees (you're only competing against the 11 other current beacons which you can monitor fairly closely), so 1% or even 2% might be realistic figures, reducing the number of transactions by a factor of 10 or 20.

Other nodes can fix that by opening up new channels to you, though.

As far as b/w goes, the number of beacons and they're bandwidth puts a limit on the transactions per second of the lightning network: if each of 12 beacons have 100Mb/s bandwidth available, and use 2048B to forward an HTLC, then the number of HTLCs a beacon can forward per second is:

  100e6/8 / 2048 = ~6100

multiplying by 12 beacons to give a maximum of around ~73k lightning transactions per second; which is about the same as the VisaNet stress tests (56k tps), which seems too low to me if you want micropayments.

Quoted text (2 lines)
> Their neighbors will want to buff up, too (they'll take some load off
> the beacon if both parties route through them).

(In the event that someone suggests a route beacon_X -> X -> Y -> Z to get to them, and you have a path A -> C -> X -> beacon_X, you can cut out the middleman and not route through a beacon at all. I don't think this gives much of an improvement though. A beacon could potentially avoid this from being possible by partitioning its neighbours into two sets and setting incoming fees for one set prohibitively high, and outgoing fees to the other set as prohibitively high; managing that dynamically would be difficult but I think possible)

Quoted text (3 lines)
> A semi-realistic simulation would be interesting.  If payments cluster
> by geography and some random channels are established by proximity
> (ie. low latency) that may take some of load off the beacons too.

I think routing by proximity cuts out some of the benefits of onion routing; you just end up with locals conncting to their local banks, and paying locals directly via their bank, and the bank being able to directly correlate payments (or two banks being able to collaborate to correlate sender and recipient).

Cheers, aj

Anthony Towns in reply to Rusty Russell permalink original

On Fri, Sep 25, 2015 at 06:26:55AM +0930, Rusty Russell wrote:

Quoted text (13 lines)
> >> >> There are some twisty details here:
> >> >> 1) How many beacon nodes?
> >> >>    12, and increase on a log scale with network size.  That size can
> >> >>    be derived from previous beacons.
> >> > I think it's also something you could set per-node, like the
> >> > minrelaytxfee.
> >> That doesn't make sense, since we need to agree on who is a beacon.
> > If you have the top 10 beacons and I have the top 14 beacons, we have
> > the top 10 beacons in common. During the gossip phase, if either of us
> > see someone in the top 10, we pass it along; I pass along a few more as
> > well.
> If I want to pay you, and you give me those 4 beacons I don't accept, we
> break down.

I have 14 beacons, and I know the order in which you're most likely to have them. If I know you can choose how many beacons you track, why would I give you the four you're least likely to have (because you have a lower limit, or because you've heard of four better beacons that haven't made it to me yet)?

Since I have to update my beacon-to-me routes regularly because of fee changes, I could regularly select different groups of beacons so you could just ask again.

Quoted text (24 lines)
> >> >> 2) How long between selection and a beacon becoming active?
> >> >>    10 blocks.  That gives time for others to connect to beacon node.
> >> > Beacons can be "active" as soon as you can route through them, and that's
> >> > just a DHT lookup to determine, and then a matter of comparing fees to
> >> > what the old beacons give you. So I think no artificial delay is needed,
> >> > and the real question is just when you expire your routes to/from the
> >> > old beacons?
> >> No.  Beacons will get saturated fast unless they have a chance to
> >> prepare.
> > Sure. I was thinking you have to volunteer to be a beacon, ie something
> > like:
> >
> >   1) commit to node id (anchor transaction in blockchain)
> >   2) commit to ordering (abs difference of node id versus
> >      sha of latest blockchain block with (depth % 2016 == 0))
> >   3) volunteer to be a beacon (sign "imma beacon! depth $n anchor
> >      $txid")
> >   4) gossip (including your signed volunteer statement) and hope you're
> >      in the top 12
> > Any preparation (opening new channels etc happens between (2) and (3)),
> > transactions happen immediately after (4).
> We don't want to have to maintain a table of volunteers, hence 3 & 4 are
> merged (simple optimization: delay advertising yourself as a beacon
> longer if it's less likely).

If you want to do any setup, I think you need to advertise yourself as a beacon to the people you want to setup with. I'm thinking that if you win the beacon lottery, you'll want to say "hi, I'm about to be a beacon" so people will setup channels with you without you having to put much initial investment in that channel. The people setting up channels with you see a bunch of people doing that, and will only want to deal with the top 12 or so. I'm not sure that's much different to actually advertising?

Quoted text (2 lines)
> Then by convention you delay 10 blocks before using a beacon.  By that
> time, routes should be sufficient.

I wouldn't have thought 10 blocks was long enough to setup a new channel especially to a beacon, fwiw. (If you can create a channel to a beacon with the beacon's side initially 0, spend all that money back to yourself, then reorg with a doublespend of the anchor inputs so the channel never existed, you can steal the beacon's pre-existing savings. The routing's trivial -- it's you to the beacon, and then each of your neighbours will tell you the cheapest path from a beacon to them as soon as they know it)

Quoted text (19 lines)
> > So... doesn't this provide a /really/ juicy target for hackers? Either
> > of the "let's steal funds" variety, or of the "let's find out as much
> > info about every transaction as we can" type?
> >
> > If you just have to hack 12 systems to observe/DoS 100% of lightning
> > network transactions, that seems worrying to me. I think I'd want to avoid
> > being a beacon in that case, just to avoid painting a target on my system.
> >
> > I'm not sure if it's a realistic attack model, but if you can observe:
> >
> >   Bob -> Alice: pay me $20 to R (routes to current beacons: ...)
> >
> > and have control of the beacon Alice ends up using, then you can both
> > observe that Alice is trying to make the payment (you see an HTLC with
> > $20 and R), and prevent Alice from making the payment (you can just not
> > forward any transactions involving R).
> Sure.  But if you can observe the private conversation between Bob and
> Alice, *and* you control enough nodes that you're likely to be the
> beacon they choose, you don't need to be a beacon to block them :)

You don't have to control the nodes initially, you just have to attack the beacons once they're announced. If they're accepting new channels, then they've announced an IP. If you get an exploit on a node that would have been #15 in the ranking, you just have to DoS three higher ranked beacons to get it to have traffic.

Quoted text (9 lines)
> > Without beacons (but routing still being possible somehow!), Bob could
> > anonymously post prices and R values in public; Alice could observe them
> > anonymously without giving away that she was observing them, and Mallory
> > could not prevent Alice from paying Bob, without controlling Alice or Bob,
> > or a large proportion of the lightning network as a whole. Bob could be
> > a dissident asking for donations in this scenario, eg.
> Yes!  I've been wondering about this kind of "donation address"
> scenario.  Turns out you can encode the R value in the onion routed
> message you send, too.  Only the final recipient can read it anyway.

Yep.

Quoted text (2 lines)
> That doesn't help with routing to the donation address; maybe we will
> need a best-effort DHT for that?

If you've got a route, but no fee information; you could probe the route with nanopayments. ie, to move $10 along me->A->B->C->D, first try sending 0.01c to B with a 0.1% then a 0.2% fee, etc. Once you know A's fee, repeat with B, then C. If the fees end up as 1%, 2% and 0.2% your successful transactions are:

  0.01c to B plus 0.0001c to A
  0.01c to C plus 0.0001c to A plus 0.0002c to B
  0.01c to D plus 0.0001c to A plus 0.0002c to B plus 0.00002c to C
  $10 to D plus 10c to A plus 20c to B plus 2c to C

and the txs that had smaller fees just bounce back to you.

Totals:
  $10 to D and also
   0.01c to D
   2.01002c to C
  20.0014c to B
  10.0003c to A

for a total of $10 and 32.02172c.

0.2c = 860 satoshi, but lightning handles milli-satoshi now, so 0.0002c = 860 msat and 0.00002c = 86 msat, so all those fees are expressible, and the probing only increases your fees by 0.06%. If I'd been sending 10c instead of $10 but used the same nanotransaction probing I would've paid 0.34172c instead of .32c in fees for a 6% increase in fees. So pretty plausible even then.

(If probing was the main use for nanotransactions, nodes might set higher fees on them though, if they assume you've already chosen a route, and they therefore don't need to compete on price with other possible routes)

Quoted text (5 lines)
> > ie, nodes do payment forwarding; wallets just spend/recieve. You'd use
> > your phone as just a wallet, but you might run a node at home or in
> > the cloud. Wallets still do the lightning protocol themselves, they just
> > don't earn fees by forwarding payments.
> I think you do want to

"run a node on your phone" ?

In order to gain node-like return on your investment, I think you'd have to be constantly active -- so updating your routes, tracking beacons, etc. You'd miss out on ever being a beacon presumably, which would pretty severely cut into your income to nodes that are beacons -- though maybe you could sell your beacon-worthy private keys and recoup some of that? I don't see how anyone would feel confident to buy your private keys though.

Your phone would need to be doing fairly constant network access while it was in your pocket as it forwarded HTLCs; 24k transactions per second over a million nodes at 5 non-beacon hops is still around 7 tx/minute for a random node. Each of those comes with multiple crypto ops as well. So you'd be burning battery afaics. If you're only doing it while you're plugged into AC, then I'd expect your ROI to drop proportionately (so instead of $10 from $100 over a year, maybe $3.50 if you leave your phone on charge every night).

It'd also up the latency for people routed through you a fair bit; phones aren't that fast, and aren't that well connected. So any payment routed over one would be that much slower than one that went via servers on fibre. If you're slow to process a transaction and more likely to lose connectivity, that ups the chances of an HTLC stalling -- you've accepted it, but you lost connectivity while trying to forward it, so everyone else is out of pocket until you get signal back.

Forwarding also introduces the risk that all your funds are tied up in active HTLCs when you want to buy a coffee.

I just don't think everyone running a full node trying to make a profit off routing is realistic.

Quoted text (4 lines)
> > Aside: "mesh network" seems to be a much better description than
> > hub-and-spoke... cf
> > https://www.reddit.com/r/Bitcoin/comments/3lo8mb/serious_question_for_blockstreamcom_will_you_let/
> Thanks for that: I'd somehow missed that troll.

Seemed like a legit question to me *shrug*. There's a corresponding thread (same title) on BitcoinXT, if you really want to feel trolled.

There's also:

  /r/lightningnetwork: The Bitcoin Lightning Network
  This sub-reddit is dedicated to corporate interests trying to take over
  the decentralized world-wide ledger.

No posts unfortunately...

Quoted text (7 lines)
> >> That's a very different architecture,
> > I'm just using it as terminology (I think...).
> > The only architectural implication is that I'm assuming "most" people
> > (24999 out of 25000) don't end up doing routing. Given routing nodes
> > have to be online with hot keys and thus risk being hacked and having
> > their funds drained, I think that's fairly plausible?
> But that risk also describes a wallet.

I don't think so: if I'm only sending/receiving money, I can be offline for the entire time I'm not doing transactions. For consumers, that's (potentially) most of the time; for merchants, that's at least when the business is closed (not much benefit for 24/7 online businesses though).

Quoted text (1 line)
> And if you route, you potentially gain funds as well as privacy.

It'll only gain you a percentage of what you've got in the channel though (or that's what I expect anyway). If you're a consumer who keeps $100 in your wallet, that's maybe $10 in a year. But to earn that $10 you have to worry about keeping you wallet secure and online, which I'd expect isn't worth it. For a phone, that could be compromised by plugging it into a USB port for power, or a flaw in a carrier's version of android, or privilege escalation from some random app, I'd rather have it be offline and safe for the 99% of the time I'm not buying anything.

(Caveat one: Maybe phones are so insecure there's no way to have a private key that's reasonably convenient, but also "safe" while "offline". You could mitigate that by introducing a second factor; having $10 on your phone most of the time -- coffee and bus fare money, that you don't care much if someone steals -- but having a secondary lightning wallet that you can only use by tapping a crypto-NFC smartcard for when you want to pay for dinner or recharge your primary wallet, eg. Having your phone be secure directly would be better though)

(Caveat two: There's no reason not to forward transactions while you're online and your private keys are in memory -- err, assuming they don't lock up too many funds anyway; I just think there's good reason to be online as little as possible)

As far as privacy goes I think you could tell which of your neighbours is using lightning primarily as a wallet versus trying to be a profit-generating node fairly easily: wallets will have smaller channels, there'll be fewer transactions over them, and they'll disconnect more often. That doesn't guarantee they're not forwarding things; but if they are they're almost certainly arranging it out of band anyway (even if only to know when they'll be online and thus able to forward).

(I actually think arguing the other way might make a bit of sense; if you're running a node, you should pay profits and expenses to/from an entirely separate lightning wallet)

Quoted text (15 lines)
> > (Or going the other way; if you're making money running a node, I think
> > it's pretty reasonable you'll try to serve on the order of 100k users
> > -- much less than that and you'll be under utilising your hardware. But
> > with only 8B potential customers, there's a limit on the number of nodes
> > that can actually do that, as calculated above. I'm assuming economics
> > somehow ends up enforcing that limit effectively)
> >
> >> which uses hosted wallets or something?  I don't think that's very
> >> interesting.
> >
> > Not hosted wallets; more along the lines of SPV clients, where you're
> > relying on the network to do most of the work (in this case working out
> > a cheap route, rather than verifying txns)?
> But the "give me a cheap route" question is exactly the same whatever
> your role.  It's "give me all your routes to beacons".

I was talking about the beacon-less alternative here, where nodes have the full weighted-directed-graph of channels and fees to work out a route.

Quoted text (1 line)
> That's a few hundred routes.

Also, with beacons, you don't need to know all their routes to beacons, just their cheapest route to each beacon, so that should be just 12 routes (unless we're working with a few hundred beacons now?). No matter which route from them, it'll always just be the same You<->Them channel beforehand, so cheapest via them will just be that plus their cheapest. You need to keep all your neighbours' cheapest routes to fall back on if someone else raises fees though, if you're not willing to repoll.

Cheers, aj

Rusty Russell in reply to Anthony Towns permalink original

Anthony Towns <aj at erisian.com.au> writes:

Quoted text (20 lines)
> On Fri, Sep 25, 2015 at 06:26:55AM +0930, Rusty Russell wrote:
>> >> >> There are some twisty details here:
>> >> >> 1) How many beacon nodes?
>> >> >>    12, and increase on a log scale with network size.  That size can
>> >> >>    be derived from previous beacons.
>> >> > I think it's also something you could set per-node, like the
>> >> > minrelaytxfee.
>> >> That doesn't make sense, since we need to agree on who is a beacon.
>> > If you have the top 10 beacons and I have the top 14 beacons, we have
>> > the top 10 beacons in common. During the gossip phase, if either of us
>> > see someone in the top 10, we pass it along; I pass along a few more as
>> > well.
>> If I want to pay you, and you give me those 4 beacons I don't accept, we
>> break down.
>
> I have 14 beacons, and I know the order in which you're most likely
> to have them. If I know you can choose how many beacons you track,
> why would I give you the four you're least likely to have (because you
> have a lower limit, or because you've heard of four better beacons that
> haven't made it to me yet)?

Ergo, there are only 10 beacons, since that's all you'll ever use? So, you *don't* get to choose your number of beacons.

Anyway, I won't propagate fee broadcasts which don't alter my proximity to a beacon. So if I'm between you and something only you consider a "beacon", you'll never know about it.

And in practice it's trivial to agree on the number of new beacons for this block, given the beacons for previous blocks (assuming we want number of beacons to grow with the network).

In summary, having your own beacons basically defeats the purpose of selecting beacons.

Quoted text (3 lines)
> Since I have to update my beacon-to-me routes regularly because of fee
> changes, I could regularly select different groups of beacons so you
> could just ask again.

Yech... you really want this to be single pass "pay me $5, and here are three routes from beacons near me".

Quoted text (23 lines)
>> > Sure. I was thinking you have to volunteer to be a beacon, ie something
>> > like:
>> >
>> >   1) commit to node id (anchor transaction in blockchain)
>> >   2) commit to ordering (abs difference of node id versus
>> >      sha of latest blockchain block with (depth % 2016 == 0))
>> >   3) volunteer to be a beacon (sign "imma beacon! depth $n anchor
>> >      $txid")
>> >   4) gossip (including your signed volunteer statement) and hope you're
>> >      in the top 12
>> > Any preparation (opening new channels etc happens between (2) and (3)),
>> > transactions happen immediately after (4).
>> We don't want to have to maintain a table of volunteers, hence 3 & 4 are
>> merged (simple optimization: delay advertising yourself as a beacon
>> longer if it's less likely).
>
> If you want to do any setup, I think you need to advertise yourself as
> a beacon to the people you want to setup with. I'm thinking that if you
> win the beacon lottery, you'll want to say "hi, I'm about to be a beacon"
> so people will setup channels with you without you having to put much
> initial investment in that channel. The people setting up channels with
> you see a bunch of people doing that, and will only want to deal with the
> top 12 or so. I'm not sure that's much different to actually advertising?

Well, my original idea was a beacon can just start broadcasting routes and see what happens.

But you're right makes more sense to have two-phases: an immediate one after the block is broadcast where you compete (via SPV proof of some tx) to be a beacon, then another closer to activation where you broadcast routes. Between those two you can expect an influx of channel offers.

Interestingly, the former idea means you get some leakage of routes, from nearby almost-beacons (until defeated by better beacons). Remembering those might help shortcircuit some routes (if there's some geographical correlation between nodes).

Quoted text (10 lines)
>> Then by convention you delay 10 blocks before using a beacon.  By that
>> time, routes should be sufficient.
>
> I wouldn't have thought 10 blocks was long enough to setup a new channel
> especially to a beacon, fwiw. (If you can create a channel to a beacon
> with the beacon's side initially 0, spend all that money back to yourself,
> then reorg with a doublespend of the anchor inputs so the channel never
> existed, you can steal the beacon's pre-existing savings. The routing's
> trivial -- it's you to the beacon, and then each of your neighbours will
> tell you the cheapest path from a beacon to them as soon as they know it)

I guess I was thinking of microtransactions, and expecting the average anchor depth requirement to be ~1. 6 is considered pretty conservative; I only added 4 to allow for propogation and setup time.

Quoted text (17 lines)
>> > I'm not sure if it's a realistic attack model, but if you can observe:
>> >
>> >   Bob -> Alice: pay me $20 to R (routes to current beacons: ...)
>> >
>> > and have control of the beacon Alice ends up using, then you can both
>> > observe that Alice is trying to make the payment (you see an HTLC with
>> > $20 and R), and prevent Alice from making the payment (you can just not
>> > forward any transactions involving R).
>> Sure.  But if you can observe the private conversation between Bob and
>> Alice, *and* you control enough nodes that you're likely to be the
>> beacon they choose, you don't need to be a beacon to block them :)
>
> You don't have to control the nodes initially, you just have to attack
> the beacons once they're announced. If they're accepting new channels,
> then they've announced an IP. If you get an exploit on a node that
> would have been #15 in the ranking, you just have to DoS three higher
> ranked beacons to get it to have traffic.

They're still beacons though, they're just useless. You do need to get a beacon then DoS enough others to force traffic though you. That may be cheaper than offering the best rates, I guess.

Quoted text (21 lines)
>> Yes!  I've been wondering about this kind of "donation address"
>> scenario.  Turns out you can encode the R value in the onion routed
>> message you send, too.  Only the final recipient can read it anyway.
>
> Yep.
>
>> That doesn't help with routing to the donation address; maybe we will
>> need a best-effort DHT for that?
>
> If you've got a route, but no fee information; you could probe the
> route with nanopayments. ie, to move $10 along me->A->B->C->D, first
> try sending 0.01c to B with a 0.1% then a 0.2% fee, etc. Once you know
> A's fee, repeat with B, then C. If the fees end up as 1%, 2% and 0.2%
> your successful transactions are:
>
>   0.01c to B plus 0.0001c to A
>   0.01c to C plus 0.0001c to A plus 0.0002c to B
>   0.01c to D plus 0.0001c to A plus 0.0002c to B plus 0.00002c to C
>   $10 to D plus 10c to A plus 20c to B plus 2c to C
>
> and the txs that had smaller fees just bounce back to you.

I was assuming the "insufficient fees" message would include the latest route info, so it's even easier.

I was more concerned about the "there's no channel from B->C any more".

Quoted text (3 lines)
> (If probing was the main use for nanotransactions, nodes might set higher
> fees on them though, if they assume you've already chosen a route, and
> they therefore don't need to compete on price with other possible routes)

Maybe nodes will offer some kind of routing service in future. Seems like it'd be a layer up though.

Quoted text (24 lines)
>> > ie, nodes do payment forwarding; wallets just spend/recieve. You'd use
>> > your phone as just a wallet, but you might run a node at home or in
>> > the cloud. Wallets still do the lightning protocol themselves, they just
>> > don't earn fees by forwarding payments.
>> I think you do want to
>
> "run a node on your phone" ?
>
> In order to gain node-like return on your investment, I think you'd have
> to be constantly active -- so updating your routes, tracking beacons,
> etc. You'd miss out on ever being a beacon presumably, which would
> pretty severely cut into your income to nodes that are beacons -- though
> maybe you could sell your beacon-worthy private keys and recoup some of
> that? I don't see how anyone would feel confident to buy your private
> keys though.
>
> Your phone would need to be doing fairly constant network access while
> it was in your pocket as it forwarded HTLCs; 24k transactions per second
> over a million nodes at 5 non-beacon hops is still around 7 tx/minute
> for a random node. Each of those comes with multiple crypto ops as
> well. So you'd be burning battery afaics. If you're only doing it while
> you're plugged into AC, then I'd expect your ROI to drop proportionately
> (so instead of $10 from $100 over a year, maybe $3.50 if you leave your
> phone on charge every night).

Constant connectivity is getting easier. You'd stop accepting new HTLCs once you wanted to go idle.

Quoted text (7 lines)
> It'd also up the latency for people routed through you a fair bit;
> phones aren't that fast, and aren't that well connected. So any payment
> routed over one would be that much slower than one that went via servers
> on fibre. If you're slow to process a transaction and more likely to
> lose connectivity, that ups the chances of an HTLC stalling -- you've
> accepted it, but you lost connectivity while trying to forward it, so
> everyone else is out of pocket until you get signal back.

Yeah, you lose a channel for that. Could end up costing you more than you'd make in profits.

Quoted text (5 lines)
> Forwarding also introduces the risk that all your funds are tied up in
> active HTLCs when you want to buy a coffee.
>
> I just don't think everyone running a full node trying to make a profit
> off routing is realistic.

You're probably right; and poor nodes might help the theoretical decentralization of the network while degrading overall practicality.

But phones will get better.

Quoted text (6 lines)
>> > Aside: "mesh network" seems to be a much better description than
>> > hub-and-spoke... cf
>> > https://www.reddit.com/r/Bitcoin/comments/3lo8mb/serious_question_for_blockstreamcom_will_you_let/
>> Thanks for that: I'd somehow missed that troll.
>
> Seemed like a legit question to me *shrug*.

If it didn't contain a kernel of validity, it wouldn't be a troll, right?

Quoted text (11 lines)
> There's a corresponding thread
> (same title) on BitcoinXT, if you really want to feel trolled.
>
> There's also:
>
>   /r/lightningnetwork: The Bitcoin Lightning Network
>
>   This sub-reddit is dedicated to corporate interests trying to take over
>   the decentralized world-wide ledger.
>
> No posts unfortunately...

Damn, let me fix that...

Quoted text (13 lines)
> (Caveat one: Maybe phones are so insecure there's no way to have a private
> key that's reasonably convenient, but also "safe" while "offline". You
> could mitigate that by introducing a second factor; having $10 on your
> phone most of the time -- coffee and bus fare money, that you don't care
> much if someone steals -- but having a secondary lightning wallet that
> you can only use by tapping a crypto-NFC smartcard for when you want to
> pay for dinner or recharge your primary wallet, eg. Having your phone
> be secure directly would be better though)
>
> (Caveat two: There's no reason not to forward transactions while you're
> online and your private keys are in memory -- err, assuming they don't
> lock up too many funds anyway; I just think there's good reason to be
> online as little as possible)

OK, if we have a real offline mode for standard wallets, the distinction becomes real.

Quoted text (11 lines)
> As far as privacy goes I think you could tell which of your neighbours
> is using lightning primarily as a wallet versus trying to be a
> profit-generating node fairly easily: wallets will have smaller channels,
> there'll be fewer transactions over them, and they'll disconnect more
> often. That doesn't guarantee they're not forwarding things; but if they
> are they're almost certainly arranging it out of band anyway (even if
> only to know when they'll be online and thus able to forward).
>
> (I actually think arguing the other way might make a bit of sense; if
> you're running a node, you should pay profits and expenses to/from an
> entirely separate lightning wallet)

I think deniability is important. Thus I would want my wallet to forward payments when offered.

Quoted text (29 lines)
>> > (Or going the other way; if you're making money running a node, I think
>> > it's pretty reasonable you'll try to serve on the order of 100k users
>> > -- much less than that and you'll be under utilising your hardware. But
>> > with only 8B potential customers, there's a limit on the number of nodes
>> > that can actually do that, as calculated above. I'm assuming economics
>> > somehow ends up enforcing that limit effectively)
>> >
>> >> which uses hosted wallets or something?  I don't think that's very
>> >> interesting.
>> >
>> > Not hosted wallets; more along the lines of SPV clients, where you're
>> > relying on the network to do most of the work (in this case working out
>> > a cheap route, rather than verifying txns)?
>> But the "give me a cheap route" question is exactly the same whatever
>> your role.  It's "give me all your routes to beacons".
>
> I was talking about the beacon-less alternative here, where nodes have
> the full weighted-directed-graph of channels and fees to work out a route.
>
>> That's a few hundred routes.
>
> Also, with beacons, you don't need to know all their routes to beacons,
> just their cheapest route to each beacon, so that should be just 12
> routes (unless we're working with a few hundred beacons now?). No
> matter which route from them, it'll always just be the same You<->Them
> channel beforehand, so cheapest via them will just be that plus their
> cheapest. You need to keep all your neighbours' cheapest routes to
> fall back on if someone else raises fees though, if you're not willing
> to repoll.

Yes, exactly. Routes propagate proportional to number of beacons. Even with hundreds, it's still cheap.

Cheers, Rusty.

Rusty Russell in reply to Anthony Towns permalink original

Anthony Towns <aj at erisian.com.au> writes:

Quoted text (9 lines)
> On Fri, Sep 25, 2015 at 11:23:42AM +0930, Rusty Russell wrote:
>> Beacons are going to get slammed, but it's not clear how bad it is.
>> Getting slammed from all directions doesn't use up channels; it's only
>> computational and bandwidth limits.
>
> It does actually use up channels -- if you've got 5 channels with 100 BTC
> in them collectively in total, and you own 20 BTC of that, and collect
> a 0.1% fee on each transaction, you'll gain 80 BTC after 80,000 BTC are
> forwarded through you, and nobody will be able to send you funds any more.

That's a great insight! Fees *do* erode channels. I had totally missed that.

Quoted text (17 lines)
> As a beacon, you'll probably be tempted to raise your fees (you're only
> competing against the 11 other current beacons which you can monitor
> fairly closely), so 1% or even 2% might be realistic figures, reducing
> the number of transactions by a factor of 10 or 20.
>
> Other nodes can fix that by opening up new channels to you, though.
>
> As far as b/w goes, the number of beacons and they're bandwidth puts a
> limit on the transactions per second of the lightning network: if each
> of 12 beacons have 100Mb/s bandwidth available, and use 2048B to forward
> an HTLC, then the number of HTLCs a beacon can forward per second is:
>
>   100e6/8 / 2048 = ~6100
>
> multiplying by 12 beacons to give a maximum of around ~73k lightning
> transactions per second; which is about the same as the VisaNet stress
> tests (56k tps), which seems too low to me if you want micropayments.

It is. You definitely want to increase the number of beacons with network size.

Quoted text (11 lines)
>> Their neighbors will want to buff up, too (they'll take some load off
>> the beacon if both parties route through them).
>
> (In the event that someone suggests a route beacon_X -> X -> Y -> Z to
> get to them, and you have a path A -> C -> X -> beacon_X, you can cut out
> the middleman and not route through a beacon at all. I don't think this
> gives much of an improvement though. A beacon could potentially avoid
> this from being possible by partitioning its neighbours into two sets
> and setting incoming fees for one set prohibitively high, and outgoing
> fees to the other set as prohibitively high; managing that dynamically
> would be difficult but I think possible)

But you'd risk not being used as a beacon if your fees are too high. It seems to me that a beacon wants many connections, to avoid the "short-circuit" case. At 100 connections, it's only 1%, though that's the best case which assumes they're all equally likely.

Quoted text (9 lines)
>> A semi-realistic simulation would be interesting.  If payments cluster
>> by geography and some random channels are established by proximity
>> (ie. low latency) that may take some of load off the beacons too.
>
> I think routing by proximity cuts out some of the benefits of onion
> routing; you just end up with locals conncting to their local banks,
> and paying locals directly via their bank, and the bank being able to
> directly correlate payments (or two banks being able to collaborate to
> correlate sender and recipient).

Good points. If we reject all routes less than (say) 3 hops by default it might mean that local payments are *less* efficient. Oops.

I'll think harder on this...

Cheers, Rusty.

Anthony Towns in reply to Rusty Russell permalink original

Batch-replying.

On Sun, Sep 27, 2015 at 01:54:45PM +0930, Rusty Russell wrote:

Quoted text (16 lines)
> Anthony Towns <aj at erisian.com.au> writes:
> > On Fri, Sep 25, 2015 at 09:56:02AM +0930, Rusty Russell wrote:
> >> [ Pieter Wuille Cc'd for pubkey recovery, search for "recovered" ]
> >> Mats Jerratsch <matsjj at gmail.com> writes:
> >> >> Indeed.  Random selection helps, here, but analysis will be interesting.
> >> > How have you ended up with a number of beacons you need? 12 seems so
> >> > low, I can’t imagine so few nodes to support all transacting for even
> >> > 10 minutes..
> >> As we keep the last 100 sets of beacons, the load is spread a little.
> > Does that actually work? Old beacons don't do any good if the payee
> > doesn't use them when advertising a route; but old beacons also don't
> > get their fee updates propogated, and aren't known by people who only
> > just joined the network. I don't think you could usefully keep more than
> > the last 2 or 3 sets of beacons?
> I was thinking they all count as active.  No point turning over all the
> beacons every block.

Okay, in that case I was misled by your original description. You're actually talking about n*k beacons at any point in time, of which the oldest k are replaced every d days. If k=12 and n=8, that gives 96 beacons at any point in time. Any given beacon is operation for n*d days, for n=8, then d=1 gives 8 days, while d=7 gives 2 months.

The "d" parameter would be "consensus-critical"; I don't think it's possible to agree on any beacons without agreeing on d. You could vary k or n as the network scales though, but in that case I think it'd generally be easier to vary n than k?

If you identify a given beacon by its cohort (from 1..n), its rank (1..k), its visibility (how long ago you first heard about it in seconds) and its currency (how recently the last route update to that beacon was), then I think the odds of a random other node also knowing about that beacon works out as:

 - worse for the most recent cohort (older cohorts should have more fully
   propogated)
 - potentially worse for the very oldest cohorts
    + if being a beacon wears you out (channels may have been used
      up; they may have been hacked; they may have cashed out their
      profits and bought an island)
    + if nodes have varying settings for n, so older cohorts don't have
      as effective route propagation
 - worse for recent visibility (newly advertising beacon, that hadn't
   fully propagated, same deal as for a new cohort)
 - worse for non-recent currency (beacon might be offline, or routes to
   that beacon might have failed)
 - worse for low rank in recent cohorts (new beacons shouldn't show up
   for old cohorts; if new beacons show up in recent cohorts, its the
   low rank beacons that will be offloaded)
 - worse for low rank in any cohort if other nodes have lower values for
   k

When picking beacons to advertise for accepting a payment, I think you'd want to take most of the above into account, to avoid only suggesting coincidently unreachable beacons, and having the payment fail.

I don't think you could really take route price into account, since the real price is "consumer to beacon" plus "beacon to merchant"; and those could trivially be inversely related. Having 10%-30% of your suggestions be selected by cheapness would still be useful though.

Choosing, say, two of the cheapest beacons, and three beacons from cohorts 3-n with recent currency and long term visibility would probably work okay though.

If nodes are identified by a 160b address, and it takes around 4 hops to get to/from a random beacon, then a route is 4*160b=80B and five routes as above is 400B. That's ~550 bytes with base58 encoding by my count, or about 7 lines of 76 column text. Kinda lame:

"please pay to 1ajaj31PWNVZEzd68S8PqAPof4EFbeZaf via lightning route: 5PSGzi9R6k6G2mdFPx2ZsfyVdiz9gSaA7EegpTvzbxLb13yMEuNuK7m1DhJuJvwkMe4BrfdU2V5q cKf825oYmikQMzpfAvVkavA3AyXZEgGWx9j3j5gUxMUE8LhawnfTWWSQMc2gChzKEz1puFcyveMa QHVdhbcJY73M4Aev7KDWqnrAYNid2keGRzDtUDfZarSsABR4RWjshCtBctekjvxYQpsBqD4NrzvV DCGQNNWbKibSawkt18xdPGxR3rwMwkEqU5rE8EfXmFrFaj7t2nB8DWQa1oe4QhvPe9BYsyAumJtG SZFmRknJ2E5feDCzYfqAu8tVcaW6yhKUgxdrxqBVfzdTBFVtt2p5PPrz4C9d3MQsrerfSHSbbX7Q VcUqhotinoMHX2UyfbRYX4BJgNjLqaXE33EthhF7BBmBRkP6V7EyZYrc53XtEi1ocuKNiejWcEQe neajEMR9rFpHHSnzSX8AXXn13TYsGirHiFG7KYu7tzg6EFEifLeAz2wxaaaMs2K6J488kxWpDy1s GtG3zX3v5msToo"

(I 100% approve of urandom generating bytes that encoded to "aj" twice in the length I estimated for a route... Sure, it probably means my RNG is compromised and identifying me, but how sweetly personalised!)

Quoted text (10 lines)
> >> To start, I was thinking you establish channels with 5 random nodes.
> > I think Barabasi-Albert graphs are probably pretty reasonable here --
> > you start by establishing channels to N nodes, selected randomly but
> > favouring nodes in proportion to how connected they already are.
> > https://en.wikipedia.org/wiki/Barab%C3%A1si%E2%80%93Albert_model
> Interesting.  If we assume growth only (as I suggested) we end up with a
> geometric distribution (as backed by Section 5 of
> http://www.e-publications.org/ims/submission/index.php/BEJ/user/submissionFile/10315?confirm=c40442a0
> ).
> It's not clear that we want a power law: do we?

I was more thinking that it's what we'll get without any particular effort. The more connected a node is:

 - the more likely you'll hear about it (via p2p), so the more likely
   you'll connect to it, versus a node you don't know exists
 - the more it will earn from fees, so the more funds it will have to
   connect to you out of the blue
 - the cheaper its routes to other nodes (beacons, consumers, merchants)
   will be at least by path length, so the more attractive it will be
   for connecting to (at least, I think?)

so the more likely you'll connect to it by happenstance, and the more happy you'll be that you did.

On Sun, Sep 27, 2015 at 02:56:29PM +0930, Rusty Russell wrote:

Quoted text (22 lines)
> Anthony Towns <aj at erisian.com.au> writes:
> > On Fri, Sep 25, 2015 at 06:26:55AM +0930, Rusty Russell wrote:
> >> >> >> There are some twisty details here:
> >> >> >> 1) How many beacon nodes?
> >> >> >>    12, and increase on a log scale with network size.  That size can
> >> >> >>    be derived from previous beacons.
> >> >> > I think it's also something you could set per-node, like the
> >> >> > minrelaytxfee.
> >> >> That doesn't make sense, since we need to agree on who is a beacon.
> >> > If you have the top 10 beacons and I have the top 14 beacons, we have
> >> > the top 10 beacons in common. During the gossip phase, if either of us
> >> > see someone in the top 10, we pass it along; I pass along a few more as
> >> > well.
> >> If I want to pay you, and you give me those 4 beacons I don't accept, we
> >> break down.
> > I have 14 beacons, and I know the order in which you're most likely
> > to have them. If I know you can choose how many beacons you track,
> > why would I give you the four you're least likely to have (because you
> > have a lower limit, or because you've heard of four better beacons that
> > haven't made it to me yet)?
> Ergo, there are only 10 beacons, since that's all you'll ever use?  So,
> you *don't* get to choose your number of beacons.

Or I choose 3 from the top 10 and 1 from the bottom 4, and have the top 10 used 90% of the time and the bottom 4 10% of the time?

Quoted text (3 lines)
> Anyway, I won't propagate fee broadcasts which don't alter my proximity
> to a beacon.  So if I'm between you and something only you consider a
> "beacon", you'll never know about it.

If 25% of the network uses 14, and 75% uses 10, but the 25% is a strongly connected subgraph, I'll know about the routes to the next four. Maybe they won't be the optimal routes to those beacons, and thus won't often be the cheapest routes, and thus won't often get used, but it still all works fine. As other people switch and it gets to a higher percentage, you get a smooth transition from k=10 to k=14.

I think bumping n=8 to n=9 or n=10 would work similarly.

If you're going to have parameters that need to be changed as things scale, seems useful to have them accept changes gracefully, rather than relying on flag days. I'm still pretty sure that k (and/or n) here work that way, as described.

Quoted text (5 lines)
> > Since I have to update my beacon-to-me routes regularly because of fee
> > changes, I could regularly select different groups of beacons so you
> > could just ask again.
> Yech... you really want this to be single pass "pay me $5, and here are
> three routes from beacons near me".

Well, so far a "route" consists of a path with fees; symbolically:

 pay [MY ADDRESS] $5 via:
   [BEACON 1] 1c [N1A] 1c [N1B] 2c [N1C] 2c [N1D] 4c [ME]
   [BEACON 2] 2c [N2A] 1c [N1C] 2c [N1D] 4c [ME]
   [BEACON 3] 1c [N3A] 3c [N3B] 1c [N3C] 1c [N3D] 1c [ME]

So even if you keep the same set of beacons, you have to regularly update the route info as fees/routes change, eg:

 pay [MY ADDRESS] $5 via:
   [BEACON 1] 1c [N1A] 1c [N1B] 2c [N1C] 2c [N1D] 4c [ME]
   [BEACON 2] 2c [N2A] 2c [N2B] 1c [ME]
   [BEACON 3] 1c [N3A] 3c [N3B] 1c [N3C] 1c [N3D] 1c [ME]
 (N2A to N2B dropped it's previously uncompetitive fee from 10c to 2c in
  this example, nothing else changed. N1C->N2A costs 8c)

Even just sitting on the "checkout" page for a minute might be long enough to require a new route suggestion, eg.

If you're doing that anyway, might as well select a different set of beacons each time as well.

(The only way to not have to do that (afaics) is to just say "pay [MY ADDRESS $5" and query the network for the route; which either means keeping the entire graph available for path finding, or having DHTs to lookup routes from beacons and fees)

Quoted text (5 lines)
> But you're right makes more sense to have two-phases: an immediate one
> after the block is broadcast where you compete (via SPV proof of some
> tx) to be a beacon, then another closer to activation where you
> broadcast routes.  Between those two you can expect an influx of channel
> offers.

If you've got n cohorts of beacons anyway, it seems like you'd just always have the newest cohort be "in setup phase". ie, they'd announce and compete fairly quickly (minutes or hours), and then spend some time getting fully setup (new channels, rebalancing), and obviously still forwarding any transactions that find their way to them, but everyone would still tend to use the more established cohorts. Then once the /next/ cohort gets selected, it's game on.

That'd just require merchants to not select the latest cohort of beacons when advertising routes from beacons. As far as everyone else is concerned, brand new beacons are fine to use as normal if they turn out to be the best route.

Quoted text (4 lines)
> Interestingly, the former idea means you get some leakage of routes,
> from nearby almost-beacons (until defeated by better beacons).
> Remembering those might help shortcircuit some routes (if there's some
> geographical correlation between nodes).

I don't think this works: old route info also means old fee info; and you can only shortcircuit if the fees are actually less, which you no longer know.

Quoted text (12 lines)
> >> Then by convention you delay 10 blocks before using a beacon.  By that
> >> time, routes should be sufficient.
> > I wouldn't have thought 10 blocks was long enough to setup a new channel
> > especially to a beacon, fwiw. (If you can create a channel to a beacon
> > with the beacon's side initially 0, spend all that money back to yourself,
> > then reorg with a doublespend of the anchor inputs so the channel never
> > existed, you can steal the beacon's pre-existing savings. The routing's
> > trivial -- it's you to the beacon, and then each of your neighbours will
> > tell you the cheapest path from a beacon to them as soon as they know it)
> I guess I was thinking of microtransactions, and expecting the average
> anchor depth requirement to be ~1.  6 is considered pretty conservative;
> I only added 4 to allow for propogation and setup time.

I don't think microtransactions help reduce risk here: from one angle, if you're spending $10,000/year on hardware and admin time to keep your node operating, you want to make that much in revenue to pay for it, and if revenue is 20% ROI per year, that's $50,000 investment or more on your side of your channels. ie, I'm expecting to see serious money locked up in channels.

(If forwarding a txn earns you 0.2%, then $10k/year in fees means forwarding $5M/year, so $13k/day, $600/hour, $10/minute, or 15c per second on average. If your average transaction is $10, that's one a minute; if it's 10c, it's three every two seconds, etc.)

Now, if you're always receiving paired transactions (10c from Alice to Carol, then 10c from Carol to Alice, then 10c from Alice to Carol again, etc), you don't need more than 10c in your channels to forward the payments, and your profit isn't dependent on your investment, and life is pretty sweet.

But if there's time discrepencies so that Alice pays multiple rounds of 10c to Carol, who then batches it up into a single $10 payment, you need $10 in your channel (100x more). Or if Alice and Anna and Amy and Abby all pay multiple rounds of 10c, then eventually Carol accumulates that into a burst of 50x $10 payments, you need at least $500 in your channel with Carol, and a similar amount distributed across the channels connecting you to the A-squad.

And if the reason you're connected to the "A-squad' is that you've got a cheap connection to a beacon, that's centralised in that one channel. If there's multiple Carol's each batching $500 in received funds together at the end of the day, your channel balances have to scale accordingly. If you don't, you'll miss out on transactions, and hence fee income.

(So, if you need $50k across your channels (making up your $50k investment mentioned above), that's $25k on each side, and you're making $10k a year in fees, off of $5M/year in transactions (again, as above), then that means your channels are able to cover about two days' worth of discrepency -- ie if you start balanced with $25k on your side of the Alice-you channel, and the same on you-Carol, after 46 hours worth of microtransactions at $13k/day, you can't accept payments from Alice or to Carol anymore. So I think this directly relates the ROI to... fee percentage and standard deviation of payment frequency on a channel? Something like that)

*However* this is all probably a moot point: if beacons aren't used while they're in the newest cohort, then they don't particularly need to use the new channels immediately, and new anchors get safely buried anyway. Something like:

 * 1 hour (6 blocks): pretty good global consensus on who the beacons are
 * 20 hours (120 blocks): plenty of time to setup new channels
 * 3 hours (18 blocks): plenty of time for the new channels to be buried

And voila, 24 hours later, the new cohort has new channels and is ready to go active, and a new newest-cohort can be chosen.

Quoted text (17 lines)
> >> > I'm not sure if it's a realistic attack model, but if you can observe:
> >> >   Bob -> Alice: pay me $20 to R (routes to current beacons: ...)
> >> > and have control of the beacon Alice ends up using, then you can both
> >> > observe that Alice is trying to make the payment (you see an HTLC with
> >> > $20 and R), and prevent Alice from making the payment (you can just not
> >> > forward any transactions involving R).
> >> Sure.  But if you can observe the private conversation between Bob and
> >> Alice, *and* you control enough nodes that you're likely to be the
> >> beacon they choose, you don't need to be a beacon to block them :)
> > You don't have to control the nodes initially, you just have to attack
> > the beacons once they're announced. If they're accepting new channels,
> > then they've announced an IP. If you get an exploit on a node that
> > would have been #15 in the ranking, you just have to DoS three higher
> > ranked beacons to get it to have traffic.
> They're still beacons though, they're just useless.  You do need to get
> a beacon then DoS enough others to force traffic though you.  That may
> be cheaper than offering the best rates, I guess.

If a beacon stops responding to pings, it won't be able to announce fee updates, and would presumably expire. I'm assuming you'd just keep using the k best beacons you've seen recently, so that would allow new guys in as well.

It feels a lot like doing economic stimulus by randomly selecting some people, giving them a million dollars, and announcing their home addresses. Sure, it's the first story on the news, but the second is how they were found mugged and broke two hours later...

Okay it's not a million dollars, it's mmore transactions. So how's beacon profitability compare to regular nodes? Assume 100 beacons, 100k regular nodes doing forwarding, $20M/day (250k tx/s at 10c/tx), and aggregate fees of 1%/tx. Shortest path between random nodes is ~4 hops, so actual tx path is about seven intermediaries: CONSUMER-a-b-c-BEACON-e-f-g-MERCHANT. So every transaction pays 6 nodes and 1 beacon. Assuming they break the fees down evenly, beacons get 1/7th of all transactions fees; remaining nodes get 6/7th of all transaction fees. So an average beacon gets:

  1/100 * 1/7 * 1% * 20M = $285.71/day
  1/(100k-100) * 6/7 * 1% * 20M = $1.72/day

If you're talking about millions of nodes, that's another factor of 10 or more worse. If you're talking 100k nodes but 1000s of beacons instead of 100, maybe it gets better ($15-$30/day vs $2/day?), but then maybe we need to revisit the beacon related traffic calculations, because 1000 is a lot more than 12...

In reality, to me those numbers just say "it's not worth running a node if you're not a beacon", so the best strategy is to commit a few cents in pretend channels on the blockchain to buy tickets in the beacon lottery, but only start actually routing when you win. So there maybe ends up being a few thousand nodes that have direct relationships with customers to earn profits based on subscription fees, and a bunch of beacon-specialists who play the beacon lottery and run 90% of the beacons at any given time, earning profit from investment and routing.

Also, if the only routes you know are to and from beacons, it seems a bit difficult to do much in the way of "scenic" routing to make the onion routing more obscure. I'm not sure this actually matters if you have a total path length of more than six or seven though.

(TBH: at this point beacons are seeming (to me) like a clever idea, that's totally implementable, but won't actually work out at all. YMMV obviously)

Quoted text (19 lines)
> >> Yes!  I've been wondering about this kind of "donation address"
> >> scenario.  Turns out you can encode the R value in the onion routed
> >> message you send, too.  Only the final recipient can read it anyway.
> > Yep.
> >> That doesn't help with routing to the donation address; maybe we will
> >> need a best-effort DHT for that?
> >
> > If you've got a route, but no fee information; you could probe the
> > route with nanopayments. ie, to move $10 along me->A->B->C->D, first
> > try sending 0.01c to B with a 0.1% then a 0.2% fee, etc. Once you know
> > A's fee, repeat with B, then C. If the fees end up as 1%, 2% and 0.2%
> > your successful transactions are:
> >   0.01c to B plus 0.0001c to A
> >   0.01c to C plus 0.0001c to A plus 0.0002c to B
> >   0.01c to D plus 0.0001c to A plus 0.0002c to B plus 0.00002c to C
> >   $10 to D plus 10c to A plus 20c to B plus 2c to C
> > and the txs that had smaller fees just bounce back to you.
> I was assuming the "insufficient fees" message would include the latest
> route info, so it's even easier.

I was figuring it would just be a "couldn't route" message with no additional info (could be no channel, not enough fees, bad R, mistake in crypto...) -- otherwise you're kind-of unwrapping the onion (ie, C tells B, "C's fee is 1%"; B tells A "C's fee is 1%"; A says "oh, trying to send money to C, huh? how interesting!". C could encrypt the info to the symmetric key A sent C, but... seems like a lot of hassle at that point)

Quoted text (1 line)
> I was more concerned about the "there's no channel from B->C any more".

Sure. In that case you can't make the payment until they tell you new routes, or you use some other protocol for route finding. The beacons are going to change soon enough anyway, so no suggested route will work for all that long, even ignoring fee changes.

Quoted text (5 lines)
> > (If probing was the main use for nanotransactions, nodes might set higher
> > fees on them though, if they assume you've already chosen a route, and
> > they therefore don't need to compete on price with other possible routes)
> Maybe nodes will offer some kind of routing service in future.  Seems
> like it'd be a layer up though.

I kind-of think routing is actually already a layer up, and effectively sort-of pluggable. ie, you've got:

0: direct connection to someone, can establish a channe, update HTLCs

1: onion-routed packets, can be forwarded on level 0

2: route-finding

If you've got a bunch of beacon routes, that's one way of implementing level 2. If you know a whole bunch of channels, then you can do it that way. If you have an oracle you can query, that's another way. If you've got multiple different systems (some nodes don't participate in the main routing network because of persecution fears eg), with some nodes in common, you can join them up.

Quoted text (8 lines)
> > There's a corresponding thread
> > (same title) on BitcoinXT, if you really want to feel trolled.
> > There's also:
> >   /r/lightningnetwork: The Bitcoin Lightning Network
> >   This sub-reddit is dedicated to corporate interests trying to take over
> >   the decentralized world-wide ledger.
> > No posts unfortunately...
> Damn, let me fix that...

Still no posts; caught in moderation I guess?

Quoted text (3 lines)
> > ...
> OK, if we have a real offline mode for standard wallets, the distinction
> becomes real.

Without it, I guess I'm thinking of balances like:

 - $10-$20 on my phone (coffee, busfare, wifi access)
 - $100-$200 on my desktop/laptop (which I can turn off, and have more
   control over)

(Ideally, I'd rather have $200 on my phone though, replacing cash/credit for everyday purchases)

Things that can't go offline don't change of course:

 - $1-$10 for IoT devices doing micropayments
 - $10-$100 for routers/cloud computers paying for their own internet
 - $1000-$5000 for merchants doing reasonable volume
 - $1000-$100,000 for nodes operating as revenue generating investments
Quoted text (9 lines)
> > As far as privacy goes I think you could tell which of your neighbours
> > is using lightning primarily as a wallet versus trying to be a
> > profit-generating node fairly easily: wallets will have smaller channels,
> > there'll be fewer transactions over them, and they'll disconnect more
> > often. That doesn't guarantee they're not forwarding things; but if they
> > are they're almost certainly arranging it out of band anyway (even if
> > only to know when they'll be online and thus able to forward).
> I think deniability is important.  Thus I would want my wallet to
> forward payments when offered.

Sure, but I think in practice that only works if you actually forward payments; otherwise "you claim that payment was forwarded; but in the five months we've monitored you, you have not forwarded a single payment, why should the jury believe this one was special?"

If you had $1000 on your phone, and were *actually* acting like a node, and willing to be a beacon, then *that* would be totally deniable, and pretty awesome. But I think in practice technology will mean you've got some nodes acting as an investment trying to earn a ROI/profit, and other nodes acting as wallets, spending money or receiving money based on goods/services outside of lightning itself.

Quoted text (3 lines)
> > (I actually think arguing the other way might make a bit of sense; if
> > you're running a node, you should pay profits and expenses to/from an
> > entirely separate lightning wallet)

So pulling in the other mail here:

On Sun, Sep 27, 2015 at 03:12:56PM +0930, Rusty Russell wrote:

Quoted text (11 lines)
> Anthony Towns <aj at erisian.com.au> writes:
> > On Fri, Sep 25, 2015 at 11:23:42AM +0930, Rusty Russell wrote:
> >> Beacons are going to get slammed, but it's not clear how bad it is.
> >> Getting slammed from all directions doesn't use up channels; it's only
> >> computational and bandwidth limits.
> > It does actually use up channels -- if you've got 5 channels with 100 BTC
> > in them collectively in total, and you own 20 BTC of that, and collect
> > a 0.1% fee on each transaction, you'll gain 80 BTC after 80,000 BTC are
> > forwarded through you, and nobody will be able to send you funds any more.
> That's a great insight!  Fees *do* erode channels.  I had totally missed
> that.

What I'm thinking is you'd do something like:

 - node has $10,000 in channels, earns 20% a year, so around $150 a month
 - once a month, roughly, node owner has the node pay $150 from the node
   to a personal lightning wallet
 - payments for node's running costs can be made from wallet (avoiding
   hitting the blockchain)
 - the personal wallet can get pushed to the blockchain providing anchor
   transactions for new channels for the node (to reinvest the profits)

Benefits:

 - you can lock the profits in an offline wallet if you want (you only
   need to be active long enough to receive the HTLCs, and you can
   decide when to send them)
 - if you have the node, you can't trace the money to the hosting
   environment
 - node's channels are refreshed and can stay open indefinitely
 - if you hit a lucky channel that's makes $1000/month with only $100
   channel balance, you can keep that channel active forever
   (you'd have to empty profits out once a day or so though)
 - you can kind-of lock the node down, so that it will only sign
   incoming/forwarded transactions, and outgoing transactions to
   a particular wallet (probably have to limit to set of known R values
   though). you could come close to having this be just a trusted crypto
   module, and have any exploit in the rest of the system be unable to
   steal your money.

Hmm, I think that actually explains the lightning/bitcoin fee nexus a bit: lightning nodes earn x% of lightning transactions; then to reinvest this profit in lightning, they spend on the blockchain generating $f in fees for miners. It's not /spending/ the profits from lightning fees that generates fees for miners (because that could be done withing the lightning network in theory), it's /reinvesting/ them in the lightning network. (And also buying into lightning in the first place, or cashing out eventually, or rebalancing your investment)

Quoted text (9 lines)
> > (In the event that someone suggests a route beacon_X -> X -> Y -> Z to
> > get to them, and you have a path A -> C -> X -> beacon_X, you can cut out
> > the middleman and not route through a beacon at all. I don't think this
> > gives much of an improvement though. A beacon could potentially avoid
> > this from being possible by partitioning its neighbours into two sets
> > and setting incoming fees for one set prohibitively high, and outgoing
> > fees to the other set as prohibitively high; managing that dynamically
> > would be difficult but I think possible)
> But you'd risk not being used as a beacon if your fees are too high.

That's not a problem here. Say every other beacon costs 1% to route through, give or take. You have neighbours A, B, C and D. You set the following prices:

   A -> Me: 0.45%
   B -> Me: 0.45%
   Me -> A: 5.1%
   Me -> B: 5.1%
   C -> Me: 5.1%
   D -> Me: 5.1%
   Me -> C: 0.45%
   Me -> D: 0.45%

A route that goes X -> A -> Me -> C -> Y will still only pay you 0.9% so is completely competitive for transactions; but hardly anyone will ever see a route like Z -> D -> C -> Me, because Z -> W -> V -> U -> A -> Me will be cheaper despite the extra hops. That in turn means means no one will figure out that Z -> D -> C -> Y is a valid path, missing out going through me.

To make it work dynamically, you'd need to swap the channels you apply the ~5% penalty so the transaction flows balance out, but I think the general principle works.

Quoted text (4 lines)
> It
> seems to me that a beacon wants many connections, to avoid the
> "short-circuit" case.  At 100 connections, it's only 1%, though
> that's the best case which assumes they're all equally likely.

Maybe... Establishing an extra 100 connections per beacon per cohort is a fair chunk of blockchain transactions; and presumably they'll expire once the beacon stops being a beacon, rather than lasting for months/years. 500kB per cohort, maybe? At 1MB/block and a cohort per day, that's 0.3% of the blockchain already.

(Is 100 realistic, or would every node want a direct channel to a beacon, so that it would be more like 1000/beacon (100k nodes, 100 beacons) or more?)

Quoted text (2 lines)
> Good points.  If we reject all routes less than (say) 3 hops by default
> it might mean that local payments are *less* efficient.  Oops.

I was thinking, at least at this stage, that there wasn't any point differentiating local vs global payments; I'm hoping global payments are quick enough for buying a coffee anyway, and online microtransactions will probably be global anyway. And as above, I think route finding is separate enough that you can always improve it while leaving the lower layers (HTLCs and onion-forwarding) the same.

Cheers, aj

Anthony Towns in reply to Anthony Towns permalink original

On Mon, Sep 28, 2015 at 08:37:19PM +1000, Anthony Towns wrote:

Quoted text (1 line)
> Batch-replying.

Oops, I triggered my own spamassassin here. Y'all might need to pull it out of your spam folders if you want to read.

Cheers, aj

Rusty Russell in reply to Anthony Towns permalink original

Anthony Towns <aj at erisian.com.au> writes:

Quoted text (21 lines)
> Batch-replying.
>
> On Sun, Sep 27, 2015 at 01:54:45PM +0930, Rusty Russell wrote:
>> Anthony Towns <aj at erisian.com.au> writes:
>> > On Fri, Sep 25, 2015 at 09:56:02AM +0930, Rusty Russell wrote:
>> >> [ Pieter Wuille Cc'd for pubkey recovery, search for "recovered" ]
>> >> Mats Jerratsch <matsjj at gmail.com> writes:
>> >> >> Indeed.  Random selection helps, here, but analysis will be interesting.
>> >> > How have you ended up with a number of beacons you need? 12 seems so
>> >> > low, I can’t imagine so few nodes to support all transacting for even
>> >> > 10 minutes..
>> >> As we keep the last 100 sets of beacons, the load is spread a little.
>> > Does that actually work? Old beacons don't do any good if the payee
>> > doesn't use them when advertising a route; but old beacons also don't
>> > get their fee updates propogated, and aren't known by people who only
>> > just joined the network. I don't think you could usefully keep more than
>> > the last 2 or 3 sets of beacons?
>> I was thinking they all count as active.  No point turning over all the
>> beacons every block.
>
> Okay, in that case I was misled by your original description.

Did I somehow give you the impression I'm making it up as we go along? I'm so sorry, let me reinforce that now...

Quoted text (5 lines)
> You're
> actually talking about n*k beacons at any point in time, of which the
> oldest k are replaced every d days. If k=12 and n=8, that gives 96 beacons
> at any point in time. Any given beacon is operation for n*d days, for n=8,
> then d=1 gives 8 days, while d=7 gives 2 months.

Pretty much.

I was thinking there's some delay before activation (so, we have 10 blocks worth of "chosen but inactive" beacons), 100 blocks of active beacons. n beacons per block (though it may increase with <formula>).

We can play with the parameters. And we might select every N blocks if we want longer-lived beacons.

Quoted text (33 lines)
> The "d" parameter would be "consensus-critical"; I don't think it's
> possible to agree on any beacons without agreeing on d. You could vary k
> or n as the network scales though, but in that case I think it'd generally
> be easier to vary n than k?
>
> If you identify a given beacon by its cohort (from 1..n), its rank
> (1..k), its visibility (how long ago you first heard about it in
> seconds) and its currency (how recently the last route update to that
> beacon was), then I think the odds of a random other node also knowing
> about that beacon works out as:
>
>  - worse for the most recent cohort (older cohorts should have more fully
>    propogated)
>
>  - potentially worse for the very oldest cohorts
>     + if being a beacon wears you out (channels may have been used
>       up; they may have been hacked; they may have cashed out their
>       profits and bought an island)
>     + if nodes have varying settings for n, so older cohorts don't have
>       as effective route propagation
>
>  - worse for recent visibility (newly advertising beacon, that hadn't
>    fully propagated, same deal as for a new cohort)
>
>  - worse for non-recent currency (beacon might be offline, or routes to
>    that beacon might have failed)
>
>  - worse for low rank in recent cohorts (new beacons shouldn't show up
>    for old cohorts; if new beacons show up in recent cohorts, its the
>    low rank beacons that will be offloaded)
>
>  - worse for low rank in any cohort if other nodes have lower values for
>    k

In practice, more recent beacons last longer. The other effects are less clear. I'm assuming nodes remember routes to older beacons than they would actually give out to others (handwave).

Quoted text (8 lines)
> When picking beacons to advertise for accepting a payment, I think you'd
> want to take most of the above into account, to avoid only suggesting
> coincidently unreachable beacons, and having the payment fail.
>
> I don't think you could really take route price into account, since the
> real price is "consumer to beacon" plus "beacon to merchant"; and those
> could trivially be inversely related. Having 10%-30% of your suggestions
> be selected by cheapness would still be useful though.

Still the best choice, I think. Simulations welcome, but on a large network random nodes are likely to be terrible for both.

Quoted text (22 lines)
> Choosing, say, two of the cheapest beacons, and three beacons from
> cohorts 3-n with recent currency and long term visibility would probably
> work okay though.
>
> If nodes are identified by a 160b address, and it takes around 4 hops
> to get to/from a random beacon, then a route is 4*160b=80B and five
> routes as above is 400B. That's ~550 bytes with base58
> encoding by my count, or about 7 lines of 76 column text. Kinda lame:
>
> "please pay to 1ajaj31PWNVZEzd68S8PqAPof4EFbeZaf via lightning route:
> 5PSGzi9R6k6G2mdFPx2ZsfyVdiz9gSaA7EegpTvzbxLb13yMEuNuK7m1DhJuJvwkMe4BrfdU2V5q
> cKf825oYmikQMzpfAvVkavA3AyXZEgGWx9j3j5gUxMUE8LhawnfTWWSQMc2gChzKEz1puFcyveMa
> QHVdhbcJY73M4Aev7KDWqnrAYNid2keGRzDtUDfZarSsABR4RWjshCtBctekjvxYQpsBqD4NrzvV
> DCGQNNWbKibSawkt18xdPGxR3rwMwkEqU5rE8EfXmFrFaj7t2nB8DWQa1oe4QhvPe9BYsyAumJtG
> SZFmRknJ2E5feDCzYfqAu8tVcaW6yhKUgxdrxqBVfzdTBFVtt2p5PPrz4C9d3MQsrerfSHSbbX7Q
> VcUqhotinoMHX2UyfbRYX4BJgNjLqaXE33EthhF7BBmBRkP6V7EyZYrc53XtEi1ocuKNiejWcEQe
> neajEMR9rFpHHSnzSX8AXXn13TYsGirHiFG7KYu7tzg6EFEifLeAz2wxaaaMs2K6J488kxWpDy1s
> GtG3zX3v5msToo"
>
> (I 100% approve of urandom generating bytes that encoded to "aj" twice
> in the length I estimated for a route... Sure, it probably means my RNG
> is compromised and identifying me, but how sweetly personalised!)

In the future, we'll all be using the payment protocol. From our flying cars. Right?

OK, so we ahve to use a 177x177 QR code. Lucky about high-res cameras, I guess?

Quoted text (4 lines)
> If you're going to have parameters that need to be changed as things
> scale, seems useful to have them accept changes gracefully, rather than
> relying on flag days. I'm still pretty sure that k (and/or n) here work
> that way, as described.

That's true, if we think of changing the numbers over time.

I was thinking of scaling n with log2(number nodes). And we can intuit number nodes from proximity of beacons to ideal <insert smoothing and formulae here>.

Quoted text (34 lines)
>> > Since I have to update my beacon-to-me routes regularly because of fee
>> > changes, I could regularly select different groups of beacons so you
>> > could just ask again.
>> Yech... you really want this to be single pass "pay me $5, and here are
>> three routes from beacons near me".
>
> Well, so far a "route" consists of a path with fees; symbolically:
>
>  pay [MY ADDRESS] $5 via:
>    [BEACON 1] 1c [N1A] 1c [N1B] 2c [N1C] 2c [N1D] 4c [ME]
>    [BEACON 2] 2c [N2A] 1c [N1C] 2c [N1D] 4c [ME]
>    [BEACON 3] 1c [N3A] 3c [N3B] 1c [N3C] 1c [N3D] 1c [ME]
>
> So even if you keep the same set of beacons, you have to regularly
> update the route info as fees/routes change, eg:
>
>  pay [MY ADDRESS] $5 via:
>    [BEACON 1] 1c [N1A] 1c [N1B] 2c [N1C] 2c [N1D] 4c [ME]
>    [BEACON 2] 2c [N2A] 2c [N2B] 1c [ME]
>    [BEACON 3] 1c [N3A] 3c [N3B] 1c [N3C] 1c [N3D] 1c [ME]
>
>  (N2A to N2B dropped it's previously uncompetitive fee from 10c to 2c in
>   this example, nothing else changed. N1C->N2A costs 8c)
>
> Even just sitting on the "checkout" page for a minute might be long
> enough to require a new route suggestion, eg.
>
> If you're doing that anyway, might as well select a different set of
> beacons each time as well.
>
> (The only way to not have to do that (afaics) is to just say "pay [MY
> ADDRESS $5" and query the network for the route; which either means
> keeping the entire graph available for path finding, or having DHTs to
> lookup routes from beacons and fees)

Yes, we could use the DHT for routes/fees. I think it's a layer on top though.

Quoted text (18 lines)
>> But you're right makes more sense to have two-phases: an immediate one
>> after the block is broadcast where you compete (via SPV proof of some
>> tx) to be a beacon, then another closer to activation where you
>> broadcast routes.  Between those two you can expect an influx of channel
>> offers.
>
> If you've got n cohorts of beacons anyway, it seems like you'd just
> always have the newest cohort be "in setup phase". ie, they'd announce
> and compete fairly quickly (minutes or hours), and then spend some time
> getting fully setup (new channels, rebalancing), and obviously still
> forwarding any transactions that find their way to them, but everyone
> would still tend to use the more established cohorts. Then once the /next/
> cohort gets selected, it's game on.
>
> That'd just require merchants to not select the latest cohort of
> beacons when advertising routes from beacons. As far as everyone else
> is concerned, brand new beacons are fine to use as normal if they turn
> out to be the best route.

Makes sense. Selecting a new cohort every block is probably silly then, since they come too fast.

Quoted text (8 lines)
>> Interestingly, the former idea means you get some leakage of routes,
>> from nearby almost-beacons (until defeated by better beacons).
>> Remembering those might help shortcircuit some routes (if there's some
>> geographical correlation between nodes).
>
> I don't think this works: old route info also means old fee info; and
> you can only shortcircuit if the fees are actually less, which you no
> longer know.

No, you get updated fee information when your message gets bounced.

Quoted text (11 lines)
> *However* this is all probably a moot point: if beacons aren't used
> while they're in the newest cohort, then they don't particularly
> need to use the new channels immediately, and new anchors get
> safely buried anyway. Something like:
>
>  * 1 hour (6 blocks): pretty good global consensus on who the beacons are
>  * 20 hours (120 blocks): plenty of time to setup new channels
>  * 3 hours (18 blocks): plenty of time for the new channels to be buried
>
> And voila, 24 hours later, the new cohort has new channels and is ready
> to go active, and a new newest-cohort can be chosen.

I like your random formula, and shall slavishly adopt it!

Quoted text (4 lines)
> It feels a lot like doing economic stimulus by randomly selecting
> some people, giving them a million dollars, and announcing their home
> addresses. Sure, it's the first story on the news, but the second is
> how they were found mugged and broke two hours later...

It's a true Bitcoin story!

Quoted text (8 lines)
> In reality, to me those numbers just say "it's not worth running a node
> if you're not a beacon", so the best strategy is to commit a few cents in
> pretend channels on the blockchain to buy tickets in the beacon lottery,
> but only start actually routing when you win. So there maybe ends up being
> a few thousand nodes that have direct relationships with customers to
> earn profits based on subscription fees, and a bunch of beacon-specialists
> who play the beacon lottery and run 90% of the beacons at any given time,
> earning profit from investment and routing.

Perhaps the entire network becomes corrupted. But the alternatives seem to lead even faster to centralization.

Joseph suggested that to be in the lottery, your anchor tx would have to be above some amount. I resisted that as another centralization force, but perhaps we'll end up there.

Quoted text (4 lines)
> Also, if the only routes you know are to and from beacons, it seems
> a bit difficult to do much in the way of "scenic" routing to make the
> onion routing more obscure. I'm not sure this actually matters if you
> have a total path length of more than six or seven though.

Or, something added up one layer. Ask me my routes, and I will tell you?

Quoted text (2 lines)
> (TBH: at this point beacons are seeming (to me) like a clever idea, that's
> totally implementable, but won't actually work out at all. YMMV obviously)

Quite possibly. It's implementable, but not sure it's going to be robust.

Quoted text (6 lines)
> I was figuring it would just be a "couldn't route" message with no
> additional info (could be no channel, not enough fees, bad R, mistake
> in crypto...) -- otherwise you're kind-of unwrapping the onion (ie, C
> tells B, "C's fee is 1%"; B tells A "C's fee is 1%"; A says "oh, trying
> to send money to C, huh? how interesting!". C could encrypt the info to the
> symmetric key A sent C, but... seems like a lot of hassle at that point)

Yep, you have to onion up error messages. (Except timeout, that needs exposure, to prove you broke a channel).

It's not that hard to do though, since every hop has a shared secret key.

Quoted text (28 lines)
>> I was more concerned about the "there's no channel from B->C any more".
>
> Sure. In that case you can't make the payment until they tell you new
> routes, or you use some other protocol for route finding. The beacons
> are going to change soon enough anyway, so no suggested route will
> work for all that long, even ignoring fee changes.
>
>> > (If probing was the main use for nanotransactions, nodes might set higher
>> > fees on them though, if they assume you've already chosen a route, and
>> > they therefore don't need to compete on price with other possible routes)
>> Maybe nodes will offer some kind of routing service in future.  Seems
>> like it'd be a layer up though.
>
> I kind-of think routing is actually already a layer up, and effectively
> sort-of pluggable. ie, you've got:
>
>  0: direct connection to someone, can establish a channe, update HTLCs
>
>  1: onion-routed packets, can be forwarded on level 0
>
>  2: route-finding
>
> If you've got a bunch of beacon routes, that's one way of implementing
> level 2. If you know a whole bunch of channels, then you can do it that
> way. If you have an oracle you can query, that's another way. If you've
> got multiple different systems (some nodes don't participate in the
> main routing network because of persecution fears eg), with some nodes
> in common, you can join them up.

Indeed. Perhaps there's a smarter way to segment the network than global beacons though. Maybe some limit on path length?

Quoted text (8 lines)
> Hmm, I think that actually explains the lightning/bitcoin fee nexus a
> bit: lightning nodes earn x% of lightning transactions; then to reinvest
> this profit in lightning, they spend on the blockchain generating $f
> in fees for miners. It's not /spending/ the profits from lightning fees
> that generates fees for miners (because that could be done withing the
> lightning network in theory), it's /reinvesting/ them in the lightning
> network. (And also buying into lightning in the first place, or cashing
> out eventually, or rebalancing your investment)

Indeed.

Quoted text (24 lines)
> That's not a problem here. Say every other beacon costs 1% to route
> through, give or take. You have neighbours A, B, C and D. You set the
> following prices:
>
>    A -> Me: 0.45%
>    B -> Me: 0.45%
>    Me -> A: 5.1%
>    Me -> B: 5.1%
>
>    C -> Me: 5.1%
>    D -> Me: 5.1%
>    Me -> C: 0.45%
>    Me -> D: 0.45%
>
> A route that goes X -> A -> Me -> C -> Y will still only pay you 0.9%
> so is completely competitive for transactions; but hardly anyone will
> ever see a route like Z -> D -> C -> Me, because Z -> W -> V -> U -> A ->
> Me will be cheaper despite the extra hops. That in turn means means no
> one will figure out that Z -> D -> C -> Y is a valid path, missing out
> going through me.
>
> To make it work dynamically, you'd need to swap the channels you apply
> the ~5% penalty so the transaction flows balance out, but I think the
> general principle works.

Clever. I'll have to think about that more...

Quoted text (14 lines)
>> It
>> seems to me that a beacon wants many connections, to avoid the
>> "short-circuit" case.  At 100 connections, it's only 1%, though
>> that's the best case which assumes they're all equally likely.
>
> Maybe... Establishing an extra 100 connections per beacon per cohort is a
> fair chunk of blockchain transactions; and presumably they'll expire once
> the beacon stops being a beacon, rather than lasting for months/years.
> 500kB per cohort, maybe? At 1MB/block and a cohort per day, that's 0.3%
> of the blockchain already.
>
> (Is 100 realistic, or would every node want a direct channel to a beacon,
> so that it would be more like 1000/beacon (100k nodes, 100 beacons)
> or more?)

I don't know. I think that the most likely connects will be distant nodes which are also hubs. Deciding which ones to accept will be a fun problem....

Quoted text (9 lines)
>> Good points.  If we reject all routes less than (say) 3 hops by default
>> it might mean that local payments are *less* efficient.  Oops.
>
> I was thinking, at least at this stage, that there wasn't any point
> differentiating local vs global payments; I'm hoping global payments are
> quick enough for buying a coffee anyway, and online microtransactions
> will probably be global anyway. And as above, I think route finding is
> separate enough that you can always improve it while leaving the lower
> layers (HTLCs and onion-forwarding) the same.

Indeed. This conversation is about medium-to-long term. For now, everyone blasting their routes & fees on IRC is workable.

Cheers, Rusty.