Skip to content

Commit e31c4d8

Browse files
committed
multi: deprecate dust-treshold config value
Replace ambigious config value "dust-treshold" with a more clear "channel-max-fee-exposure" exposure value. The old value is deprecated and will be removed in the near future.
1 parent 5c61dd7 commit e31c4d8

File tree

6 files changed

+47
-10
lines changed

6 files changed

+47
-10
lines changed

config.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ type Config struct {
454454

455455
GcCanceledInvoicesOnTheFly bool `long:"gc-canceled-invoices-on-the-fly" description:"If true, we'll delete newly canceled invoices on the fly."`
456456

457-
MaxFeeExposure uint64 `long:"dust-threshold" description:"Sets the max fee exposure in satoshis for a channel after which HTLC's will be failed."`
457+
DustThreshold uint64 `long:"dust-threshold" description:"DEPRECATED: Sets the max fee exposure in satoshis for a channel after which HTLC's will be failed." hidden:"true"`
458+
459+
MaxFeeExposure uint64 `long:"channel-max-fee-exposure" description:" Limits the maximum fee exposure in sathosis of a channel. This value is enforced for all channels and is independent of the channel initiator."`
458460

459461
Fee *lncfg.Fee `group:"fee" namespace:"fee"`
460462

@@ -714,6 +716,7 @@ func DefaultConfig() Config {
714716
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
715717
MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte,
716718
MaxFeeExposure: uint64(htlcswitch.DefaultMaxFeeExposure.ToSatoshis()),
719+
DustThreshold: uint64(htlcswitch.DefaultMaxFeeExposure.ToSatoshis()),
717720
LogWriter: build.NewRotatingLogWriter(),
718721
DB: lncfg.DefaultDB(),
719722
Cluster: lncfg.DefaultCluster(),
@@ -1700,6 +1703,18 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
17001703
return nil, mkErr("custom-message: %v", err)
17011704
}
17021705

1706+
// Don't allow both the old dust-threshold and the new
1707+
// channel-max-fee-exposure to be set.
1708+
if cfg.DustThreshold != 0 && cfg.MaxFeeExposure != 0 {
1709+
return nil, mkErr("cannot set both dust-threshold and " +
1710+
"channel-max-fee-exposure")
1711+
}
1712+
1713+
// Map the old dust-threshold to the new channel-max-fee-exposure.
1714+
if cfg.DustThreshold != 0 {
1715+
cfg.MaxFeeExposure = cfg.DustThreshold
1716+
}
1717+
17031718
// Validate the subconfigs for workers, caches, and the tower client.
17041719
err = lncfg.Validate(
17051720
cfg.Workers,

htlcswitch/switch_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4522,8 +4522,8 @@ func TestSwitchDustForwarding(t *testing.T) {
45224522
}
45234523

45244524
// sendDustHtlcs is a helper function used to send many dust HTLC's to test the
4525-
// Switch's dust-threshold logic. It takes a boolean denoting whether or not
4526-
// Alice is the sender.
4525+
// Switch's channel-max-fee-exposure logic. It takes a boolean denoting whether
4526+
// or not Alice is the sender.
45274527
func sendDustHtlcs(t *testing.T, n *threeHopNetwork, alice bool,
45284528
amt lnwire.MilliSatoshi, sid lnwire.ShortChannelID, numHTLCs int) {
45294529

itest/lnd_payment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ func testBidirectionalAsyncPayments(ht *lntest.HarnessTest) {
820820
args := []string{
821821
// Increase the dust threshold to avoid the payments fail due
822822
// to threshold limit reached.
823-
"--dust-threshold=10000000",
823+
"--channel-max-fee-exposure=10000000",
824824

825825
// Increase the pending commit interval since there are lots of
826826
// commitment dances.

lntest/harness.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func (h *HarnessTest) SetupStandbyNodes() {
316316

317317
lndArgs := []string{
318318
"--default-remote-max-htlcs=483",
319-
"--dust-threshold=5000000",
319+
"--channel-max-fee-exposure=5000000",
320320
}
321321

322322
// Start the initial seeder nodes within the test network.

sample-lnd.conf

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,33 @@
467467
; propagation
468468
; max-commit-fee-rate-anchors=10
469469

470-
; A threshold defining the maximum amount of dust a given channel can have
471-
; after which forwarding and sending dust HTLC's to and from the channel will
472-
; fail. This amount is expressed in satoshis.
470+
; DEPRECATED: This value will be deprecated please use the new setting
471+
; 'channel-max-fee-exposure'. This value is equivalent to the new fee exposure
472+
; limit but was removed because the name was ambigious.
473473
; dust-threshold=500000
474474

475+
; This value replaces the old 'dust-threshold' setting and defines the maximum
476+
; amount of satoshis that a channel pays in fees in case the commitment
477+
; transaction is broadcasted. This is enforced in both directions either when
478+
; we are the channel intiator hence paying the fees but also applies to the
479+
; channel fee if we are NOT the channel initiator. It is
480+
; important to note that every HTLC adds fees to the channel state. Non-dust
481+
; HTLCs add just a new output onto the commitment transaction whereas dust
482+
; HTLCs are completely attributed the commitment fee. So this limit can also
483+
; influence adding new HTLCs onto the state. When the limit is reached we won't
484+
; allow any new HTLCs onto the channel state (outgoing and incoming). So
485+
; choosing a right limit here must be done with caution. Moreover this is a
486+
; limit for all channels universially meaning there is no difference made due to
487+
; the channel size. So it is recommended to use the default value. However if
488+
; you have a very small channel average size you might want to reduce this
489+
; value.
490+
; Setting this value too low might cause force closes because the lightning
491+
; protocol has no way to roll back a channel state when your peer proposes a
492+
; channel update which exceeds this limit there are only two options to resolve
493+
; the situation. You can either increase the limit and the channel should be
494+
; fully functional again or one side has to force close the channel.
495+
; channel-max-fee-exposure=500000
496+
475497
; If true, lnd will abort committing a migration if it would otherwise have been
476498
; successful. This leaves the database unmodified, and still compatible with the
477499
; previously active version of lnd.

server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
661661

662662
s.htlcNotifier = htlcswitch.NewHtlcNotifier(time.Now)
663663

664-
thresholdSats := btcutil.Amount(cfg.MaxFeeExposure)
664+
thresholdSats := htlcswitch.DefaultMaxFeeExposure.ToSatoshis()
665665
thresholdMSats := lnwire.NewMSatFromSatoshis(thresholdSats)
666666

667667
linkUpdater := func(shortID lnwire.ShortChannelID) error {
@@ -4105,7 +4105,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
41054105
towerClient = s.towerClientMgr
41064106
}
41074107

4108-
thresholdSats := btcutil.Amount(s.cfg.MaxFeeExposure)
4108+
thresholdSats := htlcswitch.DefaultMaxFeeExposure.ToSatoshis()
41094109
thresholdMSats := lnwire.NewMSatFromSatoshis(thresholdSats)
41104110

41114111
// Now that we've established a connection, create a peer, and it to the

0 commit comments

Comments
 (0)