Skip to content

Commit dbec9da

Browse files
ellemoutonguggero
authored andcommitted
multi: update LND and friends
This commit updates: - LND - pool - loop - taproot-assets - faraday - lighting-node-connect - aperture - lndclient - btclog We start using the new btclog v2 library and the associated breaking changes in the lnd/build package. With this commit, we deprecate the `--remote.lit-maxlogfiles` and `--remote.lit-maxlogfilesize` options and introduce new logging options under the `--remote.lit-logging` namespace. Finally, the LND update introduced a new `MaxBlocksMinedPerTest` variable in the `lntest` package that we now need to override in order for our itests to pass.
1 parent 0829b4d commit dbec9da

File tree

24 files changed

+312
-276
lines changed

24 files changed

+312
-276
lines changed

accounts/context.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/btcsuite/btclog"
8-
"github.com/lightningnetwork/lnd/build"
7+
"github.com/btcsuite/btclog/v2"
98
)
109

1110
// ContextKey is the type that we use to identify account specific values in the
@@ -95,5 +94,5 @@ func requestScopedValuesFromCtx(ctx context.Context) (btclog.Logger,
9594

9695
prefix := fmt.Sprintf("[account: %s, request: %d]", acc.ID, reqID)
9796

98-
return build.NewPrefixLog(prefix, log), acc, reqID, nil
97+
return log.WithPrefix(prefix), acc, reqID, nil
9998
}

accounts/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package accounts
22

33
import (
4-
"github.com/btcsuite/btclog"
4+
"github.com/btcsuite/btclog/v2"
55
"github.com/lightningnetwork/lnd/build"
66
)
77

autopilotserver/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package autopilotserver
22

33
import (
4-
"github.com/btcsuite/btclog"
4+
"github.com/btcsuite/btclog/v2"
55
"github.com/lightningnetwork/lnd/build"
66
)
77

autopilotserver/mock/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package mock
22

33
import (
4-
"github.com/btcsuite/btclog"
4+
"github.com/btcsuite/btclog/v2"
55
"github.com/lightningnetwork/lnd/build"
66
)
77

config.go

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ const (
5454

5555
defaultConfigFilename = "lit.conf"
5656

57-
defaultLogLevel = "info"
58-
defaultMaxLogFiles = 3
59-
defaultMaxLogFileSize = 10
57+
defaultLogLevel = "info"
6058

6159
defaultLetsEncryptSubDir = "letsencrypt"
6260
defaultLetsEncryptListen = ":80"
@@ -285,15 +283,17 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string,
285283

286284
// defaultConfig returns a configuration struct with all default values set.
287285
func defaultConfig() *Config {
286+
defaultLogCfg := build.DefaultLogConfig()
288287
return &Config{
289288
HTTPSListen: defaultHTTPSListen,
290289
TLSCertPath: DefaultTLSCertPath,
291290
TLSKeyPath: defaultTLSKeyPath,
292291
Remote: &subservers.RemoteConfig{
292+
LitLogConfig: defaultLogCfg,
293293
LitDebugLevel: defaultLogLevel,
294294
LitLogDir: defaultLogDir,
295-
LitMaxLogFiles: defaultMaxLogFiles,
296-
LitMaxLogFileSize: defaultMaxLogFileSize,
295+
LitMaxLogFiles: defaultLogCfg.File.MaxLogFiles,
296+
LitMaxLogFileSize: defaultLogCfg.File.MaxLogFileSize,
297297
Lnd: &subservers.RemoteDaemonConfig{
298298
RPCServer: defaultRemoteLndRpcServer,
299299
MacaroonPath: DefaultRemoteLndMacaroonPath,
@@ -376,11 +376,21 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
376376
os.Exit(0)
377377
}
378378

379+
// The logging config we use to initialise the sub-logger manager below
380+
// depends on whether we're running in remote mode or not.
381+
logCfg := preCfg.Lnd.LogConfig
382+
if preCfg.LndMode == ModeRemote {
383+
logCfg = preCfg.Remote.LitLogConfig
384+
}
385+
379386
// Before we validate the config, we first hook up our own loggers.
380387
// This must be done before the config is validated if LND is running
381388
// in integrated mode so that the log levels for various non-LND related
382389
// subsystems can be set via the `lnd.debuglevel` flag.
383-
SetupLoggers(preCfg.Lnd.LogWriter, interceptor)
390+
preCfg.Lnd.SubLogMgr = build.NewSubLoggerManager(
391+
build.NewDefaultLogHandlers(logCfg, preCfg.Lnd.LogRotator)...,
392+
)
393+
SetupLoggers(preCfg.Lnd.SubLogMgr, interceptor)
384394

385395
// Load the main configuration file and parse any command line options.
386396
// This function will also set up logging properly.
@@ -413,7 +423,7 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
413423
debuglevel += fmt.Sprintf(",%s=off", GrpcLogSubsystem)
414424
}
415425

416-
err = build.ParseAndSetDebugLevels(debuglevel, cfg.Lnd.LogWriter)
426+
err = build.ParseAndSetDebugLevels(debuglevel, cfg.Lnd.SubLogMgr)
417427
if err != nil {
418428
return nil, err
419429
}
@@ -753,16 +763,34 @@ func validateRemoteModeConfig(cfg *Config) error {
753763

754764
r.LitLogDir = lncfg.CleanAndExpandPath(r.LitLogDir)
755765

766+
// Initialize the log manager with the actual logging configuration. We
767+
// need to support the deprecated max log files and max log file size
768+
// options for now.
769+
if r.LitMaxLogFiles != build.DefaultMaxLogFiles {
770+
log.Warnf("Config option 'remote.lit-maxlogfiles' is " +
771+
"deprecated, please use " +
772+
"'remote.lit-logging.file.max-files' instead")
773+
774+
r.LitLogConfig.File.MaxLogFiles = r.LitMaxLogFiles
775+
}
776+
if r.LitMaxLogFileSize != build.DefaultMaxLogFileSize {
777+
log.Warnf("Config option 'remote.lit-maxlogfilesize' is " +
778+
"deprecated, please use " +
779+
"'remote.lit-logging.file.max-file-size' instead")
780+
781+
r.LitLogConfig.File.MaxLogFileSize = r.LitMaxLogFileSize
782+
}
783+
756784
// In remote mode, we don't call lnd's ValidateConfig that sets up a
757785
// logging backend for us. We need to manually create and start one. The
758786
// root logger should've already been created as part of the default
759787
// config though.
760-
if cfg.Lnd.LogWriter == nil {
761-
cfg.Lnd.LogWriter = build.NewRotatingLogWriter()
788+
if cfg.Lnd.LogRotator == nil {
789+
cfg.Lnd.LogRotator = build.NewRotatingLogWriter()
762790
}
763-
err := cfg.Lnd.LogWriter.InitLogRotator(
791+
err := cfg.Lnd.LogRotator.InitLogRotator(
792+
cfg.Remote.LitLogConfig.File,
764793
filepath.Join(r.LitLogDir, cfg.Network, defaultLogFilename),
765-
r.LitMaxLogFileSize, r.LitMaxLogFiles,
766794
)
767795
if err != nil {
768796
return fmt.Errorf("log rotation setup failed: %v", err.Error())

db/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package db
22

33
import (
4-
"github.com/btcsuite/btclog"
4+
"github.com/btcsuite/btclog/v2"
55
"github.com/lightningnetwork/lnd/build"
66
)
77

db/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"strings"
1111

12-
"github.com/btcsuite/btclog"
12+
"github.com/btcsuite/btclog/v2"
1313
"github.com/golang-migrate/migrate/v4"
1414
"github.com/golang-migrate/migrate/v4/database"
1515
"github.com/golang-migrate/migrate/v4/source/httpfs"

firewall/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package firewall
22

33
import (
4-
"github.com/btcsuite/btclog"
4+
"github.com/btcsuite/btclog/v2"
55
"github.com/lightningnetwork/lnd/build"
66
)
77

firewalldb/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package firewalldb
22

33
import (
4-
"github.com/btcsuite/btclog"
4+
"github.com/btcsuite/btclog/v2"
55
"github.com/lightningnetwork/lnd/build"
66
)
77

0 commit comments

Comments
 (0)