From Inbound Discounts to Negative Forward Fees. #9142
feelancer21
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction
In the review process of #6703, there was a discussion about allowing overall negative forward fees. At that point, it seemed better to prevent node runners from losing money by not allowing this feature. However, I think it seems feasible to implement them in a way with limited user risks. I am looking for review especially on the mathematical part and wondering if an implementation with such checks would have success on a merge or are there any other safety concerns?
Overall, the current implementation of inbound discount is a great feature, but it is more likely to incentivize incoming forwards from sinks in the middle of the fee spectrum. However, it is unlikely that they serve as a price signal to high-end sinks.
Negative fees pose two challenges: preventing users from losing money and ensuring pathfinding algorithms find optimal routes. I won't delve deeply into pathfinding, as it seems solvable with other algos, but complex. Without adjusting the pathfinder, however, it makes no sense to introduce negative fees, as they would have no influence on the optimal solution.
User Safety
There are three possibilities of how a user can lose money with negative forward fees.
lnd
needs to check. However, we could introduce a command-line option and deactivate the negative fee feature by default.Aside from this global activation option, on a channel level, it should also be possible to either follow the current behavior of flooring the inbound fee by the outbound fee or use the new behavior. We also need a flag to distinguish gossip messages, but this is also necessary for backward compatibility with older
lnd
senders.Policy Checks and Mathematical Proof
Let$c$ be a channel, $r_{c,i}$ , $r_{c,o}$ the inbound and outbound fee rates in decimals (e.g., 1000ppm = 0.001), $b_{c,i}$ , $b_{c,o}$ the base fees in msat, and $x$ the amount a node wants to receive in msat. We define two functions, calculating the amount including inbound or outbound fees.:
and
Moreover, we define two compositions$f_{c,oi}:=f_{c,o}\circ f_{c,i}$ and $f_{c,io}:=f_{c,i}\circ f_{c,o}$ .
Now, we want to analyze what conditions are sufficient to ensure that the following attack doesn’t lead to a profit for the attacker. We assume that the attacker controls all nodes of the channel's parties, hence they can send sats from one node to another without incurring additional hop costs. The attacker chooses an arbitrary sequence of channels$c_1, \dots, c_n$ with $n\ge 2$ and $c_1=c_n$ . They send an amount $x_1$ from $c_1$ to $c_2$ , so they receive $x_2$ in $c_2$ . They proceed by sending $x_2$ from $c_2$ to $c_3$ , receiving $x_3$ , etc. Our goal is to find a condition that implies $x_1\ge x_n$ .
The main idea is to ensure that$r_{c,o}+r_{c,i}$ and $b_{c,o}+b_{c,i}$ are sufficiently positive for each channel $c$ , as the attacker must always pay both inbound and outbound fees for each channel.
Like in pathfinding, we derive the amount$x_{k-1}$ from $x_k$ . If all channels allow negative forward fees, we have the following recursive relationship:
Now we can construct$x_1$ from $x_n$ through multiple compositions of these functions:
Using the fact that composition is associative and with applying our definitions, we have:
If we assume that$f_{c,oi}(x)\ge x$ for each channel $c$ and every possible amount $x$ , then the inequality also holds for any composition of such functions in sequence. As consequence there exists a $\Delta\ge 0$ such that:
Hence:
The last inequality holds because$r_{c,i}\ge -1=-100$ %. If we also assume that $f_{c,io}(x)\ge x$ for each channel $c$ and amount $x$ , then $x_1\ge f_{c_{1},io}(x_n)\ge x_n$ , proving that the attacker cannot gain money, independently of the chosen channel sequence.
We consider that:
and
Then, for a specific channel$c$ , it is sufficient to have $f_{c,io}(x)\ge x$ and $f_{c,oi}(x)\ge x$ for all $x$ if the following three conditions are satisfied:
We can interpret the left-hand sides of these inequalities as margins that the node runner earns when routing forth and back through the same channel. The first term is a relative margin in ppm and the second and third terms are absolute margins in msat. These three inequalities could be checked during a policy update, as only the current channel fees are required. However, we must consider that the derived conditions are only correct if the fee rates are real numbers.
lnd
uses integers for fees, which can lead to rounding effects. Thus, it seems safer for the right-hand sides to be configurable non-negative minimum margins rather than zeros. In addition, a minimum margin would reduce the risk of money losses after a policy has been updated.Note that the proof also holds if some of the channels$c_1,\dots c_n$ floor the inbound fee by the previous outbound fee.
The inequalities do not guarantee that a user cannot lose money by setting the inbound fee rates too low. For example, if$r_{c,o} = 0.5$ and $r_{c,i} = -0.33$ , the first inequality holds, but it seems impossible to earn a 50% outbound fee after paying a 33% inbound fee. This demonstrates the importance of having a lower bound for the inbound fee rate.
Beta Was this translation helpful? Give feedback.
All reactions