Skip to content

Commit

Permalink
multi: deprecate dust-treshold config value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ziggie1984 committed Oct 22, 2024
1 parent c7e3baf commit 34a95bd
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
18 changes: 17 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ type Config struct {

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

MaxFeeExposure uint64 `long:"dust-threshold" description:"Sets the max fee exposure in satoshis for a channel after which HTLC's will be failed."`
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"`

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."`

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

Expand Down Expand Up @@ -1717,6 +1719,20 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
cfg.Pprof.MutexProfile = cfg.MutexProfile
}

// Don't allow both the old dust-threshold and the new
// channel-max-fee-exposure to be set.
defaultExposure := uint64(htlcswitch.DefaultMaxFeeExposure.ToSatoshis())
if cfg.DustThreshold != 0 && cfg.MaxFeeExposure != defaultExposure {
return nil, mkErr("cannot set both dust-threshold and " +
"channel-max-fee-exposure")
}

// Use the old dust-threshold as the max fee exposure if it is set and
// the new option is not (has the default value).
if cfg.DustThreshold != 0 {
cfg.MaxFeeExposure = cfg.DustThreshold
}

// Validate the subconfigs for workers, caches, and the tower client.
err = lncfg.Validate(
cfg.Workers,
Expand Down
4 changes: 2 additions & 2 deletions htlcswitch/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4522,8 +4522,8 @@ func TestSwitchDustForwarding(t *testing.T) {
}

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

Expand Down
2 changes: 1 addition & 1 deletion itest/lnd_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ func testBidirectionalAsyncPayments(ht *lntest.HarnessTest) {
args := []string{
// Increase the dust threshold to avoid the payments fail due
// to threshold limit reached.
"--dust-threshold=10000000",
"--channel-max-fee-exposure=10000000",

// Increase the pending commit interval since there are lots of
// commitment dances.
Expand Down
2 changes: 1 addition & 1 deletion lntest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (h *HarnessTest) SetupStandbyNodes() {

lndArgs := []string{
"--default-remote-max-htlcs=483",
"--dust-threshold=5000000",
"--channel-max-fee-exposure=5000000",
}

// Start the initial seeder nodes within the test network.
Expand Down
30 changes: 26 additions & 4 deletions sample-lnd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,32 @@
; propagation
; max-commit-fee-rate-anchors=10

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

; This value replaces the old 'dust-threshold' setting and defines the maximum
; amount of satoshis that a channel pays in fees in case the commitment
; transaction is broadcasted. This is enforced in both directions either when
; we are the channel intiator hence paying the fees but also applies to the
; channel fee if we are NOT the channel initiator. It is
; important to note that every HTLC adds fees to the channel state. Non-dust
; HTLCs add just a new output onto the commitment transaction whereas dust
; HTLCs are completely attributed the commitment fee. So this limit can also
; influence adding new HTLCs onto the state. When the limit is reached we won't
; allow any new HTLCs onto the channel state (outgoing and incoming). So
; choosing a right limit here must be done with caution. Moreover this is a
; limit for all channels universally meaning there is no difference made due to
; the channel size. So it is recommended to use the default value. However if
; you have a very small channel average size you might want to reduce this
; value.
; WARNING: Setting this value too low might cause force closes because the
; lightning protocol has no way to roll back a channel state when your peer
; proposes a channel update which exceeds this limit. There are only two options
; to resolve this situation, either increasing the limit or one side force
; closes the channel.
; channel-max-fee-exposure=500000

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

0 comments on commit 34a95bd

Please sign in to comment.