Skip to content

Commit 97235dc

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 a040f8f commit 97235dc

File tree

5 files changed

+55
-10
lines changed

5 files changed

+55
-10
lines changed

config.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ type Config struct {
450450

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

453-
MaxFeeExposure uint64 `long:"dust-threshold" description:"Sets the max fee exposure in satoshis for a channel after which HTLC's will be failed."`
453+
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"`
454+
455+
MaxFeeExposure uint64 `long:"channel-max-fee-exposure" description:" Limits the maximum fee exposure in satoshis of a channel. This value is enforced for all channels and is independent of the channel initiator."`
454456

455457
Fee *lncfg.Fee `group:"fee" namespace:"fee"`
456458

@@ -710,7 +712,6 @@ func DefaultConfig() Config {
710712
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
711713
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
712714
MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte,
713-
MaxFeeExposure: uint64(htlcswitch.DefaultMaxFeeExposure.ToSatoshis()),
714715
LogRotator: build.NewRotatingLogWriter(),
715716
DB: lncfg.DefaultDB(),
716717
Cluster: lncfg.DefaultCluster(),
@@ -1714,6 +1715,28 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
17141715
cfg.Pprof.MutexProfile = cfg.MutexProfile
17151716
}
17161717

1718+
// Don't allow both the old dust-threshold and the new
1719+
// channel-max-fee-exposure to be set.
1720+
if cfg.DustThreshold != 0 && cfg.MaxFeeExposure != 0 {
1721+
return nil, mkErr("cannot set both dust-threshold and " +
1722+
"channel-max-fee-exposure")
1723+
}
1724+
1725+
switch {
1726+
1727+
// Use the old dust-threshold as the max fee exposure if it is set and
1728+
// the new option is not.
1729+
case cfg.DustThreshold != 0:
1730+
cfg.MaxFeeExposure = cfg.DustThreshold
1731+
1732+
// Use the default max fee exposure if the new option is not set and
1733+
// the old one is not set either.
1734+
case cfg.MaxFeeExposure == 0:
1735+
cfg.MaxFeeExposure = uint64(
1736+
htlcswitch.DefaultMaxFeeExposure.ToSatoshis(),
1737+
)
1738+
}
1739+
17171740
// Validate the subconfigs for workers, caches, and the tower client.
17181741
err = lncfg.Validate(
17191742
cfg.Workers,

htlcswitch/switch_test.go

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

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

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: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,32 @@
474474
; propagation
475475
; max-commit-fee-rate-anchors=10
476476

477-
; A threshold defining the maximum amount of dust a given channel can have
478-
; after which forwarding and sending dust HTLC's to and from the channel will
479-
; fail. This amount is expressed in satoshis.
480-
; dust-threshold=500000
477+
; DEPRECATED: This value will be deprecated please use the new setting
478+
; "channel-max-fee-exposure". This value is equivalent to the new fee exposure
479+
; limit but was removed because the name was ambigious.
480+
; dust-threshold=
481+
482+
; This value replaces the old 'dust-threshold' setting and defines the maximum
483+
; amount of satoshis that a channel pays in fees in case the commitment
484+
; transaction is broadcasted. This is enforced in both directions either when
485+
; we are the channel intiator hence paying the fees but also applies to the
486+
; channel fee if we are NOT the channel initiator. It is
487+
; important to note that every HTLC adds fees to the channel state. Non-dust
488+
; HTLCs add just a new output onto the commitment transaction whereas dust
489+
; HTLCs are completely attributed the commitment fee. So this limit can also
490+
; influence adding new HTLCs onto the state. When the limit is reached we won't
491+
; allow any new HTLCs onto the channel state (outgoing and incoming). So
492+
; choosing a right limit here must be done with caution. Moreover this is a
493+
; limit for all channels universally meaning there is no difference made due to
494+
; the channel size. So it is recommended to use the default value. However if
495+
; you have a very small channel average size you might want to reduce this
496+
; value.
497+
; WARNING: Setting this value too low might cause force closes because the
498+
; lightning protocol has no way to roll back a channel state when your peer
499+
; proposes a channel update which exceeds this limit. There are only two options
500+
; to resolve this situation, either increasing the limit or one side force
501+
; closes the channel.
502+
; channel-max-fee-exposure=500000
481503

482504
; If true, lnd will abort committing a migration if it would otherwise have been
483505
; successful. This leaves the database unmodified, and still compatible with the

0 commit comments

Comments
 (0)