mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 14:45:23 +01:00
Merge pull request #7771 from ellemouton/towerConfigDefaults
multi: add tower config defaults
This commit is contained in:
commit
2e1b6597cf
@ -638,9 +638,7 @@ func DefaultConfig() Config {
|
||||
ChannelCacheSize: channeldb.DefaultChannelCacheSize,
|
||||
},
|
||||
Prometheus: lncfg.DefaultPrometheus(),
|
||||
Watchtower: &lncfg.Watchtower{
|
||||
TowerDir: defaultTowerDir,
|
||||
},
|
||||
Watchtower: lncfg.DefaultWatchtowerCfg(defaultTowerDir),
|
||||
HealthChecks: &lncfg.HealthCheckConfig{
|
||||
ChainCheck: &lncfg.CheckConfig{
|
||||
Interval: defaultChainInterval,
|
||||
@ -713,6 +711,7 @@ func DefaultConfig() Config {
|
||||
ServerPingTimeout: defaultGrpcServerPingTimeout,
|
||||
ClientPingMinWait: defaultGrpcClientPingMinWait,
|
||||
},
|
||||
WtClient: lncfg.DefaultWtClientCfg(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,19 @@
|
||||
wtdb.BackupIDs](https://github.com/lightningnetwork/lnd/pull/7623) instead of
|
||||
the entire retribution struct. This reduces the amount of data that needs to
|
||||
be held in memory.
|
||||
|
||||
* [Replace in-mem task pipeline with a disk-overflow
|
||||
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
|
||||
|
||||
* [Ensure that both the byte and string form of a TXID is populated in the
|
||||
|
@ -13,3 +13,14 @@ type Watchtower struct {
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
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.
|
||||
//
|
||||
@ -10,10 +15,6 @@ type WtClient struct {
|
||||
// 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."`
|
||||
|
||||
// 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
|
||||
// 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."`
|
||||
@ -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."`
|
||||
}
|
||||
|
||||
// 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.
|
||||
//
|
||||
// NOTE: Part of the Validator interface.
|
||||
func (c *WtClient) Validate() error {
|
||||
// TODO(wilmer): remove in v0.9.0 release.
|
||||
if len(c.PrivateTowerURIs) > 0 {
|
||||
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 " +
|
||||
"the client, set `wtclient.active` and run " +
|
||||
"`lncli wtclient -h` for more information")
|
||||
if c.SweepFeeRate == 0 {
|
||||
return fmt.Errorf("sweep-fee-rate must be non-zero")
|
||||
}
|
||||
|
||||
if c.MaxUpdates == 0 {
|
||||
return fmt.Errorf("max-updates must be non-zero")
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -992,11 +992,6 @@ litecoin.node=ltcd
|
||||
; specified in sat/byte, the default is 10 sat/byte.
|
||||
; 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
|
||||
; 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
|
||||
|
36
server.go
36
server.go
@ -1497,29 +1497,15 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
|
||||
if cfg.WtClient.Active {
|
||||
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 protocol operations on sat/kw.
|
||||
sweepRateSatPerVByte := chainfee.SatPerKVByte(
|
||||
1000 * cfg.WtClient.SweepFeeRate,
|
||||
)
|
||||
policy.SweepFeeRate = sweepRateSatPerVByte.FeePerKWeight()
|
||||
}
|
||||
// We expose the sweep fee rate in sat/vbyte, but the tower
|
||||
// protocol operations on sat/kw.
|
||||
sweepRateSatPerVByte := chainfee.SatPerKVByte(
|
||||
1000 * cfg.WtClient.SweepFeeRate,
|
||||
)
|
||||
|
||||
if cfg.WtClient.MaxUpdates != 0 {
|
||||
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
|
||||
}
|
||||
policy.SweepFeeRate = sweepRateSatPerVByte.FeePerKWeight()
|
||||
|
||||
if err := policy.Validate(); err != nil {
|
||||
return nil, err
|
||||
@ -1565,7 +1551,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
s.towerClient, err = wtclient.New(&wtclient.Config{
|
||||
FetchClosedChannel: fetchClosedChannel,
|
||||
BuildBreachRetribution: buildBreachRetribution,
|
||||
SessionCloseRange: sessionCloseRange,
|
||||
SessionCloseRange: cfg.WtClient.SessionCloseRange,
|
||||
ChainNotifier: s.cc.ChainNotifier,
|
||||
SubscribeChannelEvents: func() (subscribe.Subscription,
|
||||
error) {
|
||||
@ -1584,7 +1570,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
MinBackoff: 10 * time.Second,
|
||||
MaxBackoff: 5 * time.Minute,
|
||||
ForceQuitDelay: wtclient.DefaultForceQuitDelay,
|
||||
MaxTasksInMemQueue: maxTasksInMemQueue,
|
||||
MaxTasksInMemQueue: cfg.WtClient.MaxTasksInMemQueue,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1599,7 +1585,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
s.anchorTowerClient, err = wtclient.New(&wtclient.Config{
|
||||
FetchClosedChannel: fetchClosedChannel,
|
||||
BuildBreachRetribution: buildBreachRetribution,
|
||||
SessionCloseRange: sessionCloseRange,
|
||||
SessionCloseRange: cfg.WtClient.SessionCloseRange,
|
||||
ChainNotifier: s.cc.ChainNotifier,
|
||||
SubscribeChannelEvents: func() (subscribe.Subscription,
|
||||
error) {
|
||||
@ -1618,7 +1604,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
MinBackoff: 10 * time.Second,
|
||||
MaxBackoff: 5 * time.Minute,
|
||||
ForceQuitDelay: wtclient.DefaultForceQuitDelay,
|
||||
MaxTasksInMemQueue: maxTasksInMemQueue,
|
||||
MaxTasksInMemQueue: cfg.WtClient.MaxTasksInMemQueue,
|
||||
})
|
||||
if err != nil {
|
||||
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"`
|
||||
}
|
||||
|
||||
// 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.
|
||||
// If the corresponding values parsed by Conf are already set in the Config,
|
||||
// those fields will be not be modified.
|
||||
|
Loading…
Reference in New Issue
Block a user