<oembed><type>rich</type><version>1.0</version><author_name>npub17rld56k4365lfphyd8u8kwuejey5xcazdxptserx03wc4jc9g24stx9l2h</author_name><author_url>https://nostr.ae/npub17rld56k4365lfphyd8u8kwuejey5xcazdxptserx03wc4jc9g24stx9l2h</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2022-06-29&#xA;📝 Original message:&#xA;On Sun, Jun 05, 2022 at 02:29:28PM +0000, ZmnSCPxj via Lightning-dev wrote:&#xA;&#xA;Just sharing my thoughts on this.&#xA;&#xA;&gt; Introduction&#xA;&gt; ============&#xA;&gt;           Optimize for reliability+&#xA;&gt;            uncertainty+fee+drain+uptime...&#xA;&gt;                  .--~~--.&#xA;&gt;                 /        \&#xA;&gt;                /          \&#xA;&gt;               /            \&#xA;&gt;              /              \&#xA;&gt;             /                \&#xA;&gt;         _--&#39;                  `--_&#xA;&gt;         Just                  Just&#xA;&gt;       optimize              optimize&#xA;&gt;         for                   for&#xA;&gt;       low fee               low fee&#xA;&#xA;I think ideally you want to optimise for some combination of fee, speed&#xA;and reliability (both liklihood of a clean failure that you can retry&#xA;and of generating stuck payments). As Matt/Peter suggest in another&#xA;thread, maybe for some uses you can accept low speed for low fees,&#xA;while in others you&#39;d rather pay more and get near-instant results. I&#xA;think drain should just go to fee, and uncertainty/uptime are just ways&#xA;of estimating reliability.&#xA;&#xA;It might be reasonable to generate local estimates for speed/reliability&#xA;by regularly sending onion messages or designed-to-fail htlcs.&#xA;&#xA;Sorry if that makes me a midwit :)&#xA;&#xA;&gt; Rene Pickhardt also presented the idea of leaking friend-of-a-friend balances, to help payers increase their payment reliability.&#xA;&#xA;I think foaf (as opposed to global) gossip of *fee rates* is a very&#xA;interesting approach to trying to give nodes more *current* information,&#xA;without flooding the entire network with more traffic than it can&#xA;cope with.&#xA;&#xA;&gt; Now we can consider that *every channel is a marketplace*.&#xA;&gt; What is being sold is the sats inside the channel.&#xA;&#xA;(Really, the marketplace is a channel pair (the incoming channel and&#xA;the outgoing channel), and what&#39;s being sold is their relative balance)&#xA;&#xA;&gt; So my concrete proposal is that we can do the same friend-of-a-friend balance leakage proposed by Rene, except we leak it using *existing* mechanisms --- i.e. gossiping a `channel_update` with new feerates adjusted according to the supply on the channel --- rather than having a new message to leak friend-of-a-friend balance directly.&#xA;&#xA;+42&#xA;&#xA;&gt; Because we effectively leak the balance of channels by the feerates on the channel, this totally leaks the balance of channels.&#xA;&#xA;I don&#39;t think this is true -- you ideally want to adjust fees not to&#xA;maintain a balanced channel (50% on each side), but a balanced *flow*&#xA;(1:1 incoming/outgoing payment volume) -- it doesn&#39;t really matter if&#xA;you get the balanced flow that results in an average of a 50:50, 80:20&#xA;or 20:80 ratio of channel balances (at least, it doesn&#39;t as long as your&#xA;channel capacity is 10 or 100 times the payment size, and your variance&#xA;is correspondingly low).&#xA;&#xA;Further, you have two degrees of freedom when setting fee rates: one&#xA;is how balanced the flows are, which controls how long your channel can&#xA;remain useful, but the other is how *much* flow there is -- if halving&#xA;your fee rate doubles the flow rate in sats/hour, then that will still&#xA;increase your profit. That also doesn&#39;t leak balance information.&#xA;&#xA;&gt; ### Inverting The Filter: Feerate Cards&#xA;&gt; Basically, a feerate card is a mapping between a probability-of-success range and a feerate.&#xA;&gt; * 00%-&gt;25%: -10ppm&#xA;&gt; * 26%-&gt;50%: 1ppm&#xA;&gt; * 51%-&gt;75%: 5ppm&#xA;&gt; * 76%-&gt;100%: 50ppm&#xA;&#xA;Feerate cards don&#39;t really make sense to me; &#34;probability of success&#34;&#xA;isn&#39;t a real measure the payer can use -- naively, if it were, they could&#xA;just retry at 1ppm 10 times and get to 95% chances of success. But if&#xA;they can afford to retry (background rebalancing?), they might as well&#xA;just try at -10ppm, 1ppm, 5ppm, 10ppm (or perhaps with a binary search?),&#xA;and see if they&#39;re lucky; but if they want a 1s response time, and can&#39;t&#xA;afford retries, what good is even a 75% chance of success if that&#39;s the&#xA;individual success rate on each hop of their five hop path?&#xA;&#xA;And if you&#39;re not just going by odds of having to retry, then you need to&#xA;get some current information about the channel to plug into the formula;&#xA;but if you&#39;re getting *current* information, why not let that information&#xA;be the feerate directly?&#xA;&#xA;&gt; More concretely, we set some high feerate, impose some kind of constant &#34;gravity&#34; that pulls down the feerate over time, then we measure the relative loss of outgoing liquidity to serve as &#34;lift&#34; to the feerate.&#xA;&#xA;If your current fee rate is F (ppm), and your current volume (flow) is V&#xA;(sats forwarded per hour), then your profit is FV. If dropping your fee&#xA;rate by dF (&lt;0) results in an increase of V by dV (&gt;0), then you want:&#xA;&#xA;   (F+dF)(V+dV) &gt; FV&#xA;   FV + VdF + FdV + dFdV &gt; FV&#xA;   FdV &gt; -VdF&#xA;   dV/dF &lt; -V/F (flip the inequality because dF is negative)&#xA;&#xA;   (dV/V)/(dF/F) &lt; -1  (fee-elasticity of volume is in the elastic&#xA;                        region)&#xA;&#xA;(&lt;-1 == elastic == flow changes more than the fee does == drop the fee&#xA;rate; &gt;-1 == ineleastic == flow changes less than the fee does == raise&#xA;the fee rate; =-1 == unit elastic == you&#39;ve found a locally optimal&#xA;fee rate)&#xA;&#xA;You could optimise base fee in the same way, if you set F to be sats/tx&#xA;and V to be txs/hour, but then you&#39;re trying to optimise two variables&#xA;on a 2 dimensional plane, which is harder. So probably better to do&#xA;zero base fees and just set it to 0 and ignore it, or use your actual&#xA;computation costs -- perhaps about 20msat if you&#39;re paying $100USD/month&#xA;for your lightning node, a channel update takes 10ms, each forwarded HTLC&#xA;accounts for 4 updates, 2 on the incoming channel, 2 on the outgoing,&#xA;with no batching, and only 40% of payments are successful, at $20k/BTC.&#xA;&#xA;It&#39;s likely more important to have balanced flows than maximally&#xA;profitable ones though, as that&#39;s what allows you to keep your channel&#xA;open. That&#39;s probably pretty hard to optimise, since a changed fee on&#xA;one channel will affect the volume on ther channels as well.&#xA;&#xA;Relatedly:&#xA;&#xA;&gt; I want to propose that all published nodes support some kind of&#xA;&gt; onchain/offchain swap capability.&#xA;&#xA;If you&#39;re running a forwarding node, and collecting fees for forwarding,&#xA;considered in net your channels won&#39;t be balanced: the fees you collect&#xA;are all coming in, and there&#39;s nothing to compensate for that. Having some&#xA;way to send those fees &#34;out&#34; is necessary to keep your channels balanced&#xA;and avoid the need to have to close them. Having a swap capability like&#xA;this is perhaps a relatively easy way to be able to (automatically)&#xA;fix imbalances caused by collecting fees, and thus preserve your older&#xA;channels.&#xA;&#xA;Cheers,&#xA;aj</html></oembed>