Research/Bitcoin Dev Archive / lightning-dev list
Routing on the lightning network?
13 messages, Jul 3 to 18, 2015. Started by Rusty Russell.
Rusty Russell (5), CJP (5), Nick ODell, Joseph Poon, Anthony Towns
Hi all,
One of the fun open questions for LN is how routing will work. I'd like to kick off that discussion now, to see if we can create a strawman which doesn't immediately collapse.
Assumptions: 1. I'm assuming each node is known by its pubkey.
2. Source routing seems the easiest route; best for privacy, best for any tradeoffs between reliability/price etc.
3. We should do onion routing: each node knows the source and next step. This is not perfect: R values trivially identifies connections (if you own two nodes on the path, you can connect them), and the timeout implies a minimum TTL.
4. A recipient gives the payer 100 routes from some nodes to them. The payer hopefully can route to one of the mentioned nodes (probably the cheapest). This also means that if the payer has to do some route query it doesn't trivially reveal who the recipient is.
Route broadcast is more fun. It's not like BGP where you have useful subnets; even if you did, you need the pubkey of every node.
My original idea was a subset of hubs (a few thousand?) to which you would connect: that makes full discovery routing fairly easy within that network, and you report your address as "client XXXXX via hub <pubkey>". Your hub(s) keep the routing tables, you just query them mostly.
A more ambitious idea would be to select N "beacons" based on the block hash which every node figures out their best routes to/from. That's actually really efficient for broadcasting: you can guess whether a node is a likely beacon based on previous results, and only broadcast likely winners. It also means each node only has to remember N * 144 routes each way if we want beacons to expire after a day.
But could also result in the beacons (and their neighbors) getting slammed. Maybe beacons only become usable after 10 blocks, so they have a chance to boost their connections in preparation? I'd have to simulate it...
Joseph also pointed out that the anchor transactions in the blockchain imply the network topology. That's kind of cool, but I'll let him explore that.
Cheers, Rusty
The routing design has important implications for privacy, but also for the enforcement of regulations on the Lightning network.
Imagine, for instance, that a couple of large nodes start requiring their neighbors to provide identity information (KYC-style regulation), and then require them to recursively provide identity information for all their neighbors' neighbors, and so on. If it is visible to intermediate nodes which other nodes participate in a transaction, this would cause the Lightning network to split into a regulated and a non-regulated part: nobody would dare to interface between the two, since that would prove to the regulated side that they illegally provide connectivity on the non-regulated side.
So, I don't want nodes to explicitly know the shape of the entire network. Based on how Wikipedia explains source routing to me, I think it is incompatible with what I want. Please also note that IP almost never uses source routing.
Also, as a counter-measure against censorship (or persecution) based on destination address, I think the function of "destination address of a route" should be de-coupled from the function of "payer endpoint" or "payee endpoint" of a route. In many cases, the "payer endpoint" or especially the "payee endpoint" will also fulfill the role of "destination address", but they may also choose a neutral "meeting point" node in the middle, and both route towards its address. This will allow nodes to secretly interface between regulated and non-regulated parts of the network, for transactions going in both directions.
The time-out value is a bit of a problem in this concept, since it is an indication of the number of hops from the payee endpoint. However, if nodes are free to choose the time-out increment for themselves, they could choose to make that increment smaller, to be able to route through a node that provides an interface to the regulated part.
An additional advantage of separating destination addresses from the payment endpoints is that routing tables can be much smaller. Most consumers, and a lot of small shops can choose not to have their own destination address, but instead route through the destination address of their Lightning provider (a bit like a NAT router's IP address).
In my view, routing tables are a sort of a heuristic, that tells you how likely a payment (of a certain amount!) to/from a certain destination address is to succeed on one of your interfaces. It is an optimization over the dumb algorithm of simply trying out all your interfaces one by one(*). It is TBD how to determine these heuristics, and how to exchange them between nodes.
This is probably quite different from how routing on the Internet works, and I'm not sure how it will scale and how it can be defended against DoS attacks, but it sort of follows automatically from the desire to keep the network free.
CJP
(*) Which is currently the only routing method implemented in Amiko Pay.
Rusty Russell schreef op vr 03-07-2015 om 11:40 [+0930]:
Quoted text (48 lines)
> Hi all, > > One of the fun open questions for LN is how routing will work. > I'd like to kick off that discussion now, to see if we can create a > strawman which doesn't immediately collapse. > > Assumptions: > 1. I'm assuming each node is known by its pubkey. > > 2. Source routing seems the easiest route; best for privacy, best for > any tradeoffs between reliability/price etc. > > 3. We should do onion routing: each node knows the source and next step. > This is not perfect: R values trivially identifies connections (if > you own two nodes on the path, you can connect them), and the timeout > implies a minimum TTL. > > 4. A recipient gives the payer 100 routes from some nodes to them. The > payer hopefully can route to one of the mentioned nodes (probably the > cheapest). This also means that if the payer has to do some route > query it doesn't trivially reveal who the recipient is. > > Route broadcast is more fun. It's not like BGP where you have useful > subnets; even if you did, you need the pubkey of every node. > > My original idea was a subset of hubs (a few thousand?) to which you > would connect: that makes full discovery routing fairly easy within that > network, and you report your address as "client XXXXX via hub <pubkey>". > Your hub(s) keep the routing tables, you just query them mostly. > > A more ambitious idea would be to select N "beacons" based on the block > hash which every node figures out their best routes to/from. That's > actually really efficient for broadcasting: you can guess whether a node > is a likely beacon based on previous results, and only broadcast likely > winners. It also means each node only has to remember N * 144 routes > each way if we want beacons to expire after a day. > > But could also result in the beacons (and their neighbors) getting > slammed. Maybe beacons only become usable after 10 blocks, so they have > a chance to boost their connections in preparation? I'd have to > simulate it... > > Joseph also pointed out that the anchor transactions in the blockchain > imply the network topology. That's kind of cool, but I'll let him > explore that. > > Cheers, > Rusty
CJP <cjp at ultimatestunts.nl> writes:
Quoted text (2 lines)
> The routing design has important implications for privacy, but also for > the enforcement of regulations on the Lightning network.
Hi CJP! I was hoping you'd weigh in here, thanks!
Quoted text (14 lines)
> Imagine, for instance, that a couple of large nodes start requiring > their neighbors to provide identity information (KYC-style regulation), > and then require them to recursively provide identity information for > all their neighbors' neighbors, and so on. If it is visible to > intermediate nodes which other nodes participate in a transaction, this > would cause the Lightning network to split into a regulated and a > non-regulated part: nobody would dare to interface between the two, > since that would prove to the regulated side that they illegally provide > connectivity on the non-regulated side. > > So, I don't want nodes to explicitly know the shape of the entire > network. Based on how Wikipedia explains source routing to me, I think > it is incompatible with what I want. Please also note that IP almost > never uses source routing.
Total agreement. The network must be robust against censorship/partition for good technical reasons as well as malice. People will also rightfully expect a caching layer for bitcoin to have the same open-membership properties that bitcoin has.
Quoted text (9 lines)
> Also, as a counter-measure against censorship (or persecution) based on > destination address, I think the function of "destination address of a > route" should be de-coupled from the function of "payer endpoint" or > "payee endpoint" of a route. In many cases, the "payer endpoint" or > especially the "payee endpoint" will also fulfill the role of > "destination address", but they may also choose a neutral "meeting > point" node in the middle, and both route towards its address. This will > allow nodes to secretly interface between regulated and non-regulated > parts of the network, for transactions going in both directions.
OK, so this is why I proposed an onion routing system.
Basically: each node sees the next hop, the R hash, the amount, the timeout, the fee being offered. It doesn't see the source, nor the final destination.
This, however, requires source routing.
Quoted text (11 lines)
> The time-out value is a bit of a problem in this concept, since it is an > indication of the number of hops from the payee endpoint. However, if > nodes are free to choose the time-out increment for themselves, they > could choose to make that increment smaller, to be able to route through > a node that provides an interface to the regulated part. > > An additional advantage of separating destination addresses from the > payment endpoints is that routing tables can be much smaller. Most > consumers, and a lot of small shops can choose not to have their own > destination address, but instead route through the destination address > of their Lightning provider (a bit like a NAT router's IP address).
This was close to my original mental model: several thousand hubs, most people as clients. But this risks becoming centralized, which directly leads to the problem of censorship. You would simply blacklist certain providers, or whitelist the ones you approve of.
So Joseph pushed my thinkoing in a radically more decentralized direction, but routing becomes a *much* harder problem.
Anyway, I think it makes sense to support this in the protocol by adding an opaque destination token. This could distinguish separate payments or separate clients. Some nodes may well support transparent forwarding of these to other nodes.
Quoted text (11 lines)
> In my view, routing tables are a sort of a heuristic, that tells you how > likely a payment (of a certain amount!) to/from a certain destination > address is to succeed on one of your interfaces. It is an optimization > over the dumb algorithm of simply trying out all your interfaces one by > one(*). It is TBD how to determine these heuristics, and how to exchange > them between nodes. > > This is probably quite different from how routing on the Internet works, > and I'm not sure how it will scale and how it can be defended against > DoS attacks, but it sort of follows automatically from the desire to > keep the network free.
Yep, spray-and-pray is always a good starting point! But it definitely won't scale, so I'd like to make sure we don't paint ourselves into a corner (even if that's our first cut).
Fees are a real issue. Without source routing the client is guessing how much fees will be, and there'll be a lot of gaming to decide how much of the pie to take (take too much, you get none as payment fails to route). I think you'll end up asking your provider how you should to pay, and that's a pretty horrible model for privacy.
With source routing and onion it's a little better; you can explicitly state what each hop gets. Of course, if your route/payment information is out of date you lose, too.
In summary:
1) Each-hop routing:
- Final destination hub is revealed to all nodes.
- May be forwarded, though.
- Source may be revealed to all nodes?
- Fees are tricky.
- Too low will fail
- How to estimate?
- Adaptable to changing network conditions
- Intermediary nodes can reroute.
- End clients need not know anything.
2) Source routing:
- Neither final source nor dest revealed to intermediary nodes.
- Fees are known in advance.
- Requires retransmission from source if routes change.
- End clients need routing/fee information.
- Allows selection of nodes from source
- May let you avoid bad/tracking/unreliable nodes?
Is there anything I missed?
Cheers, Rusty.
Quoted text (7 lines)
> OK, so this is why I proposed an onion routing system. > > Basically: each node sees the next hop, the R hash, the amount, the > timeout, the fee being offered. It doesn't see the source, nor the > final destination. > > This, however, requires source routing.
Ah, now I understand a bit better what you mean with onion routing. Yes, that requires source routing, and it is another way of anonymizing the route. A disadvantage of this approach is that it requires the source of a route (so basically everyone) to know the shape of the network (who is connected to who), which is a privacy disadvantage. This is not necessary in TOR, since in TOR, every node can (usually) connect to every other node, so finding a route is trivial.
At the risk of making things too complicated: it is possible to combine both concepts in a single design. Source routing just requires the protocol to be able to carry arbitrary payload data to the next waypoint, so that the waypoint (which is supposed to understand the arbitrary payload data) can determine how the route should be continued. It's perfectly fine if the final waypoint of the route is a "neutral meeting point" somewhere in the middle, as in my concept. In-between waypoints, routers are free to use non-source routing, as long as the waypoints can report with reasonable accuracy which other waypoints are reachable, so that other nodes know the high-level shape of the network for use in their source routing.
I don't see the "several thousand hubs" model as more sensitive to centralization/censorship than other routing models, as long as there is no barrier to creating your own hub and to start using new hubs. Any routing model has routable addresses and risks addresses being censored by a part of the network.
There is one other attack mode I see, which is independent of the routing method: a powerful attacker (read: government) could be monitoring transactions on several "regulated" nodes. It could also gain the ability, every once in a while, to initiate transactions from an "illegal" node that should have been censored (e.g. by physical access to its hardware). If such transactions are routed over "regulated" nodes, it would immediately recognize this, because the transaction hash would be the same. The attacker can then identify the node that allows "illegal" transactions to enter the regulated network, and punish it. Even if we find a way to somehow use a different hash on every hop of a transaction, it can still do this based on the exact payment amount, or based on timing. I don't see right now how this attack mode can be eliminated; maybe it should be accepted as a risk inherent in the design of the network. Let's hope that the freedom-loving part of the network will always be so large that censorship-loving parts will just hurt themselves by isolating themselves.
Quoted text (5 lines)
> In summary: > > 1) Each-hop routing: > - Final destination hub is revealed to all nodes. > - May be forwarded, though.
Yes, may be forwarded, as in the "hybrid design" I described here. Also, bi-directional routing towards a meeting point in the middle doesn't reveal the final destination of the route as a whole.
Quoted text (1 line)
> - Source may be revealed to all nodes?
Not necessary. You just need to keep the route open for a while, so that messages towards the source can follow it back.
Quoted text (3 lines)
> - Fees are tricky. > - Too low will fail > - How to estimate?
I'll make another reply about fees; that's a whole subject on its own.
Quoted text (11 lines)
> - Adaptable to changing network conditions > - Intermediary nodes can reroute. > - End clients need not know anything. > > 2) Source routing: > - Neither final source nor dest revealed to intermediary nodes. > - Fees are known in advance. > - Requires retransmission from source if routes change. > - End clients need routing/fee information. > - Allows selection of nodes from source > - May let you avoid bad/tracking/unreliable nodes?
CJP
Quoted text (9 lines)
> Fees are a real issue. Without source routing the client is guessing > how much fees will be, and there'll be a lot of gaming to decide how > much of the pie to take (take too much, you get none as payment fails to > route). I think you'll end up asking your provider how you should to > pay, and that's a pretty horrible model for privacy. > > With source routing and onion it's a little better; you can explicitly > state what each hop gets. Of course, if your route/payment information > is out of date you lose, too.
I like to think of fees in the same way as we pay for Internet access. Every physical hop in the Internet has related costs, e.g. in placing the cables and upgrading the cables when new technology becomes available and when demand grows. Yet it doesn't matter for your Internet bill how many hops your packets make, or which route they follow. Your ISP will just average out all the costs it has to make on its interfaces, and present a fraction of that to each customer. At some points in the middle between providers, there are places where both sides have an equal interest in maintaining their link, and no fees are charged.
One major difference with the Internet is that we already have a micro-transaction infrastructure in place, which is something the Internet has never had (until now). This means it is possible to do instant per-transaction payment of transaction fees. The fact that we CAN do it doesn't mean we SHOULD, but I think there are advantages: non-immediate payment models always require some form of trust from at least one of the sides. Immediate payment of a transaction fee is as simple as updating the micro-transaction channel with a slightly larger amount than the to-be-forwarded transaction amount.
An interesting question is whether nodes will be prepared to forward payments at a net loss (the to-be-paid fee is higher than the to-be-received fee); maybe they will, if they can compensate the losses with higher profits on other transactions. Fee differences could play a role in routing decisions.
That brings me to another point: fees could be used as a way to incentivize people to bring channels back to equilibrium. When a channel's funds are almost fully assigned to one of its sides, further payments towards that side become nearly impossible. Increasing fees in that direction and decreasing fees in the opposite direction should incentivize people to perform more transactions that bring the channel back to equilibrium, and to perform less transactions that bring it further out of equilibrium, or find alternative routes for those transactions.
You could even offer negative fees for transactions that bring a channel back to equilibrium. There could be a market for people making money from bringing other peoples' channels back to equilibrium. This would require either to step away from "net neutrality" (so, not the same fee for every route / destination), or it would require some form of source routing and explicitly setting the fees of intermediate nodes.
My "neutral meeting point" routing design, which is effectively a two-hop source routing, is already good enough: a node in the middle of the network is advertising that it can benefit from a negative fee, and it invites people to perform transactions and to share the profit. It creates two routable addresses (one for the negative-fee interface (A) and one for all other interfaces (B)). Other people can then perform a payment-to-self, with payee side routing to A and payer-side routing to B. Payee-side can then have a larger payment amount than payer-side, as agreed with the meeting point, to transfer a part of the profit to the person performing the transaction.
CJP
Quoted text (4 lines)
>I like to think of fees in the same way as we pay for Internet access. >Every physical hop in the Internet has related costs, e.g. in placing >the cables and upgrading the cables when new technology becomes >available and when demand grows.
What sort of fee would this be? A percentage fee? A per-transaction fee? Both?
I can see a compelling case for any of the three.
On Tue, Jul 14, 2015 at 12:54 PM, CJP <cjp at ultimatestunts.nl> wrote:
Quoted text (73 lines)
> >> Fees are a real issue. Without source routing the client is guessing >> how much fees will be, and there'll be a lot of gaming to decide how >> much of the pie to take (take too much, you get none as payment fails to >> route). I think you'll end up asking your provider how you should to >> pay, and that's a pretty horrible model for privacy. >> >> With source routing and onion it's a little better; you can explicitly >> state what each hop gets. Of course, if your route/payment information >> is out of date you lose, too. > > I like to think of fees in the same way as we pay for Internet access. > Every physical hop in the Internet has related costs, e.g. in placing > the cables and upgrading the cables when new technology becomes > available and when demand grows. Yet it doesn't matter for your Internet > bill how many hops your packets make, or which route they follow. Your > ISP will just average out all the costs it has to make on its > interfaces, and present a fraction of that to each customer. At some > points in the middle between providers, there are places where both > sides have an equal interest in maintaining their link, and no fees are > charged. > > One major difference with the Internet is that we already have a > micro-transaction infrastructure in place, which is something the > Internet has never had (until now). This means it is possible to do > instant per-transaction payment of transaction fees. The fact that we > CAN do it doesn't mean we SHOULD, but I think there are advantages: > non-immediate payment models always require some form of trust from at > least one of the sides. Immediate payment of a transaction fee is as > simple as updating the micro-transaction channel with a slightly larger > amount than the to-be-forwarded transaction amount. > > An interesting question is whether nodes will be prepared to forward > payments at a net loss (the to-be-paid fee is higher than the > to-be-received fee); maybe they will, if they can compensate the losses > with higher profits on other transactions. Fee differences could play a > role in routing decisions. > > That brings me to another point: fees could be used as a way to > incentivize people to bring channels back to equilibrium. When a > channel's funds are almost fully assigned to one of its sides, further > payments towards that side become nearly impossible. Increasing fees in > that direction and decreasing fees in the opposite direction should > incentivize people to perform more transactions that bring the channel > back to equilibrium, and to perform less transactions that bring it > further out of equilibrium, or find alternative routes for those > transactions. > > You could even offer negative fees for transactions that bring a channel > back to equilibrium. There could be a market for people making money > from bringing other peoples' channels back to equilibrium. This would > require either to step away from "net neutrality" (so, not the same fee > for every route / destination), or it would require some form of source > routing and explicitly setting the fees of intermediate nodes. > > My "neutral meeting point" routing design, which is effectively a > two-hop source routing, is already good enough: a node in the middle of > the network is advertising that it can benefit from a negative fee, and > it invites people to perform transactions and to share the profit. It > creates two routable addresses (one for the negative-fee interface (A) > and one for all other interfaces (B)). Other people can then perform a > payment-to-self, with payee side routing to A and payer-side routing to > B. Payee-side can then have a larger payment amount than payer-side, as > agreed with the meeting point, to transfer a part of the profit to the > person performing the transaction. > > CJP > > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev
CJP <cjp at ultimatestunts.nl> writes:
Quoted text (28 lines)
> Rusty Russell <rusty at rustcorp.com.au> wrote: >> OK, so this is why I proposed an onion routing system. >> >> Basically: each node sees the next hop, the R hash, the amount, the >> timeout, the fee being offered. It doesn't see the source, nor the >> final destination. >> >> This, however, requires source routing. > > Ah, now I understand a bit better what you mean with onion routing. Yes, > that requires source routing, and it is another way of anonymizing the > route. A disadvantage of this approach is that it requires the source of > a route (so basically everyone) to know the shape of the network (who is > connected to who), which is a privacy disadvantage. This is not > necessary in TOR, since in TOR, every node can (usually) connect to > every other node, so finding a route is trivial. > > At the risk of making things too complicated: it is possible to combine > both concepts in a single design. Source routing just requires the > protocol to be able to carry arbitrary payload data to the next > waypoint, so that the waypoint (which is supposed to understand the > arbitrary payload data) can determine how the route should be continued. > It's perfectly fine if the final waypoint of the route is a "neutral > meeting point" somewhere in the middle, as in my concept. In-between > waypoints, routers are free to use non-source routing, as long as the > waypoints can report with reasonable accuracy which other waypoints are > reachable, so that other nodes know the high-level shape of the network > for use in their source routing.
It does follow logically: the node is given the next hop, the fee the transaction is prepared to pay there, and the time delta (eg. there must be 3 days left on the HTLC at that point).
If it's expressed that way, there's no reason that "next hop" need be adjacent, right?
Quoted text (5 lines)
> I don't see the "several thousand hubs" model as more sensitive to > centralization/censorship than other routing models, as long as there is > no barrier to creating your own hub and to start using new hubs. Any > routing model has routable addresses and risks addresses being censored > by a part of the network.
My concern is mainly that if we design something which doesn't scale, nodes will be forced to insert barriers to newcomers for their own preservation. Thus my preference to design in terms of millions, not thousands, if that makes sense.
Quoted text (16 lines)
> There is one other attack mode I see, which is independent of the > routing method: a powerful attacker (read: government) could be > monitoring transactions on several "regulated" nodes. It could also gain > the ability, every once in a while, to initiate transactions from an > "illegal" node that should have been censored (e.g. by physical access > to its hardware). If such transactions are routed over "regulated" > nodes, it would immediately recognize this, because the transaction hash > would be the same. The attacker can then identify the node that allows > "illegal" transactions to enter the regulated network, and punish it. > Even if we find a way to somehow use a different hash on every hop of a > transaction, it can still do this based on the exact payment amount, or > based on timing. I don't see right now how this attack mode can be > eliminated; maybe it should be accepted as a risk inherent in the design > of the network. Let's hope that the freedom-loving part of the network > will always be so large that censorship-loving parts will just hurt > themselves by isolating themselves.
Yes, indeed.
Cheers, Rusty.
CJP <cjp at ultimatestunts.nl> writes:
Quoted text (30 lines)
>> Fees are a real issue. Without source routing the client is guessing >> how much fees will be, and there'll be a lot of gaming to decide how >> much of the pie to take (take too much, you get none as payment fails to >> route). I think you'll end up asking your provider how you should to >> pay, and that's a pretty horrible model for privacy. >> >> With source routing and onion it's a little better; you can explicitly >> state what each hop gets. Of course, if your route/payment information >> is out of date you lose, too. > > I like to think of fees in the same way as we pay for Internet access. > Every physical hop in the Internet has related costs, e.g. in placing > the cables and upgrading the cables when new technology becomes > available and when demand grows. Yet it doesn't matter for your Internet > bill how many hops your packets make, or which route they follow. Your > ISP will just average out all the costs it has to make on its > interfaces, and present a fraction of that to each customer. At some > points in the middle between providers, there are places where both > sides have an equal interest in maintaining their link, and no fees are > charged. > > One major difference with the Internet is that we already have a > micro-transaction infrastructure in place, which is something the > Internet has never had (until now). This means it is possible to do > instant per-transaction payment of transaction fees. The fact that we > CAN do it doesn't mean we SHOULD, but I think there are advantages: > non-immediate payment models always require some form of trust from at > least one of the sides. Immediate payment of a transaction fee is as > simple as updating the micro-transaction channel with a slightly larger > amount than the to-be-forwarded transaction amount.
Yes, it's a great question! The resource which is used up is not so much CPU and bandwidth, it's the channel capacity and the security risk involved with having bitcoin in a hot wallet. Both these costs scale with the size of payment, making a "pay per satoshi" model seem reasonable.
I'm concerned that if we don't take a reasonable stab at monetization, it's another centralization pressure: the only nodes become those who have a second income source, such as selling your data or providing service only to (paying) registered businesses.
Quoted text (22 lines)
> An interesting question is whether nodes will be prepared to forward > payments at a net loss (the to-be-paid fee is higher than the > to-be-received fee); maybe they will, if they can compensate the losses > with higher profits on other transactions. Fee differences could play a > role in routing decisions. > > That brings me to another point: fees could be used as a way to > incentivize people to bring channels back to equilibrium. When a > channel's funds are almost fully assigned to one of its sides, further > payments towards that side become nearly impossible. Increasing fees in > that direction and decreasing fees in the opposite direction should > incentivize people to perform more transactions that bring the channel > back to equilibrium, and to perform less transactions that bring it > further out of equilibrium, or find alternative routes for those > transactions. > > You could even offer negative fees for transactions that bring a channel > back to equilibrium. There could be a market for people making money > from bringing other peoples' channels back to equilibrium. This would > require either to step away from "net neutrality" (so, not the same fee > for every route / destination), or it would require some form of source > routing and explicitly setting the fees of intermediate nodes.
Yes, this was suggested to me by Joseph Poon in a face-to-face conversation we had in San Francisco. It kind of blew my mind, actually. The fact that you discovered it too provides fairly convincing proof that you're smarter than me :)
eg. He suggested your client would initially connect to 5 random hubs. It would then occasionally route payments back to itself, where doing so was profitable or even neutral. If every client did this, it could provide significant liquidity.
Quoted text (10 lines)
> My "neutral meeting point" routing design, which is effectively a > two-hop source routing, is already good enough: a node in the middle of > the network is advertising that it can benefit from a negative fee, and > it invites people to perform transactions and to share the profit. It > creates two routable addresses (one for the negative-fee interface (A) > and one for all other interfaces (B)). Other people can then perform a > payment-to-self, with payee side routing to A and payer-side routing to > B. Payee-side can then have a larger payment amount than payer-side, as > agreed with the meeting point, to transfer a part of the profit to the > person performing the transaction.
(Sorry, a bit of a brain dump follows!)
I think negative fees fall out naturally from a route description which includes fees (eg. A->B costs Xa + Ya-per-satoshi, B->A costs Xb + Yb-per-satoshi). Naturally they need constraints (ie. don't bother sending me 1BTC, my channel isn't that big).
There's going to be a real problem here with minimizing route flap. Spamming the network every time pricing changes due to another HTLC is not going to work, and could even undermine privacy by revealing amounts.
A time-based model may work, but we'd need some serious modelling. eg. "My fee will decrease by 0.1 satoshi per byte per second until you hear otherwise".
WRT fee payment: The simplest fee method involves skimming an amount from the HTLC. That only works if the HTLC succeeds! On the other hand, if you pay each node up-front, it has no incentive to deliver. And stalled payments are the greatest cost to a node (tying up capital for days, potentially).
It seems the ideal payment calculation would be in satoshi-seconds (how much capital you used, for how long).
Perhaps we can rig something that requires the recipient to pay more according to time?
Joseph?
Cheers, Rusty.
On Wed, Jul 15, 2015 at 11:51:06AM +0930, Rusty Russell wrote:
Quoted text (4 lines)
> Perhaps we can rig something that requires the recipient to pay more > according to time? > > Joseph?
It's definitely possible, depends on what kind of complexity you're comfortable with. I think Tadge brought up the idea a long time ago about using the timelock for decay of payments with one's counterparty for on-chain enforceability. E.g. A current Commitment has 50 sub-commitments which pay out different lightning fee values with later locktimes.
Presume an HTLC has a 0.09 value with 0.01 allocated to fees (refunds back to Alice any extra fees). If we are currently at Commitment #123, we have Commitment123_1, Commitment123_2, and Commitment123_3. Each have very similar payouts, with very minor differences in HTLC fees paid and the locktime.
Assuming some kind of full on-chain Replace-By-Fee, you can prioritize Commitment123_3 over Commitment123_2 on-chain, but Commitment123_3 will also have a higher fee on lightning as well. However, Commitment123_3 can only be broadcast at a later date, so "earlier" Commitment123 values can be valid. Things can get a little wonky at the edges, so you have to arrange the fees such that if there's some time asynchronousness along the chain, that intermediary nodes don't lose out (functionally I think this means the time-decay will be somewhat marginal and be a small percentage of the total lightning fees paid).
Quoted text (11 lines)
> > You could even offer negative fees for transactions that bring a channel > > back to equilibrium. There could be a market for people making money > > from bringing other peoples' channels back to equilibrium. This would > > require either to step away from "net neutrality" (so, not the same fee > > for every route / destination), or it would require some form of source > > routing and explicitly setting the fees of intermediate nodes. > > Yes, this was suggested to me by Joseph Poon in a face-to-face > conversation we had in San Francisco. It kind of blew my mind, > actually. The fact that you discovered it too provides fairly > convincing proof that you're smarter than me :)
Maybe :), but I'm not sure I invented it myself. I had a talk about Amiko Pay at the Bitcoinference in Amsterdam, and someone in the audience actually came up with this idea. I vaguely remember I was already playing with the idea at that time, but I'm not really sure.
CJP
Nick ODell schreef op di 14-07-2015 om 18:29 [-0600]:
Quoted text (8 lines)
> >I like to think of fees in the same way as we pay for Internet access. > >Every physical hop in the Internet has related costs, e.g. in placing > >the cables and upgrading the cables when new technology becomes > >available and when demand grows. > > What sort of fee would this be? A percentage fee? A per-transaction fee? Both? > > I can see a compelling case for any of the three.
Rusty has argued for a fee that scales with Satoshi-seconds, so the to-be-transferred amount times the amount of time it takes to finish the transaction. The reason for that would be because then the fee scales with the actual scarce good you're consuming (the ability to lock a certain amount of funds for a certain amount of time on a channel is the thing that's scarce).
Personally, I'd like to keep participants as free as possible in choosing the right fee structure; the technology platform shouldn't stand in the way. Virtually any fee structure is possible anyway, as long as some trust exists between two sides of a link, but in order to make fees trust-free, some fee structures require special features from the underlying technology. Per-transaction fees that can be determined in advance are easy to do, but e.g. the Satoshi-seconds structure is something that requires an extension of the micro-transaction channel design.
CJP
On 8 July 2015 at 10:21, Rusty Russell <rusty at rustcorp.com.au> wrote:
Quoted text (4 lines)
> 1) Each-hop routing: > 2) Source routing: > Is there anything I missed? >
"Por que no los dos?"
If you have source routing from alice to bob to carol to dave, with specified fees for each hop, why should that preclude bob deciding to route to carol via eliza and frank (and sharing the hop's fee correspondingly)? Then "each-hop" routing falls out as the special case where you specify source routing directly from your hub to the final destination.
3) Extensible source-routing
- client chooses how many layers are required (fees, reliability vs
anonymity)
- at any point, holder of transaction may extend the route by adding
intermediary hops (optimise fees, channels, hub/hub balances, etc)
Pros:
- only hop endpoints are visible at any step
- adaptable to changing network conditions
- source can be anonymous to destination, source and destination
anonymous to intermediaries
- clients need minimal info (ability to estimate fees, info on hub
reputation for anonymising)
Cons:
- does not let you avoid nodes
+ (NSA sets up a hub with negative fees in every direction, hubs
reroute everything though it to bump their fees)
- how to work out fees?
- how to figure out how to route to other hubs you don't want to have a
direct channel with?
I think the latter two points have to be solved with some sort of global (but not necessarily complete) routing announcement service, so you can query who has channels and do cheapest path finding amongst them; clients/leaf-nodes so they can estimate fees, hubs so they can do routing, optimise fees, and work out profitable new channels to connect. Maybe that can be derived from transactions on the blockchain though? But that's already in the lightning paper.
I think a routed "transaction" looks something like:
To: Bob - Here's 200 satoshi from Alice locked with R - You need to send 195 satoshi to Carol with message X, who will unlock R.
So extending the route would just be Bob making a new transaction:
To: Dave: - Here's 198 satoshi from Bob locked with R - You need to send 195 satoshi to Carol with message X, who will unlock R.
which seems plausible -- though I haven't checked it against the actual protocol so maybe it fails in the details... If it's okay, then maliciously routing to /dev/null just means R never gets revealed, no one gets paid, and the transaction eventually is considered refunded/cancelled; and if it does get where it's going the only consequence versus going directly is it takes a little longer and Bob loses some fees.
Speaking of fees, I wonder if the "fee proportional to satoshi-hours" is backwards -- rather than saying "the intermediary wants to charge for how long finalisation takes", couldn't you just say "the sender is willing to pay inversely to how long finalisation takes" in every case?
If I'm an intermediary, that works out as me being offered (F - k * t) satoshi to deliver X satoshi within t seconds, for some F and k, then if I want to take a cut of X*t*r to cover my costs, that just looks like me onsending X satoshi plus a fee of up to (F - k * t - X*t*r) = (F - (k+X*r) * t). If you can arrange that fee structure technically, a successful transaction means everyone has an incentive to close the txn ASAP (including the final recipient who receives the leftover fee as a time-sensitive bonus). In that case you just want to choose r based on your available funds in both directions, making it expensive when you're over-committed, and potentially offering refunds (r<0) when you're unbalanced.
I think it's possible to cancel an unroutable transaction so that the funds can be reused (by effectively routing back to the sender?); if it is, nominating a smaller but still time-sensitive fee to have that happen sooner rather than later might be good too. That could also be used to implement a fee-enforced TTL; if the success fee is characterised by (F_1, k_1) and the failure fee is (F_2, k_2), with F_1 > F_2 and k_1 > k_2 then failing becomes more profitable than succeeding at t > (F_1-F_2) / (k_1-k_2). (F_2 > F_1, failing is immediately better than succeeding; k_2 > k_1, failing never become a better option; when passing on fees, probably would be clever to keep that time roughly constant, which is admittedly straight-forward). That might be useful if you want the protocol to have long timeouts for safety, but you want short timeouts in practice for responsiveness.
Offering an insufficient fee seems like it would easily render a transaction unroutable; if one of the hubs is on a satellite or floating platform for anonymity purposes, it might want massively high fees; if onion routing is in place, this may only be discoverable mid-way through the routing.
If you structure the transaction as "<Bob> here's <N-K*t> satoshi, locked with <R> to be revealed by <Carol> once you deliver <M> and as many of those satoshi as possible to her" with the actual payment Carol's expecting not encoded anywhere other than (encrypted) in M, then if Bob tries taking more fees than needed, he increases the risk Carol won't unlock R and he'll get nothing.
I don't quite see how channels can be safely used for independent concurrent transactions though. If I (Bob) have an idle channel to Carol for 100k satoshi, and I want to route 100 satoshi on behalf of Alice to Dave (locked to R_1), and 200 satoshi from Anna to Doug (locked to R_2) and 150 satoshi from Amelia to Drew through that channel simultaneously, how do I sign things given that any combination of those transactions could fail, breaking the potential "chain"? There's 7 scenarios that could happen then, do I need to send potential transactions for all of them to Carol?
CHANNEL -> [a] Bob 999,900 | Carol + R_1 100
CHANNEL -> [b] Bob 999,800 | Carol + R_2 200
[a] -> [c] Bob 999,700 | Carol + R_2 200
CHANNEL -> [_] Bob 999,850 | Carol + R_3 150
[a] -> [_] Bob 999,750 | Carol + R_3 150
[b] -> [_] Bob 999,650 | Carol + R_3 150
[c] -> [_] Bob 999,550 | Carol + R_3 150
If you can't have concurrent independent txns on a channel, then it seems like you want /really/ short timeouts (seconds not days) to keep things flowing -- your txn doesn't block just the satoshis its spending, it blocks /all/ the unspent satoshis in the channel...
Cheers, aj (hoping the above is adding to the discussion)
Anthony Towns <aj at erisian.com.au> writes:
Quoted text (14 lines)
> On 8 July 2015 at 10:21, Rusty Russell <rusty at rustcorp.com.au> wrote: > >> 1) Each-hop routing: >> 2) Source routing: >> Is there anything I missed? >> > > "Por que no los dos?" > > If you have source routing from alice to bob to carol to dave, with > specified fees for each hop, why should that preclude bob deciding to route > to carol via eliza and frank (and sharing the hop's fee correspondingly)? > Then "each-hop" routing falls out as the special case where you specify > source routing directly from your hub to the final destination.
Si! As I said in a followup to CJP:
It does follow logically: the node is given the next hop, the fee the
transaction is prepared to pay there, and the time delta (eg. there must
be 3 days left on the HTLC at that point).
If it's expressed that way, there's no reason that "next hop" need be
adjacent, right?
In fact, you can't really avoid them using intermediaries.
Quoted text (4 lines)
> Cons: > - does not let you avoid nodes > + (NSA sets up a hub with negative fees in every direction, hubs > reroute everything though it to bump their fees)
Good point. Especially if they're prepared to use very tight timing (since the money is not important), so a node won't lose too much expiry time on the HTLC.
Quoted text (9 lines)
> - how to work out fees? > - how to figure out how to route to other hubs you don't want to have a > direct channel with? > > I think the latter two points have to be solved with some sort of global > (but not necessarily complete) routing announcement service, so you can > query who has channels and do cheapest path finding amongst them; > clients/leaf-nodes so they can estimate fees, hubs so they can do routing, > optimise fees, and work out profitable new channels to connect.
Agreed. I think some dynamic routing protocol has to give you fees and other info. That's a fun, hard problem.
Quoted text (3 lines)
> Maybe that > can be derived from transactions on the blockchain though? But that's > already in the lightning paper.
Joseph half-seriously suggested that the anchor txs be open-kimono, meaning that the routing info is on the blockchain already. It's cute, but since you need the dynamic info I'm not sure it saves anyyhing.
Quoted text (16 lines)
> Speaking of fees, I wonder if the "fee proportional to satoshi-hours" is > backwards -- rather than saying "the intermediary wants to charge for how > long finalisation takes", couldn't you just say "the sender is willing to > pay inversely to how long finalisation takes" in every case? > > If I'm an intermediary, that works out as me being offered (F - k * t) > satoshi to deliver X satoshi within t seconds, for some F and k, then if I > want to take a cut of X*t*r to cover my costs, that just looks like me > onsending X satoshi plus a fee of up to (F - k * t - X*t*r) = (F - (k+X*r) > * t). If you can arrange that fee structure technically, a successful > transaction means everyone has an incentive to close the txn ASAP > (including the final recipient who receives the leftover fee as a > time-sensitive bonus). In that case you just want to choose r based on your > available funds in both directions, making it expensive when you're > over-committed, and potentially offering refunds (r<0) when you're > unbalanced.
I think there's a natural bias to collect ASAP in every case, so I'm not sure if further incentive there is required.
The problematic case is payment fail after timeout. In a naive model, if the payment succeeds (eventually), at least you get some money. If it fails, there's no transaction to skim the fees from.
Quoted text (13 lines)
> I think it's possible to cancel an unroutable transaction so that the funds > can be reused (by effectively routing back to the sender?); if it is, > nominating a smaller but still time-sensitive fee to have that happen > sooner rather than later might be good too. That could also be used to > implement a fee-enforced TTL; if the success fee is characterised by (F_1, > k_1) and the failure fee is (F_2, k_2), with F_1 > F_2 and k_1 > k_2 then > failing becomes more profitable than succeeding at t > (F_1-F_2) / > (k_1-k_2). (F_2 > F_1, failing is immediately better than succeeding; k_2 > > k_1, failing never become a better option; when passing on fees, probably > would be clever to keep that time roughly constant, which is admittedly > straight-forward). That might be useful if you want the protocol to have > long timeouts for safety, but you want short timeouts in practice for > responsiveness.
The TTL in practice is the time difference each node wants for timeouts. OP_CSV is cleverly implemented in terms of median blocktime, which makes it less manipulable, but I wouldn't want to use a difference of less 1 hour per hop simply because there's a non-trivial chance of getting no blocks for an hour.
Quoted text (12 lines)
> Offering an insufficient fee seems like it would easily render a > transaction unroutable; if one of the hubs is on a satellite or floating > platform for anonymity purposes, it might want massively high fees; if > onion routing is in place, this may only be discoverable mid-way through > the routing. > > If you structure the transaction as "<Bob> here's <N-K*t> satoshi, locked > with <R> to be revealed by <Carol> once you deliver <M> and as many of > those satoshi as possible to her" with the actual payment Carol's expecting > not encoded anywhere other than (encrypted) in M, then if Bob tries taking > more fees than needed, he increases the risk Carol won't unlock R and he'll > get nothing.
No, I think fees need to be explicit. "I will pay you N satoshi to get M satoshi to Carol".
Quoted text (8 lines)
> I don't quite see how channels can be safely used for independent > concurrent transactions though. If I (Bob) have an idle channel to Carol > for 100k satoshi, and I want to route 100 satoshi on behalf of Alice to > Dave (locked to R_1), and 200 satoshi from Anna to Doug (locked to R_2) and > 150 satoshi from Amelia to Drew through that channel simultaneously, how do > I sign things given that any combination of those transactions could fail, > breaking the potential "chain"? There's 7 scenarios that could happen then, > do I need to send potential transactions for all of them to Carol?
They become separate HTLCs. That all works fine.
Cheers, Rusty.