Research/Bitcoin Dev Archive / lightning-dev list
Just in Time Routing (JIT-Routing) and a channel rebalancing heuristic as an add on for improved routing success in BOLT 1.0
10 messages, Mar 5 to 26, 2019. Started by René Pickhardt.
ZmnSCPxj (6), René Pickhardt (2), Ariel Lorenzo-Luaces (2)
Hey everyone,
In this mail I introduce the Just in Time Routing schema (aka JIT Routing). Its main idea is to mitigate the disadvantages from our current source based routing (i.e.: guessing a route that will work in the sense that it has enough liquidity in each channel) and make the routing process a little bit more like the best effort routing that we know from IP-forwarding. As far as I know this will not decrease the privacy of the nodes. As part of this Routing scheme nodes need to be able to quickly rebalance their channels. Thus in this mail I also propose a heuristic for doing this efficiently which I have implemented and seems to provide pretty good results. Obviously the heuristic should be tested with the help of a simulation. I did not have the chance to do that yet. Partly also because I am lacking a proper dataset and I don't want to do this on artificial data.
The advantages of JIT Routing are: * it is possible to do now without any protocol modification. In particular no modifications of the onions are necessary. * routing nodes can already easily implement it. By implementing it they will increase the routing success even for nodes which are running older implementations * it seems to be logically equivalent to AMP Routing. In particular its properties will also help base AMP once it is part of the protocol. * local channel balance information along the route can now be part of the path finding process while not decreasing the privacy by sharing information about channel balances with others. In fact the privacy of nodes is even being increased.
The disadvantages seem: * it might economically not be incentivized for a routing node in every situation. Theoretically it can even happen that a node pays a fee in order to use this technique but can't earn the routing fee as the onion fails later. Nodes can implement risk management strategies to mitigate this issue. * The routing process might take a longer time as it starts sub routing processes. * While doing JIT routing the capacity for channels should be reserved even before HTLCs are set up (to prevent hostile recursive chains of rebalancing operations)
Obviously routing single big payments is a challenge for the lightning network. During the developer summit in Adelaide we have agreed to put Base AMP to BOLT 1.1. To review Base AMP the idea is basically after receiving a payment hash to create several onions on various routes to the recipient. While Base AMP in theory can find the maxflow / min cut and achieve maximum liquidity it is not clear yet how well Base AMP will really work.
While it has been shown that smaller payments have a higher chance to be routed successfully there is the downside that we have more payments which increases the likelihood that any one of those payment eventually fails. As far as I know there have not been any studies researching this fact. Also the fact remains that Base AMP is still a source base routing protocol putting the sender into a tough spot as it has to guess which routes might work.
How to JIT Routing?
For the BOLTs we basically need one Recommendation (in fact even today nodes can do this without this explicit recommendation, but I would suggest to add the recommendation):
If a node cannot forward an incoming HTLC because the node has not enough funds on the outgoing channel the node MAY pause the routing process and try to rebalance the channel that misses liquidity. If it isn't able to rebalance the channel it should fail the onion sending back an insufficient wire funds error `temporary_channel_failure`
Let us consider the following Graph and situation for an example:
100 / 110 80 / 200
S ----------> B --------> R
\ /
80/200 \ / 100/200
\ /
T
Meaning we have the following channels: S ---> B capacity: 110 A funds: 100 B funds: 10 B ---> R capacity: 200 B funds: 80 R funds: 120 B ---> T capacity: 200 B funds: 80 T funds: 120 T ---> R capacity: 200 T funds: 100 R funds: 100
Let us assume S wants to send a payment of 90 to R. With this distribution of funds this will not work with a single route S ---> B ---> R as the channel B--->R can only forward 78 (taking the channel reserve of 1% into consideration)
Now with Base AMP after a protocol update this would be resolved by making two onions forwarding for example 45 each. Also S would have to pay more routing fees as the basefee of B will be charged twice.
Onion 1: S ---> B ---> R Onion 2: S ---> B ---> T ---> R
However it is S again who has to guess how the problems with the liquidity are it does not know how B has spread its funds between R and T (and potentially other channels)
With the above recommendation in place B can create a different onion with lets say moving 50 from the B---> T channel to the B ---> R channel resulting in the following situation:
100 / 110 130 / 200
S ----------> B --------> R
\ /
30/200 \ / 50/200
\ /
T
Meaning we have the following channels: S ---> B capacity: 110 A funds: 100 B funds: 10 B ---> R capacity: 200 B funds: 130 R funds: 70 B ---> T capacity: 200 B funds: 30 T funds: 170 T ---> R capacity: 200 T funds: 50 R funds: 150
Now B can easily pass the original onion with a value of 90 which was designed for the route S ---> B ---> R
Obviously there can also be issues when B tries to rebalance their channels as the attempted event of rebalancing might trigger another JIT operation at another node (potentially making a later stage of the original onion harder to be forwarded). Also B does not have full information about the T---> R channel. Yet B has more information about B's neighbourhood than S does as B knows which channels are liquid and how many paths exist between the endpoints of those channels. This B should be able to make a more educated decision as the originator node S. Since B would only do a rebalancing if the routing fees for the rebalancing are cheaper than the fees they collect (and other nodes would do the same) the risk for and infinit cascade of rebalancing operations should be mitigated. Also the total CLTV for the rebalancing operation should be smaller than the original onion. A sender of the onion could obviously start with larger cltv_deltas to allow routing nodes to have some buffer. This is also good in the sense of shadow routing as described in the BOLTs.
Another problem that might arise is the question if the routing node is able to quickly compute rebalancing paths. I have been working on a c-lightning plugin for rebalancing over the weekend (it is actually when I came up with the idea of JIT routing). Currently I use the following promising heuristic for rebalancing: I look at the friend of a friend network of the node that wants to rebalance channels. This network consists of alle channel partners of the node and their channels. This will in particular have all triangles and rectangles of the lightning network that the node that wants to rebalance is part of. Now I remove the node that wants to rebalance from the friend of the friend network. The resulting graph should always stay pretty small. In a regular small world network the friend of a friend graph consists of roughly 10k nodes. In particular after pruning nodes with degree 1 (which can't be used to rebalance on this subgraph) we have a pretty small network. After extracting this subnetwork (which for general operation could always be maintained while gossip messages are coming in) the computation to suggest several hundred rebalancing cycles and even ordering them by price takes less than 1 second on my machine. So far I have been pretty successful finding several (cheap!) rebalancing suggestions in this network from my lightning node (which has about 40 channels)
I will release the code for the rebalancing schema soon but I wanted to have the idea already out in order to get more feedback while working on this.
best Rene
Good morning Rene,
The base idea is good at first glance.
However, let us consider this situation:
0.1 1.0
A --------- B
1.5 | / 0.5
| /
| /
| /
| /
| /
| /
| /
0.5 | / 0.75
C
A must pay B, 1.0 BTC.
A knows the exact state of AB and AC channels, but only knows that BC has total 1.25 capacity.
A sends via route A->C->B. It knows that it has sufficient capacity in AC. It also knows that the total capacity in CB has a chance of transferring 1.0BTC.
So what happens (let us assume Lightning fees are negligible).
1. A locks 1.0 in AC in an HTLC.
2. C cannot forward since it has only 0.75 in CB.
It initiates a rebalance.
3. C notices it has 0.5 BTC in AC.
It can transfer 0.25BTC from AC to CB to be able to get 1.0 in CB that it can forward.
So it routes 0.25 BTC via C->A->B->C.
4. C locks 0.25 in CA in an HTLC.
5. A cannot forward the C->A->B->C payment since it only has 0.1BTC in AB.
It initiates a rebalance.
6. A notices it has 0.5 BTC in AC (1.0 is currently locked in an HTLC, leaving it 0.5BTC).
It can transfer 0.15BTC in AC to AB to be able to get 0.25 in AC that it can forward.
So it routes 0.15 BTC via A->C->B->C.
7. A locks 0.15 in AC in an HTLC.
8. C is now in a bind.
If it forwards the 0.15 BTC, then it will still fail the earlier A->C->B 1.0 payment.
This is because it will lose 0.15 BTC from its side here, leading to 0.6 BTC, then receive 0.25 BTC from the rebalance, only having 0.85 BTC.
If it does not forward, A is unable to rebalance and fails the rebalance of C, which fails the original payment from A->C->B.
Thus it seems to me, that precisely because of the lack of a global view, such kinds of complicated HTLC networks will form, then still lead to payment failure.
Good morning Rene and list,
Let us consider then the rule *when* a rebalancing would be beneficial to the node.
The node is offered a fee amount (`offered_fee_amount`) for the forwarding. It knows that, under current channel states, it will definitely have to fail and earn 0 fees.
If it engages in JIT-routing, it must pay some fee (`rebalancing_fee_amount`) for the rebalancing operation. But even if it successfully forwards its hop, it is still possible that the route will fail anyway and it will earn 0 fees.
So let us consider the probability of success (`success_rate`), a value between 0 to 1.0. This is the estimated probability that we will succeed the route after we forward it.
We should only engage in JIT-routing if:
offered_fee_amount * success_rate - rebalancing_fee_amount > 0
The LHS of the subtraction is the expected earning, while the RHS of the subtraction is the expected cost. The above is trivial accounting for determining net earnings.
The fee amounts are trivially computable. Presumably the rebalancing code can compute the fee given a particular rebalance path, and thus can provide `rebalancing_fee_amount`.
The `success_rate` can be computed statically from some node data. Better, is for the node to start with this precomputed static information, but augment this over time with its own experienced `success_rate` for all forwards.
Regards, ZmnSCPxj
Hello Rene, ZmnSCPxj, and list
I really like the proposal and I'm sure it's the correct way forward for reducing payment failures and increasing privacy (through mitigating probing based network analysis)
However I am concerned that this proposal could introduce a vulnerability to a spoofed-payment attack.
An adversary could create a malicious payment that's guaranteed to fail, for free. Any intermediary nodes on the path of the payment before it fails could lose fees due to rebalancing if the rebalancing path's success is not dependent on the original payment's success.
Could anyone speak to this and confirm whether it would be possible for the rebalancing step to reuse the original payment hash? If this is possible then it should explicitly be included in this proposal.
If reusing the payment hash is not possible on the routing path then JIT routing would need some other mitigation for the spoofed-payment attack.
Cheers
Ariel Lorenzo-Luaces
On Mar 14, 2019, 7:45 AM, at 7:45 AM, ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> wrote:
Quoted text (43 lines)
>Good morning Rene and list, > >Let us consider then the rule *when* a rebalancing would be beneficial >to the node. > >The node is offered a fee amount (`offered_fee_amount`) for the >forwarding. >It knows that, under current channel states, it will definitely have to >fail and earn 0 fees. > >If it engages in JIT-routing, it must pay some fee >(`rebalancing_fee_amount`) for the rebalancing operation. >But even if it successfully forwards its hop, it is still possible that >the route will fail anyway and it will earn 0 fees. > >So let us consider the probability of success (`success_rate`), a value >between 0 to 1.0. >This is the estimated probability that we will succeed the route after >we forward it. > >We should only engage in JIT-routing if: > > offered_fee_amount * success_rate - rebalancing_fee_amount > 0 > >The LHS of the subtraction is the expected earning, while the RHS of >the subtraction is the expected cost. >The above is trivial accounting for determining net earnings. > >The fee amounts are trivially computable. >Presumably the rebalancing code can compute the fee given a particular >rebalance path, and thus can provide `rebalancing_fee_amount`. > >The `success_rate` can be computed statically from some node data. >Better, is for the node to start with this precomputed static >information, but augment this over time with its own experienced >`success_rate` for all forwards. > >Regards, >ZmnSCPxj >_______________________________________________ >Lightning-dev mailing list >Lightning-dev at lists.linuxfoundation.org >https://www.learnbitcoin.com/archive/lists/lightning-dev
Hey everyone,
I am glad the suggestion is being picked up. At this time I want to respond to two of the concerns that have been thrown in. I have some other comments and ideas but would like to hold them back so that we can have more people joining the discussion without bias also this mail will already be quite long.
ZmnSCPxj suggested to introduce a `success_rate` for JIT routing. While this success_rate can obviously only be estimated or configured I would advice against including this to the protocol. As I mentioned before I suggested to include JIT Routing as a MAY Recommendation so it is up to the node to decide if it cannot earn `offered_fee_amount` to engage in the JIT-rebalancing operation. A node operator might be willing in general to to pay a fee for rebalancing even if there is not an outstanding routing event taking place. So even while `rebalancing_fee_amount` > `offered_fee_amount` the node could see the offered_fee_amount as a discount for the planned rebalancing amount. We don't know that and I honestly believe that the protocol should not make economical decisions for the node. In any case rebalancing will overall increase the likelihood for successful routing but it makes sense to defer the rebalancing operation to a moment in which the liquidity is actually needed.
Regarding Ariels suggestion about reusing the payment hash with JIT Routing I have some more thoughts: Reusing the payment hash indeed seems like a good idea. However it produces some technical issues which in my opinion can all be mitigated. it is just a question with these challenges if it is worthwhile doing it?
I have drawn several situations and tried to construct an example in which using the same payment hash for the JIT-rebalancing would result in a severe problem with the payment process in the sense that it would be compromised or somebody could steal funds. It could however be a privacy issue as more nodes are being aware of the same payment (but that is also the case with base-AMP) I was not able to construct such a situation (under the assumption that the rebalancing amount does not exceed the original payment amount). My feeling (though I have not done this yet) is that one should be able to proof that taking the same payment hash would always work and in fact create a situation in which at least the rebalancing only takes place if the entire payment was routed successfully.
Assuming someone will be able to proof that using the same payment hash for JIT Routing is not an issue we still run into another problem (which I believe can be fixed with another MUST rule but comes with quite some implementation overhead.)
The deadlock problem when doing JIT Routing with the same payment hash: When using the same payment hash there will be two htlc's (potentially of different amounts) in opposing directions on the same channel (or in the lnd case maybe between separate channels between the same two peers). Unluckily without a novel rule this can produce a deadlock.
As an example take the situation from my initial email with an additional recipient R1:
100 / 110 80 / 200 150/180
S ----------> B --------> R ----------> R1
\ /
80/200 \ / 100/200
\ /
T
Meaning we have the following channels: S ---> B capacity: 110 A funds: 100 B funds: 10 B ---> R capacity: 200 B funds: 80 R funds: 120 B ---> T capacity: 200 B funds: 80 T funds: 120 T ---> R capacity: 200 T funds: 100 R funds: 100 R ---> R1 capacity: 180 R funds: 150 R1 funds: 30
neglecting fees the following htlcs would be offered 1.) S-->B amount: 90 2.) B-->T amount:50 3.) T-->R amount:50 4.) R-->B amount: 50 5.) B-->R amount: 90 (difficult to set up before 4. settles) 6.) R-->R1 amount: 90
while 1,5 and 6 are the original path 2,3,4 are the JIT rebalancing.
We see that in this situation using the same preimage results in a problem. Since the rebalancing is not settled R will not accept the 5th htlc (B--->R amount: 90) as there is not enough liquidity on B's side producing a deadlock However since the same payment hash is used it is save to combine the 4th and 5th htlc to have the following situation:
1.) S-->B amount: 90 2.) B-->T amount:50 3.) T-->R amount:50 4.) R-->B will be removed or settled or replaced by the 5th htlcs with a different amount (90 - 50) 5.) B-->R amount: 40 6.) R-->R1 amount: 90
Note that while theoretically it seems tempting to just have two htlc outputs as the second node could always claim the htlc if the first claims theirs. However this will not work onchain as potentially more funds are spend than exist.
Therefor we need a MUST-rule to fix the deadlock problem (which could probably also be formulated in a symmetric way): If a node N offers an htlc to a partner with an amount x from whom the node already received an htlc y (where y is smaller than x) the nodes must create a new channel state discarding the old htlc but having a new offer from N with the amount x-y.
This decreases the liquidity bound in the routing process, enables for a critical channel to be rebalanced several times during several JIT operations and keeps the onchain footprint low as there are less htlc outputs.
Also as mentioned above it seems crucial that the rebalancing amount must not exceed the original payment amount if the payment hash is being reused. Imagine there was no R1 and R was actually the final destination and B decides to rebalance an amount larger than necessary (which could not happen in our setup). R could release the preimage before setting up the final htlc from R back to B to fulfill the rebalancing request. This could also happen if T was the final recipient (which R would not now!)
The only way how I see that this problem can be mitigated is by introducing the following rule (morally even as a MUST rule) If a node decides to engage in JIT Routing using the same payment hash as the incoming htlc it SHOULD NOT rebalance an amount higher than the incoming HTLCs. If it rebalances with a new payment hash it MAY use an arbitrary amount. Rational: (as described above)
Another problem while reusing the payment hash is that in this situation the node who issued the invoice could be involved in a rebalancing act and decline an htlc as the amount is not sufficient for the invoice. Therefor we would have to set either the base-AMP feature flag or create a new one for JIT-routing which would signal that there are more htlc's coming which need to be combined to forward an onion.
In order to avoid this complex aggregation of htlcs we could also see this process as a local AMP right a way saying that a node instead of forwarding the onion MAY do a local base-AMP to the next recipient.
So in my opinion this suggestions to reuse the payment hash is not only reasonable but actually desirable in particular if we can proof that it is not a problem and if we agree that we can mitigate the technical challenges which I described in this mail.
Best regards Rene
On Thu, Mar 14, 2019 at 2:08 PM Ariel Lorenzo-Luaces <arielluaces at gmail.com> wrote:
Quoted text (75 lines)
> Hello Rene, ZmnSCPxj, and list > > > I really like the proposal and I'm sure it's the correct way forward for > reducing payment failures and increasing privacy (through mitigating > probing based network analysis) > > > However I am concerned that this proposal could introduce a vulnerability > to a spoofed-payment attack. > > > An adversary could create a malicious payment that's guaranteed to fail, > for free. Any intermediary nodes on the path of the payment before it fails > could lose fees due to rebalancing if the rebalancing path's success is not > dependent on the original payment's success. > > > Could anyone speak to this and confirm whether it would be possible for > the rebalancing step to reuse the original payment hash? If this is > possible then it should explicitly be included in this proposal. > > > If reusing the payment hash is not possible on the routing path then JIT > routing would need some other mitigation for the spoofed-payment attack. > > > Cheers > > > Ariel Lorenzo-Luaces > > > On Mar 14, 2019, at 7:45 AM, ZmnSCPxj via Lightning-dev < > lightning-dev at lists.linuxfoundation.org> wrote: >> >> Good morning Rene and list, >> >> Let us consider then the rule *when* a rebalancing would be beneficial to the node. >> >> The node is offered a fee amount (`offered_fee_amount`) for the forwarding. >> It knows that, under current channel states, it will definitely have to fail and earn 0 fees. >> >> If it engages in JIT-routing, it must pay some fee (`rebalancing_fee_amount`) for the rebalancing operation. >> But even if it successfully forwards its hop, it is still possible that the route will fail anyway and it will earn 0 fees. >> >> So let us consider the probability of success (`success_rate`), a value between 0 to 1.0. >> This is the estimated probability that we will succeed the route after we forward it. >> >> We should only engage in JIT-routing if: >> >> offered_fee_amount * success_rate - rebalancing_fee_amount > 0 >> >> The LHS of the subtraction is the expected earning, while the RHS of the subtraction is the expected cost. >> The above is trivial accounting for determining net earnings. >> >> The fee amounts are trivially computable. >> Presumably the rebalancing code can compute the fee given a particular rebalance path, and thus can provide `rebalancing_fee_amount`. >> >> The `success_rate` can be computed statically from some node data. >> Better, is for the node to start with this precomputed static information, but augment this over time with its own experienced `success_rate` for all forwards. >> >> Regards, >> ZmnSCPxj >> ------------------------------ >> >> Lightning-dev mailing list >> Lightning-dev at lists.linuxfoundation.org >> https://www.learnbitcoin.com/archive/lists/lightning-dev >> >> _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
Good morning Rene and Ariel,
Quoted text (5 lines)
> Hey everyone, > > I am glad the suggestion is being picked up. At this time I want to respond to two of the concerns that have been thrown in. I have some other comments and ideas but would like to hold them back so that we can have more people joining the discussion without bias also this mail will already be quite long. > > ZmnSCPxj suggested to introduce a `success_rate` for JIT routing. While this success_rate can obviously only be estimated or configured I would advice against including this to the protocol. As I mentioned before I suggested to include JIT Routing as a MAY Recommendation so it is up to the node to decide if it cannot earn `offered_fee_amount` to engage in the JIT-rebalancing operation.
I think it is beyond the scope of the protocol specs to specify this. However, we should remember that it is not the protocol specs that is running on the actual network, but actual implementations. Thus the exact rule may need discussion nevertheless, as it may affect the ability to attack actual implementations on the network.
Quoted text (6 lines)
> A node operator might be willing in general to to pay a fee for rebalancing even if there is not an outstanding routing event taking place. So even while `rebalancing_fee_amount` > `offered_fee_amount` the node could see the offered_fee_amount as a discount for the planned rebalancing amount. We don't know that and I honestly believe that the protocol should not make economical decisions for the node. In any case rebalancing will overall increase the likelihood for successful routing but it makes sense to defer the rebalancing operation to a moment in which the liquidity is actually needed. > > Regarding Ariels suggestion about reusing the payment hash with JIT Routing I have some more thoughts: > Reusing the payment hash indeed seems like a good idea. However it produces some technical issues which in my opinion can all be mitigated. it is just a question with these challenges if it is worthwhile doing it? > > I have drawn several situations and tried to construct an example in which using the same payment hash for the JIT-rebalancing would result in a severe problem with the payment process in the sense that it would be compromised or somebody could steal funds. It could however be a privacy issue as more nodes are being aware of the same payment (but that is also the case with base-AMP)
This would be fixable when we switch to points and scalars (from hashes and preimages) and enable route decorrelation, just as it would improve base-AMP.
Quoted text (47 lines)
> I was not able to construct such a situation (under the assumption that the rebalancing amount does not exceed the original payment amount). My feeling (though I have not done this yet) is that one should be able to proof that taking the same payment hash would always work and in fact create a situation in which at least the rebalancing only takes place if the entire payment was routed successfully. > > Assuming someone will be able to proof that using the same payment hash for JIT Routing is not an issue we still run into another problem (which I believe can be fixed with another MUST rule but comes with quite some implementation overhead.) > > The deadlock problem when doing JIT Routing with the same payment hash: > When using the same payment hash there will be two htlc's (potentially of different amounts) in opposing directions on the same channel (or in the lnd case maybe between separate channels between the same two peers). Unluckily without a novel rule this can produce a deadlock. > > As an example take the situation from my initial email with an additional recipient R1: > > 100 / 110 80 / 200 150/180 > S ----------> B --------> R ----------> R1 > \ / > 80/200 \ / 100/200 > \ / > T > > Meaning we have the following channels: > S ---> B capacity: 110 A funds: 100 B funds: 10 > B ---> R capacity: 200 B funds: 80 R funds: 120 > B ---> T capacity: 200 B funds: 80 T funds: 120 > T ---> R capacity: 200 T funds: 100 R funds: 100 > R ---> R1 capacity: 180 R funds: 150 R1 funds: 30 > > neglecting fees the following htlcs would be offered > 1.) S-->B amount: 90 > 2.) B-->T amount:50 > 3.) T-->R amount:50 > 4.) R-->B amount: 50 > 5.) B-->R amount: 90 (difficult to set up before 4. settles) > 6.) R-->R1 amount: 90 > > while 1,5 and 6 are the original path 2,3,4 are the JIT rebalancing. > > We see that in this situation using the same preimage results in a problem. Since the rebalancing is not settled R will not accept the 5th htlc (B--->R amount: 90) as there is not enough liquidity on B's side producing a deadlock > However since the same payment hash is used it is save to combine the 4th and 5th htlc to have the following situation: > > 1.) S-->B amount: 90 > 2.) B-->T amount:50 > 3.) T-->R amount:50 > 4.) R-->B will be removed or settled or replaced by the 5th htlcs with a different amount (90 - 50) > 5.) B-->R amount: 40 > 6.) R-->R1 amount: 90 > > Note that while theoretically it seems tempting to just have two htlc outputs as the second node could always claim the htlc if the first claims theirs. However this will not work onchain as potentially more funds are spend than exist. > > Therefor we need a MUST-rule to fix the deadlock problem (which could probably also be formulated in a symmetric way): > If a node N offers an htlc to a partner with an amount x from whom the node already received an htlc y (where y is smaller than x) the nodes must create a new channel state discarding the old htlc but having a new offer from N with the amount x-y.
Or more clearly:
* Given two nodes A and B:
* If B has already offered an HTLC with hash `h` and value `y`, AND A offers an HTLC with hash `h` and value `x` such that `x > y`:
* The previous HTLC from B to A with value `y` is replaced with a new HTLC from A to B with value `x - y`.
* The value owned by A is deducted by `x - y` instead of `x`.
* Normal checks for capacity in A side should check `x - y`.
* The value `y` is returned to ownership of B.
* B performs forwarding normally with the value `x` as the amount to continue forwarding, or as payment if it is the final node.
Note that the overall effect on the route would be as if there were a "local bass amplifier" from the node that performs the JIT-routing. It also is nearer to a "JIT routing" than a "JIT rebalancing".
This also complicates the database needed to chain HTLCs together (particularly in c-lightning). We would have to connect the outgoing HTLC to two incoming HTLCs.
However this probably needs a feature bit. If one side does not support this feature, it will `error` in response to an attempt to forward where the available capacity is greater than the available capacity. This `error` will cause the channel to be closed unilaterally.
In a decorrelation world, this will still work, but `B` now knows that a JIT local bass amplifier was done.
Quoted text (4 lines)
> > This decreases the liquidity bound in the routing process, enables for a critical channel to be rebalanced several times during several JIT operations and keeps the onchain footprint low as there are less htlc outputs. > > Also as mentioned above it seems crucial that the rebalancing amount must not exceed the original payment amount if the payment hash is being reused. Imagine there was no R1 and R was actually the final destination and B decides to rebalance an amount larger than necessary (which could not happen in our setup). R could release the preimage before setting up the final htlc from R back to B to fulfill the rebalancing request. This could also happen if T was the final recipient (which R would not now!)
But what about for invoices with no particular amount? Since the invoice has no particular amount, the recipient will assume that any offered value is correct.
So suppose we have that `R` is the recipient. In that case, the rebalancing attempt by B looks like a small offer. Since `R` knows the preimage, it can grab the value.
Note in particular that lnd is known to have this behavior (I know the preimage, I will take the coins and ignore the onion packet). In this case it would be loss of lnd to do so, since it will get the smaller rebalance value rather than the full payment to be forwarded. Good thing we are both c-lightning developers.
Regards, ZmnSCPxj
Good morning all,
I have been thinking further about JIT-Routing.
Particularly, the extension of Rene of the idea from Ariel, to use the same payment hash (payment point in the future).
I observe that this effectively creates a sort of "local bass amplifier" multipath payment.
Quoted text (2 lines)
>From this idea, also: > > If a node N offers an htlc to a partner with an amount x from whom the node already received an htlc y (where y is smaller than x) the nodes must create a new channel state discarding the old htlc but having a new offer from N with the amount x-y.
I think we should consider also the possibility of multiple HTLCs "y" above. For instance, the node may not have enough liquidity in any single channel to fulfill the forward, or even augment its channel(s) to that node from a single other channel. However the node may have multiple channels, which in aggregate may have enough liquidity to fulfill the forward on the channel(s) to the next node in the onion hop.
Implementation-wise, it means:
1. An outgoing HTLC may need to be associated with multiple incoming HTLCs. 2. An incoming payment may need to be associated with multiple incoming HTLCs (this is a prerequisite of all forms of multipath payment, whether bass amplifier or AMP). 3. An outgoing HTLC may need to be deleted, and all its associated incoming HTLCs re-associated to either a new outgoing HTLC or an incoming payment. 3.1. Multiple such outgoing HTLCs may be deleted in a single step, and all their incoming HTLCs will be re-assocaited.
In future, when moving to points/scalars, we need to reveal for each HTLC we want to reverse, the total decorrelation secret that makes them each claimable by knowledge of the point, of the new HTLC we want to reverse.
---
But first, let us consider, is there a need for JIT-Routing?
I have always held that failure of a single routing attempt is not very important, as multiple routing attempts can be performed in sequence, and as long as any *single* attempt completes, then the payment succeeds.
However, in a world where some kind of multipart payment (whether bass amplifier or AMP) is in frequent use, this changes. A failure of a single routing attempt may delay the completion of a multipart payment, as it means that the source has to retry that branch of the multipart payment. In short, *all* attempts must succeed for a multipart payment to succeed.
It would be nice if we can perform re-routing in order to help multipart payments succeed without so much coordination at the source. This is why Rendezvous Routing is of interest to me, since (naively) it seems to me that re-routing is possible with Rendezvous.
However, it seems that JIT-Routing, as modified by Rene based on idea of Ariel, does much of what Rendezvous Routing would do for re-routing. (Rendezvous Routing is still independently of value for privacy of receivers as well as moving fee payment from senders to receivers in the "withdrawal from custodial wallet" case.)
So I think this JIT-Routing would synergize quite well with bass amplifier and AMP. It effectively allows forwarding nodes to independently split a forwarding attempt across multiple paths, without participation of source.
Good morning list,
I have been thinking of JIT-Routing in the context of unidirectional channels, as for example in Eclair Mobile. Now of course unidirectional-only nodes as in Eclair Mobile cannot forward and cannot be intermediate nodes. However, as I pointed out in previous email, the same JIT-Routing can be used also when the node is the ultimate source of the payment.
The original formulation, which requires a separate, completed rebalance, before performing a payment, cannot be used in unidirectional mode. It requires that the channel to be boosted by the rebalance, must first receive the value, which is disallowed in unidirectional mode.
However, the Luaces-Pickhardt JIT-Routing, which has a conditional rebalance, does not require that the channel receive. So it seems to me, that the Luaces-Pickhardt JIT-Routing can work with Eclair.
Let us consider the following history:
1. An Eclair Mobile client creates a 1mBTC channel.
2. The client successfully pays an unrelated payment of 0.5 mBTC.
3. The client has to make another payment of 0.6 mBTC, to be passed by this channel.
The client has another channel which can pay out the needed 0.15mBTC (additional 0.05mBTC needed for the channel reserve).
4. The second payment passes.
In the below sequence of states, A is the Eclair Mobile client node, while B is the counterparty.
1. A = 1.0, B = 0.0 ; starting state. 2. A = 0.5, B = 0.0, A->HTLC->B = 0.5 ; client offers payment in #2 above. 3. A = 0.5, B = 0.5 ; payee accepts payment. 4. A = 0.5, B = 0.35, B->HTLC->A = 0.15 ; the rebalance from another channel of A, initiated by #3 above. 5. A = 0.05, B = 0.5, A->HTLC->B = 0.45 ; HTLC polarity reversed by A offering an HTLC of 0.6 BTC (the new mechanism proposed by Rene). 6. A = 0.05, B = 0.95 ; payee accepts payment.
As can be seen from above, A will never have an increase in its money.
Thus, the new Luaces-Pickhardt formulation of JIT-Routing, which requires the new "reverse HTLC polarity" mechanism to reuse the same hash as the actual payment, should be safe for unidirectional Eclair Mobile nodes.
Let us consider the following sequence of events:
1. An Eclair Mobile client creates a 1mBTC channel.
2. The client successfully pays an unrelated payment of 0.5 mBTC.
3. The client has to make another payment of 0.6 mBTC, to be passed by this channel.
The client has another channel which can pay out the needed 0.15mBTC (additional 0.05mBTC needed for the channel reserve).
4. The second payment fails.
Then the sequence of states is:
1. A = 1.0, B = 0.0 ; starting state. 2. A = 0.5, B = 0.0, A->HTLC->B = 0.5 ; client offers payment in #2 above. 3. A = 0.5, B = 0.5 ; payee accepts payment. 4. A = 0.5, B = 0.35, B->HTLC->A = 0.15 ; the rebalance from another channel of A, initiated by #3 above. 5. A = 0.05, B = 0.5, A->HTLC->B = 0.45 ; HTLC polarity reversed by A offering an HTLC of 0.6 BTC (the new mechanism proposed by Rene). 6. A = 0.5, B = 0.5 ; payment fails.
Now in the above, the only state that has A own less money than in a later state is state 5. However, even if we are at state 6, and B replays state 5, B cannot claim the A->HTLC->B (if it had the hash, it would have claimed the HTLC instead of failing it), so it will revert back to A when it times out. This is the same as existing cases of payment failure in Eclair Mobile, so presumably if it has a problem here, it would have a problem in existing Eclair Mobile unidirectional channels.
Thus, it should be safe to use the Luaces-Pickhardt JIT-Routing in unidirectional-only nodes, even if the original Pickhardt JIT-Routing is unsafe for unidirectional-only nodes.
Thus this is a plausible replacement for all forms of multipart payments. In effect, instead of a multipart payment being decided by the source to the destination, we have each hop, including the source, deciding to split or not split the payment according to how much fee it has to devote to rebalance attempts.
Regards, ZmnSCPxj
Good morning list
I have been thinking about how JIT-Routing can allow the network to be more private and scalable than it currently is today. Rene has mentioned that JIT-Routing allows channel balance information to affect pathing decisions without the source node being aware. I would take this further and suggest that JIT-Routing can allow routing over sub-paths that are only visible to neighbour nodes and are entirely hidden from the source node or plublic view.
An intermediate route node could decide for any reason to re-route a payment through any subset of nodes to arrive at the next hop. This is similar to Rene's local AMP idea where friend-of-a-friend nodes are used. But instead this system could allow arbitraryly long paths to the next hop by finding a new sub-route and re-layering the onion packet with the new sub-route prepended.
The same pre-image would be used and this process would be completely invisible to the next hop (original next hop, not the new next hop in the sub-route, I would instead call those the sub-hops).
It's unfortunate that the intermediate nodes along the sub-route would be aware that a sub-route is being attempted because they could observe extra hop packets prepended to the minimum twenty and I don't see of a way to fix this. But maybe it doesn't need fixing since the original twenty encryption layers are arguably private enough.
The sub-route could also employ base AMP since the same pre-image is used. The next hop node would still never even know that a subroute was attempted if no "wait for more payments" flag is added to the per_hop field and we implement the "wait for timeout if HTLC is less than amt_to_forward" rule.
Public nodes could advertise channels which don't actually exist directly but are instead hidden paths that the source node doesn't need to know or care about. The fees advertised for these aggregate-channels would be the aggregate fees expected from the sub-route.
I think the biggest gain from this system is that the network can be more abstract. This abstraction allows all possible subsets of public nodes to be a clique since all subsets of nodes can be maximally connected with aggregate-channels as long as the entire network is well connected.
This new property of the network could allow a source node to select a random privacy-clique and rely on payments to be routed along aggregate-channels without the source node needing to compute or even know the exact sub-routes. Futhermore, the source node could exclusively download and listen to the privacy-clique and ignore the rest of the network structure thus reducing the burden of keeping up to date network information.
Cheers Ariel Lorenzo-Luaces
On Mar 22, 2019, 4:44 AM, at 4:44 AM, ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> wrote:
Quoted text (99 lines)
>Good morning list, > >I have been thinking of JIT-Routing in the context of unidirectional >channels, as for example in Eclair Mobile. >Now of course unidirectional-only nodes as in Eclair Mobile cannot >forward and cannot be intermediate nodes. >However, as I pointed out in previous email, the same JIT-Routing can >be used also when the node is the ultimate source of the payment. > >The original formulation, which requires a separate, completed >rebalance, before performing a payment, cannot be used in >unidirectional mode. >It requires that the channel to be boosted by the rebalance, must first >receive the value, which is disallowed in unidirectional mode. > >However, the Luaces-Pickhardt JIT-Routing, which has a conditional >rebalance, does not require that the channel receive. >So it seems to me, that the Luaces-Pickhardt JIT-Routing can work with >Eclair. > >Let us consider the following history: > >1. An Eclair Mobile client creates a 1mBTC channel. >2. The client successfully pays an unrelated payment of 0.5 mBTC. >3. The client has to make another payment of 0.6 mBTC, to be passed by >this channel. >The client has another channel which can pay out the needed 0.15mBTC >(additional 0.05mBTC needed for the channel reserve). >4. The second payment passes. > >In the below sequence of states, A is the Eclair Mobile client node, >while B is the counterparty. > >1. A = 1.0, B = 0.0 ; starting state. >2. A = 0.5, B = 0.0, A->HTLC->B = 0.5 ; client offers payment in #2 >above. >3. A = 0.5, B = 0.5 ; payee accepts payment. >4. A = 0.5, B = 0.35, B->HTLC->A = 0.15 ; the rebalance from another >channel of A, initiated by #3 above. >5. A = 0.05, B = 0.5, A->HTLC->B = 0.45 ; HTLC polarity reversed by A >offering an HTLC of 0.6 BTC (the new mechanism proposed by Rene). >6. A = 0.05, B = 0.95 ; payee accepts payment. > >As can be seen from above, A will never have an increase in its money. > >Thus, the new Luaces-Pickhardt formulation of JIT-Routing, which >requires the new "reverse HTLC polarity" mechanism to reuse the same >hash as the actual payment, should be safe for unidirectional Eclair >Mobile nodes. > >Let us consider the following sequence of events: > >1. An Eclair Mobile client creates a 1mBTC channel. >2. The client successfully pays an unrelated payment of 0.5 mBTC. >3. The client has to make another payment of 0.6 mBTC, to be passed by >this channel. >The client has another channel which can pay out the needed 0.15mBTC >(additional 0.05mBTC needed for the channel reserve). >4. The second payment fails. > >Then the sequence of states is: > >1. A = 1.0, B = 0.0 ; starting state. >2. A = 0.5, B = 0.0, A->HTLC->B = 0.5 ; client offers payment in #2 >above. >3. A = 0.5, B = 0.5 ; payee accepts payment. >4. A = 0.5, B = 0.35, B->HTLC->A = 0.15 ; the rebalance from another >channel of A, initiated by #3 above. >5. A = 0.05, B = 0.5, A->HTLC->B = 0.45 ; HTLC polarity reversed by A >offering an HTLC of 0.6 BTC (the new mechanism proposed by Rene). >6. A = 0.5, B = 0.5 ; payment fails. > >Now in the above, the only state that has A own less money than in a >later state is state 5. >However, even if we are at state 6, and B replays state 5, B cannot >claim the A->HTLC->B (if it had the hash, it would have claimed the >HTLC instead of failing it), so it will revert back to A when it times >out. >This is the same as existing cases of payment failure in Eclair Mobile, >so presumably if it has a problem here, it would have a problem in >existing Eclair Mobile unidirectional channels. > >Thus, it should be safe to use the Luaces-Pickhardt JIT-Routing in >unidirectional-only nodes, even if the original Pickhardt JIT-Routing >is unsafe for unidirectional-only nodes. > >Thus this is a plausible replacement for all forms of multipart >payments. >In effect, instead of a multipart payment being decided by the source >to the destination, we have each hop, including the source, deciding to >split or not split the payment according to how much fee it has to >devote to rebalance attempts. > >Regards, >ZmnSCPxj >_______________________________________________ >Lightning-dev mailing list >Lightning-dev at lists.linuxfoundation.org >https://www.learnbitcoin.com/archive/lists/lightning-dev
Good morning Ariel and Rene and list,
I have started to consider how best to attack the modified Luaces-Pickhardt JIT-Routing, which reuses the same payment hash as the message to forward. (In the case where JIT-Routing is used by the ultimate source of a payment, the payment hash of the invoice being paid.)
And it seems that, unless hop routes are given more time than their reported `cltv_delta`, then either:
1. JIT-Routing cannot be done since the rebalancing requires more blocks than is allocated to the hop, 2. OR, JIT-Routing is done despite the lack of blocks, at the major risk of possibly getting attacked by fooling around with lock times.
Decorrelation could remove the risk in #2.