Merge pull request #7771 from ellemouton/towerConfigDefaults
multi: add tower config defaults
This commit is contained in:
7 files changed
+79
-45
No files matched your search
@@ -638,9 +638,7 @@ func DefaultConfig() Config {
|
|||||||
ChannelCacheSize: channeldb.DefaultChannelCacheSize,
|
ChannelCacheSize: channeldb.DefaultChannelCacheSize,
|
||||||
},
|
},
|
||||||
Prometheus: lncfg.DefaultPrometheus(),
|
Prometheus: lncfg.DefaultPrometheus(),
|
||||||
Watchtower: &lncfg.Watchtower{
|
Watchtower: lncfg.DefaultWatchtowerCfg(defaultTowerDir),
|
||||||
TowerDir: defaultTowerDir,
|
|
||||||
},
|
|
||||||
HealthChecks: &lncfg.HealthCheckConfig{
|
HealthChecks: &lncfg.HealthCheckConfig{
|
||||||
ChainCheck: &lncfg.CheckConfig{
|
ChainCheck: &lncfg.CheckConfig{
|
||||||
Interval: defaultChainInterval,
|
Interval: defaultChainInterval,
|
||||||
@@ -713,6 +711,7 @@ func DefaultConfig() Config {
|
|||||||
ServerPingTimeout: defaultGrpcServerPingTimeout,
|
ServerPingTimeout: defaultGrpcServerPingTimeout,
|
||||||
ClientPingMinWait: defaultGrpcClientPingMinWait,
|
ClientPingMinWait: defaultGrpcClientPingMinWait,
|
||||||
},
|
},
|
||||||
|
WtClient: lncfg.DefaultWtClientCfg(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,19 @@
|
|||||||
wtdb.BackupIDs](https://github.com/lightningnetwork/lnd/pull/7623) instead of
|
wtdb.BackupIDs](https://github.com/lightningnetwork/lnd/pull/7623) instead of
|
||||||
the entire retribution struct. This reduces the amount of data that needs to
|
the entire retribution struct. This reduces the amount of data that needs to
|
||||||
be held in memory.
|
be held in memory.
|
||||||
|
|
||||||
* [Replace in-mem task pipeline with a disk-overflow
|
* [Replace in-mem task pipeline with a disk-overflow
|
||||||
queue](https://github.com/lightningnetwork/lnd/pull/7380)
|
queue](https://github.com/lightningnetwork/lnd/pull/7380)
|
||||||
|
|
||||||
|
* [Add defaults](https://github.com/lightningnetwork/lnd/pull/7771) to the
|
||||||
|
wtclient and watchtower config structs and use these to populate the defaults
|
||||||
|
of the main LND config struct so that the defaults appear in the `lnd --help`
|
||||||
|
command output.
|
||||||
|
|
||||||
|
* The deprecated "wtclient.private-tower-uris" option has also been
|
||||||
|
[removed](https://github.com/lightningnetwork/lnd/pull/7771). This field was
|
||||||
|
deprecated in v0.8.0-beta.
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
|
|
||||||
* [Ensure that both the byte and string form of a TXID is populated in the
|
* [Ensure that both the byte and string form of a TXID is populated in the
|
||||||
|
|||||||
@@ -13,3 +13,14 @@ type Watchtower struct {
|
|||||||
|
|
||||||
watchtower.Conf
|
watchtower.Conf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultWatchtowerCfg creates a Watchtower with some default values filled
|
||||||
|
// out.
|
||||||
|
func DefaultWatchtowerCfg(defaultTowerDir string) *Watchtower {
|
||||||
|
conf := watchtower.DefaultConf()
|
||||||
|
|
||||||
|
return &Watchtower{
|
||||||
|
TowerDir: defaultTowerDir,
|
||||||
|
Conf: *conf,
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
-12
@@ -1,6 +1,11 @@
|
|||||||
package lncfg
|
package lncfg
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/watchtower/wtclient"
|
||||||
|
"github.com/lightningnetwork/lnd/watchtower/wtpolicy"
|
||||||
|
)
|
||||||
|
|
||||||
// WtClient holds the configuration options for the daemon's watchtower client.
|
// WtClient holds the configuration options for the daemon's watchtower client.
|
||||||
//
|
//
|
||||||
@@ -10,10 +15,6 @@ type WtClient struct {
|
|||||||
// back up channel states with registered watchtowers.
|
// back up channel states with registered watchtowers.
|
||||||
Active bool `long:"active" description:"Whether the daemon should use private watchtowers to back up revoked channel states."`
|
Active bool `long:"active" description:"Whether the daemon should use private watchtowers to back up revoked channel states."`
|
||||||
|
|
||||||
// PrivateTowerURIs specifies the lightning URIs of the towers the
|
|
||||||
// watchtower client should send new backups to.
|
|
||||||
PrivateTowerURIs []string `long:"private-tower-uris" description:"(Deprecated) Specifies the URIs of private watchtowers to use in backing up revoked states. URIs must be of the form <pubkey>@<addr>. Only 1 URI is supported at this time, if none are provided the tower will not be enabled."`
|
|
||||||
|
|
||||||
// SweepFeeRate specifies the fee rate in sat/byte to be used when
|
// SweepFeeRate specifies the fee rate in sat/byte to be used when
|
||||||
// constructing justice transactions sent to the tower.
|
// constructing justice transactions sent to the tower.
|
||||||
SweepFeeRate uint64 `long:"sweep-fee-rate" description:"Specifies the fee rate in sat/byte to be used when constructing justice transactions sent to the watchtower."`
|
SweepFeeRate uint64 `long:"sweep-fee-rate" description:"Specifies the fee rate in sat/byte to be used when constructing justice transactions sent to the watchtower."`
|
||||||
@@ -32,17 +33,41 @@ type WtClient struct {
|
|||||||
MaxUpdates uint16 `long:"max-updates" description:"The maximum number of updates to be backed up in a single session."`
|
MaxUpdates uint16 `long:"max-updates" description:"The maximum number of updates to be backed up in a single session."`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultWtClientCfg returns the WtClient config struct with some default
|
||||||
|
// values populated.
|
||||||
|
func DefaultWtClientCfg() *WtClient {
|
||||||
|
// The sweep fee rate used internally by the tower client is in sats/kw
|
||||||
|
// but the config exposed to the user is in sats/byte, so we convert the
|
||||||
|
// default here before exposing it to the user.
|
||||||
|
sweepSatsPerKvB := wtpolicy.DefaultSweepFeeRate.FeePerKVByte()
|
||||||
|
sweepFeeRate := uint64(sweepSatsPerKvB / 1000)
|
||||||
|
|
||||||
|
return &WtClient{
|
||||||
|
SweepFeeRate: sweepFeeRate,
|
||||||
|
SessionCloseRange: wtclient.DefaultSessionCloseRange,
|
||||||
|
MaxTasksInMemQueue: wtclient.DefaultMaxTasksInMemQueue,
|
||||||
|
MaxUpdates: wtpolicy.DefaultMaxUpdates,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Validate ensures the user has provided a valid configuration.
|
// Validate ensures the user has provided a valid configuration.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the Validator interface.
|
// NOTE: Part of the Validator interface.
|
||||||
func (c *WtClient) Validate() error {
|
func (c *WtClient) Validate() error {
|
||||||
// TODO(wilmer): remove in v0.9.0 release.
|
if c.SweepFeeRate == 0 {
|
||||||
if len(c.PrivateTowerURIs) > 0 {
|
return fmt.Errorf("sweep-fee-rate must be non-zero")
|
||||||
return fmt.Errorf("the `wtclient.private-tower-uris` option " +
|
}
|
||||||
"has been deprecated as of v0.8.0-beta and will be " +
|
|
||||||
"removed in v0.9.0-beta. To setup watchtowers for " +
|
if c.MaxUpdates == 0 {
|
||||||
"the client, set `wtclient.active` and run " +
|
return fmt.Errorf("max-updates must be non-zero")
|
||||||
"`lncli wtclient -h` for more information")
|
}
|
||||||
|
|
||||||
|
if c.MaxTasksInMemQueue == 0 {
|
||||||
|
return fmt.Errorf("max-tasks-in-mem-queue must be non-zero")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.SessionCloseRange == 0 {
|
||||||
|
return fmt.Errorf("session-close-range must be non-zero")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -992,11 +992,6 @@ litecoin.node=ltcd
|
|||||||
; specified in sat/byte, the default is 10 sat/byte.
|
; specified in sat/byte, the default is 10 sat/byte.
|
||||||
; wtclient.sweep-fee-rate=10
|
; wtclient.sweep-fee-rate=10
|
||||||
|
|
||||||
; (Deprecated) Specifies the URIs of private watchtowers to use in backing up
|
|
||||||
; revoked states. URIs must be of the form <pubkey>@<addr>. Only 1 URI is
|
|
||||||
; supported at this time, if none are provided the tower will not be enabled.
|
|
||||||
; wtclient.private-tower-uris=
|
|
||||||
|
|
||||||
; The range over which to choose a random number of blocks to wait after the
|
; The range over which to choose a random number of blocks to wait after the
|
||||||
; last channel of a session is closed before sending the DeleteSession message
|
; last channel of a session is closed before sending the DeleteSession message
|
||||||
; to the tower server. The default is currently 288. Note that setting this to
|
; to the tower server. The default is currently 288. Note that setting this to
|
||||||
|
|||||||
@@ -1497,29 +1497,15 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
|
|
||||||
if cfg.WtClient.Active {
|
if cfg.WtClient.Active {
|
||||||
policy := wtpolicy.DefaultPolicy()
|
policy := wtpolicy.DefaultPolicy()
|
||||||
|
policy.MaxUpdates = cfg.WtClient.MaxUpdates
|
||||||
|
|
||||||
if cfg.WtClient.SweepFeeRate != 0 {
|
// We expose the sweep fee rate in sat/vbyte, but the tower
|
||||||
// We expose the sweep fee rate in sat/vbyte, but the
|
// protocol operations on sat/kw.
|
||||||
// tower protocol operations on sat/kw.
|
sweepRateSatPerVByte := chainfee.SatPerKVByte(
|
||||||
sweepRateSatPerVByte := chainfee.SatPerKVByte(
|
1000 * cfg.WtClient.SweepFeeRate,
|
||||||
1000 * cfg.WtClient.SweepFeeRate,
|
)
|
||||||
)
|
|
||||||
policy.SweepFeeRate = sweepRateSatPerVByte.FeePerKWeight()
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.WtClient.MaxUpdates != 0 {
|
policy.SweepFeeRate = sweepRateSatPerVByte.FeePerKWeight()
|
||||||
policy.MaxUpdates = cfg.WtClient.MaxUpdates
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionCloseRange := uint32(wtclient.DefaultSessionCloseRange)
|
|
||||||
if cfg.WtClient.SessionCloseRange != 0 {
|
|
||||||
sessionCloseRange = cfg.WtClient.SessionCloseRange
|
|
||||||
}
|
|
||||||
|
|
||||||
maxTasksInMemQueue := uint64(wtclient.DefaultMaxTasksInMemQueue)
|
|
||||||
if cfg.WtClient.MaxTasksInMemQueue != 0 {
|
|
||||||
maxTasksInMemQueue = cfg.WtClient.MaxTasksInMemQueue
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := policy.Validate(); err != nil {
|
if err := policy.Validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1565,7 +1551,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
s.towerClient, err = wtclient.New(&wtclient.Config{
|
s.towerClient, err = wtclient.New(&wtclient.Config{
|
||||||
FetchClosedChannel: fetchClosedChannel,
|
FetchClosedChannel: fetchClosedChannel,
|
||||||
BuildBreachRetribution: buildBreachRetribution,
|
BuildBreachRetribution: buildBreachRetribution,
|
||||||
SessionCloseRange: sessionCloseRange,
|
SessionCloseRange: cfg.WtClient.SessionCloseRange,
|
||||||
ChainNotifier: s.cc.ChainNotifier,
|
ChainNotifier: s.cc.ChainNotifier,
|
||||||
SubscribeChannelEvents: func() (subscribe.Subscription,
|
SubscribeChannelEvents: func() (subscribe.Subscription,
|
||||||
error) {
|
error) {
|
||||||
@@ -1584,7 +1570,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
MinBackoff: 10 * time.Second,
|
MinBackoff: 10 * time.Second,
|
||||||
MaxBackoff: 5 * time.Minute,
|
MaxBackoff: 5 * time.Minute,
|
||||||
ForceQuitDelay: wtclient.DefaultForceQuitDelay,
|
ForceQuitDelay: wtclient.DefaultForceQuitDelay,
|
||||||
MaxTasksInMemQueue: maxTasksInMemQueue,
|
MaxTasksInMemQueue: cfg.WtClient.MaxTasksInMemQueue,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1599,7 +1585,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
s.anchorTowerClient, err = wtclient.New(&wtclient.Config{
|
s.anchorTowerClient, err = wtclient.New(&wtclient.Config{
|
||||||
FetchClosedChannel: fetchClosedChannel,
|
FetchClosedChannel: fetchClosedChannel,
|
||||||
BuildBreachRetribution: buildBreachRetribution,
|
BuildBreachRetribution: buildBreachRetribution,
|
||||||
SessionCloseRange: sessionCloseRange,
|
SessionCloseRange: cfg.WtClient.SessionCloseRange,
|
||||||
ChainNotifier: s.cc.ChainNotifier,
|
ChainNotifier: s.cc.ChainNotifier,
|
||||||
SubscribeChannelEvents: func() (subscribe.Subscription,
|
SubscribeChannelEvents: func() (subscribe.Subscription,
|
||||||
error) {
|
error) {
|
||||||
@@ -1618,7 +1604,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
MinBackoff: 10 * time.Second,
|
MinBackoff: 10 * time.Second,
|
||||||
MaxBackoff: 5 * time.Minute,
|
MaxBackoff: 5 * time.Minute,
|
||||||
ForceQuitDelay: wtclient.DefaultForceQuitDelay,
|
ForceQuitDelay: wtclient.DefaultForceQuitDelay,
|
||||||
MaxTasksInMemQueue: maxTasksInMemQueue,
|
MaxTasksInMemQueue: cfg.WtClient.MaxTasksInMemQueue,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ type Conf struct {
|
|||||||
WriteTimeout time.Duration `long:"writetimeout" description:"Duration the watchtower server will wait for messages to be written before hanging up on client connections"`
|
WriteTimeout time.Duration `long:"writetimeout" description:"Duration the watchtower server will wait for messages to be written before hanging up on client connections"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultConf returns a Conf with some default values filled in.
|
||||||
|
func DefaultConf() *Conf {
|
||||||
|
return &Conf{
|
||||||
|
ReadTimeout: DefaultReadTimeout,
|
||||||
|
WriteTimeout: DefaultWriteTimeout,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Apply completes the passed Config struct by applying any parsed Conf options.
|
// Apply completes the passed Config struct by applying any parsed Conf options.
|
||||||
// If the corresponding values parsed by Conf are already set in the Config,
|
// If the corresponding values parsed by Conf are already set in the Config,
|
||||||
// those fields will be not be modified.
|
// those fields will be not be modified.
|
||||||
|
|||||||
Reference in new issue
Block a user