multi: introduce config-level DustThreshold for defining threshold

This commit is contained in:
eugene committed 2021-09-30 13:44:35 -04:00
1 parent 3897baff0a
commit 702b3a3258
6 files changed
+23 -5

No files matched your search

+3
View File
@@ -355,6 +355,8 @@ type Config struct {
GcCanceledInvoicesOnTheFly bool `long:"gc-canceled-invoices-on-the-fly" description:"If true, we'll delete newly canceled invoices on the fly."`
DustThreshold uint64 `long:"dust-threshold" description:"Sets the dust sum threshold in satoshis for a channel after which dust HTLC's will be failed."`
Invoices *lncfg.Invoices `group:"invoices" namespace:"invoices"`
Routing *lncfg.Routing `group:"routing" namespace:"routing"`
@@ -550,6 +552,7 @@ func DefaultConfig() Config {
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
MaxCommitFeeRateAnchors: lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte,
DustThreshold: uint64(htlcswitch.DefaultDustThreshold.ToSatoshis()),
LogWriter: build.NewRotatingLogWriter(),
DB: lncfg.DefaultDB(),
Cluster: lncfg.DefaultCluster(),
+1
View File
@@ -189,6 +189,7 @@ func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error)
HtlcNotifier: &mockHTLCNotifier{},
Clock: clock.NewDefaultClock(),
HTLCExpiry: time.Hour,
DustThreshold: DefaultDustThreshold,
}
return New(cfg, startingHeight)
+9 -5
View File
@@ -77,9 +77,9 @@ var (
// threshold.
errDustThresholdExceeded = errors.New("dust threshold exceeded")
// defaultDustThreshold is the default threshold after which we'll fail
// payments if they are dust. This is currently set to 500k sats.
defaultDustThreshold = lnwire.MilliSatoshi(500_000_000)
// DefaultDustThreshold is the default threshold after which we'll fail
// payments if they are dust. This is currently set to 500m msats.
DefaultDustThreshold = lnwire.MilliSatoshi(500_000_000)
)
// plexPacket encapsulates switch packet and adds error channel to receive
@@ -187,6 +187,10 @@ type Config struct {
// will expiry this long after the Adds are added to a mailbox via
// AddPacket.
HTLCExpiry time.Duration
// DustThreshold is the threshold in milli-satoshis after which we'll
// fail incoming or outgoing dust payments for a particular channel.
DustThreshold lnwire.MilliSatoshi
}
// Switch is the central messaging bus for all incoming/outgoing HTLCs.
@@ -2375,7 +2379,7 @@ func (s *Switch) evaluateDustThreshold(link ChannelLink,
}
// Finally check against the defined dust threshold.
if localSum > defaultDustThreshold {
if localSum > s.cfg.DustThreshold {
return true
}
}
@@ -2393,7 +2397,7 @@ func (s *Switch) evaluateDustThreshold(link ChannelLink,
}
// Finally check against the defined dust threshold.
if remoteSum > defaultDustThreshold {
if remoteSum > s.cfg.DustThreshold {
return true
}
}
+1
View File
@@ -203,6 +203,7 @@ func TestLightningNetworkDaemon(t *testing.T) {
// TODO(roasbeef): create master balanced channel with all the monies?
aliceBobArgs := []string{
"--default-remote-max-htlcs=483",
"--dust-threshold=5000000",
}
// Run the subset of the test cases selected in this tranche.
+5
View File
@@ -365,6 +365,11 @@
; propagation (default: 10)
; max-commit-fee-rate-anchors=5
; 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. (default: 500000)
; dust-threshold=1000000
; 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
; previously active version of lnd.
+4
View File
@@ -490,6 +490,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
s.htlcNotifier = htlcswitch.NewHtlcNotifier(time.Now)
thresholdSats := btcutil.Amount(cfg.DustThreshold)
thresholdMSats := lnwire.NewMSatFromSatoshis(thresholdSats)
s.htlcSwitch, err = htlcswitch.New(htlcswitch.Config{
DB: dbs.chanStateDB,
LocalChannelClose: func(pubKey []byte,
@@ -519,6 +522,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
RejectHTLC: cfg.RejectHTLC,
Clock: clock.NewDefaultClock(),
HTLCExpiry: htlcswitch.DefaultHTLCExpiry,
DustThreshold: thresholdMSats,
}, uint32(currentHeight))
if err != nil {
return nil, err