Difference between revisions of "Using Charge-Lnd to Adjust HTLC Limits"

From PlebNet Wiki
Jump to navigation Jump to search
 
Line 5: Line 5:
Charge-Lnd can be used to automatically adjust your max-htlc limits on your channels. Today it is not possible to set up in the main configuration file along with the fees and there is an [https://github.com/accumulator/charge-lnd/issues/48 open issue report] for that. However the following workaround can be done to set up max-htlc.
Charge-Lnd can be used to automatically adjust your max-htlc limits on your channels. Today it is not possible to set up in the main configuration file along with the fees and there is an [https://github.com/accumulator/charge-lnd/issues/48 open issue report] for that. However the following workaround can be done to set up max-htlc.


====Getting Started====
You can use special fork of charge-lnd to set max_htlc_msat = local balance. [https://plebnet.wiki/wiki/Fees_And_Profitability#Using_Charge-Lnd_to_set_Maximum_HTLCs See here for installation instructions]
 
If you don't already have Charge-Lnd, please see the installation instructions near the bottom of [[Fees And Profitability]], and familiarize yourself with how it works before following the rest of this guide.
Ok, you should have already created a Charge-Lnd config file for your fee policy. Now let's make a new config file for our max-htlc policy.
 
<code>nano ~/charge-lnd/maxhtlc</code>
 
Now you are ready to input your max-htlc settings. It's very wordy since we are using Charge-Lnd. Paste in the following and adjust as you wish. For example, you can reduce the granularity level and go by 20% steps instead of 10% steps.
 
 
<pre>
#When your channel is full of outbound liquity, aka local balance, you allow any size transaction to go through.
[100]
strategy = static
chan.min_ratio = 1
max_htlc_msat_ratio = 1
 
#When your channel is above 90% outbound liquity, you allow any size transaction to flow through your channel that is 90% of your channel size or less.
[90]
strategy = static
chan.min_ratio = 0.9
max_htlc_msat_ratio = 0.9
 
#And so on...
[80]
strategy = static
chan.min_ratio = 0.8
max_htlc_msat_ratio = 0.8
 
[70]
strategy = static
chan.min_ratio = 0.7
max_htlc_msat_ratio = 0.7
 
[60]
strategy = static
chan.min_ratio = 0.6
max_htlc_msat_ratio = 0.6
 
[50]
strategy = static
chan.min_ratio = 0.5
max_htlc_msat_ratio = 0.5
 
#As your channel outbound liquidity depletes, the max htlc limit becomes more and more relevant. So it makes sense to increase the intervals of adjustment.
[45]
strategy = static
chan.min_ratio = 0.45
max_htlc_msat_ratio = 0.45
 
[40]
strategy = static
chan.min_ratio = 0.4
max_htlc_msat_ratio = 0.4
 
[35]
strategy = static
chan.min_ratio = 0.35
max_htlc_msat_ratio = 0.35
 
[30]
strategy = static
chan.min_ratio = 0.3
max_htlc_msat_ratio = 0.3
 
[25]
strategy = static
chan.min_ratio = 0.25
max_htlc_msat_ratio = 0.25
 
[20]
strategy = static
chan.min_ratio = 0.2
max_htlc_msat_ratio = 0.2
 
[15]
strategy = static
chan.min_ratio = 0.15
max_htlc_msat_ratio = 0.15
 
#Now the intervals will be increased further.
[12.5]
strategy = static
chan.min_ratio = 0.125
max_htlc_msat_ratio = 0.125
 
[10]
strategy = static
chan.min_ratio = 0.1
max_htlc_msat_ratio = 0.1
 
[7.5]
strategy = static
chan.min_ratio = 0.075
max_htlc_msat_ratio = 0.075
 
[5]
strategy = static
chan.min_ratio = 0.05
max_htlc_msat_ratio = 0.05
 
[2.5]
strategy = static
chan.min_ratio = 0.025
max_htlc_msat_ratio = 0.025
 
[1]
strategy = static
chan.min_ratio = 0.01
max_htlc_msat_ratio = 0.01
 
#If your channel outbound liquidity is less than 1% of the channel size, it may be time to stop routing and rebalance.
[0]
strategy = static
max_htlc_msat = 1_000
</pre>
 
To exit the new maxhtlc policy config file,
<code>Ctrl+X</code> then <code>Y</code> then <code>Enter</code>
 
To run a test of how it will affect your channels, you can do a dry-run.
 
<code>~/.local/bin/charge-lnd --lnddir ~/umbrel/lnd -c ~/charge-lnd/maxhtlc --dry-run</code>
 
If you are happy with how it is operating, you can remove <code>--dry-run</code> and it will be applied to your channels.
 
====Auto-Adjust====
 
To make it run every so often and update the max-htlc setting for a channel shortly after liquidity moves, you can add it to your crontab.
 
<code>crontab -e</code>
 
Then paste in the following job:
 
<code>33 * * * * /home/umbrel/.local/bin/charge-lnd --lnddir /home/umbrel/umbrel/lnd -c /home/umbrel/charge-lnd/maxhtlc > /tmp/charge-lnd.log 2>&1; date >> /tmp/charge-lnd.log</code>
 
Replace the number "33" with a random number between 0 and 59. This will be the minute of each hour when it updates. We don't want everyone to pick the same minute which could theoretically harm the gossip network.
 
To avoid excessive gossip, you should try not to run it more than once per hour.
Also, note that if you run both proportional fees and max-htlc policy you would be doubling the amount of gossip. You may want to consider static fees with max-htlc policy.
 
To exit cron,
<code>Ctrl+X</code> then <code>Y</code> then <code>Enter</code>

Latest revision as of 17:56, 6 October 2021

A maximum htlc setting can be used to limit the amount of outbound liquidity that can pass through a channel, subject to channel outbound liquidity. This can be a good thing, because when someone tries to forward a payment through one of your channels, but that channel doesn't have enough liquidity, it will cause a payment failure at your node. If your node gets a lot of payment failures it may affect your node's reliability reputation in the network. By setting max-htlc limits so that your channels are only considered when they have enough liquidity to handle the payment, it can reduce the number of failures your node experiences, and improve the lightning network as a whole.

Note that max-htlc settings don't limit the amount of incoming liquidity a channel can receive, which is good. Incoming liquidity is not what causes failures on your node, and it also allows for your locally depleted channels to have liquidity flow back into them without any issue, despite low maximum htlcs.

Charge-Lnd can be used to automatically adjust your max-htlc limits on your channels. Today it is not possible to set up in the main configuration file along with the fees and there is an open issue report for that. However the following workaround can be done to set up max-htlc.

You can use special fork of charge-lnd to set max_htlc_msat = local balance. See here for installation instructions