Skip to content

multi: allow disabling of sub-servers #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ type Config struct {
LndMode string `long:"lnd-mode" description:"The mode to run lnd in, either 'remote' (default) or 'integrated'. 'integrated' means lnd is started alongside the UI and everything is stored in lnd's main data directory, configure everything by using the --lnd.* flags. 'remote' means the UI connects to an existing lnd node and acts as a proxy for gRPC calls to it. In the remote node LiT creates its own directory for log and configuration files, configure everything using the --remote.* flags." choice:"integrated" choice:"remote"`
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`

FaradayMode string `long:"faraday-mode" description:"The mode to run faraday in, either 'integrated' (default) or 'remote'. 'integrated' means faraday is started alongside the UI and everything is stored in faraday's main data directory, configure everything by using the --faraday.* flags. 'remote' means the UI connects to an existing faraday node and acts as a proxy for gRPC calls to it." choice:"integrated" choice:"remote"`
FaradayMode string `long:"faraday-mode" description:"The mode to run faraday in, either 'integrated' (default), 'remote' or 'disable'. 'integrated' means faraday is started alongside the UI and everything is stored in faraday's main data directory, configure everything by using the --faraday.* flags. 'remote' means the UI connects to an existing faraday node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without a connection to faraday." choice:"integrated" choice:"remote" choice:"disable"`
Faraday *faraday.Config `group:"Integrated faraday options (use when faraday-mode=integrated)" namespace:"faraday"`

LoopMode string `long:"loop-mode" description:"The mode to run loop in, either 'integrated' (default) or 'remote'. 'integrated' means loopd is started alongside the UI and everything is stored in loop's main data directory, configure everything by using the --loop.* flags. 'remote' means the UI connects to an existing loopd node and acts as a proxy for gRPC calls to it." choice:"integrated" choice:"remote"`
LoopMode string `long:"loop-mode" description:"The mode to run loop in, either 'integrated' (default), 'remote' or 'disable'. 'integrated' means loopd is started alongside the UI and everything is stored in loop's main data directory, configure everything by using the --loop.* flags. 'remote' means the UI connects to an existing loopd node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without a connection to loop." choice:"integrated" choice:"remote" choice:"disable"`
Loop *loopd.Config `group:"Integrated loop options (use when loop-mode=integrated)" namespace:"loop"`

PoolMode string `long:"pool-mode" description:"The mode to run pool in, either 'integrated' (default) or 'remote'. 'integrated' means poold is started alongside the UI and everything is stored in pool's main data directory, configure everything by using the --pool.* flags. 'remote' means the UI connects to an existing poold node and acts as a proxy for gRPC calls to it." choice:"integrated" choice:"remote"`
PoolMode string `long:"pool-mode" description:"The mode to run pool in, either 'integrated' (default) or 'remote'. 'integrated' means poold is started alongside the UI and everything is stored in pool's main data directory, configure everything by using the --pool.* flags. 'remote' means the UI connects to an existing poold node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without a connection to pool." choice:"integrated" choice:"remote" choice:"disable"`
Pool *pool.Config `group:"Integrated pool options (use when pool-mode=integrated)" namespace:"pool"`

TaprootAssetsMode string `long:"taproot-assets-mode" description:"The mode to run taproot assets in, either 'integrated' (default), 'remote' or 'disable'. 'integrated' means tapd is started alongside the UI and everything is stored in tap's main data directory, configure everything by using the --taproot-assets.* flags. 'remote' means the UI connects to an existing tapd node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without a connection to tapd" choice:"integrated" choice:"disable"`
Expand Down Expand Up @@ -460,20 +460,26 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
// (like the log or lnd options) as they will be taken from lnd's config
// struct. Others we want to force to be the same as lnd so the user
// doesn't have to set them manually, like the network for example.
cfg.Faraday.Lnd.MacaroonPath = faraday.DefaultLndMacaroonPath
if err := faraday.ValidateConfig(cfg.Faraday); err != nil {
return nil, err
if cfg.FaradayMode != ModeDisable {
cfg.Faraday.Lnd.MacaroonPath = faraday.DefaultLndMacaroonPath
if err := faraday.ValidateConfig(cfg.Faraday); err != nil {
return nil, err
}
}

defaultLoopCfg := loopd.DefaultConfig()
cfg.Loop.Lnd.MacaroonPath = defaultLoopCfg.Lnd.MacaroonPath
if err := loopd.Validate(cfg.Loop); err != nil {
return nil, err
if cfg.LoopMode != ModeDisable {
cfg.Loop.Lnd.MacaroonPath = defaultLoopCfg.Lnd.MacaroonPath
if err := loopd.Validate(cfg.Loop); err != nil {
return nil, err
}
}

cfg.Pool.Lnd.MacaroonPath = pool.DefaultLndMacaroonPath
if err := pool.Validate(cfg.Pool); err != nil {
return nil, err
if cfg.PoolMode != ModeDisable {
cfg.Pool.Lnd.MacaroonPath = pool.DefaultLndMacaroonPath
if err := pool.Validate(cfg.Pool); err != nil {
return nil, err
}
}

if cfg.TaprootAssetsMode != ModeDisable {
Expand Down
6 changes: 6 additions & 0 deletions itest/litd_mode_integrated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ var (
allowedThroughLNC: true,
grpcWebURI: "/frdrpc.FaradayServer/RevenueReport",
restWebURI: "/v1/faraday/revenue",
canDisable: true,
}, {
name: "looprpc",
macaroonFn: loopMacaroonFn,
Expand All @@ -237,6 +238,7 @@ var (
allowedThroughLNC: true,
grpcWebURI: "/looprpc.SwapClient/ListSwaps",
restWebURI: "/v1/loop/swaps",
canDisable: true,
}, {
name: "poolrpc",
macaroonFn: poolMacaroonFn,
Expand All @@ -245,6 +247,7 @@ var (
allowedThroughLNC: true,
grpcWebURI: "/poolrpc.Trader/GetInfo",
restWebURI: "/v1/pool/info",
canDisable: true,
}, {
name: "taprpc",
macaroonFn: tapMacaroonFn,
Expand Down Expand Up @@ -314,6 +317,9 @@ func testDisablingSubServers(ctx context.Context, net *NetworkHarness,
err := net.RestartNode(
node, nil, []LitArgOption{
WithLitArg("taproot-assets-mode", "disable"),
WithLitArg("loop-mode", "disable"),
WithLitArg("pool-mode", "disable"),
WithLitArg("faraday-mode", "disable"),
},
)
require.NoError(t, err)
Expand Down
62 changes: 38 additions & 24 deletions itest/litd_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,42 +730,56 @@ func (hn *HarnessNode) WaitUntilStarted(conn grpc.ClientConnInterface,
return err
}

faradayMode, _ := hn.Cfg.ActiveArgs.getArg("faraday-mode")
loopMode, _ := hn.Cfg.ActiveArgs.getArg("loop-mode")
poolMode, _ := hn.Cfg.ActiveArgs.getArg("pool-mode")
tapMode, _ := hn.Cfg.ActiveArgs.getArg("taproot-assets-mode")

ctxt, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
return wait.NoError(func() error {
faradayClient, err := hn.faradayClient()
if err != nil {
return err
}
if faradayMode != terminal.ModeDisable {
faradayClient, err := hn.faradayClient()
if err != nil {
return err
}

_, err = faradayClient.RevenueReport(
ctxt, &frdrpc.RevenueReportRequest{},
)
if err != nil {
return err
_, err = faradayClient.RevenueReport(
ctxt, &frdrpc.RevenueReportRequest{},
)
if err != nil {
return err
}
}

loopClient, err := hn.loopClient()
if err != nil {
return err
}
if loopMode != terminal.ModeDisable {
loopClient, err := hn.loopClient()
if err != nil {
return err
}

_, err = loopClient.ListSwaps(ctxt, &looprpc.ListSwapsRequest{})
if err != nil {
return err
_, err = loopClient.ListSwaps(
ctxt, &looprpc.ListSwapsRequest{},
)
if err != nil {
return err
}
}

poolClient, err := hn.poolClient()
if err != nil {
return err
}
if poolMode != terminal.ModeDisable {
poolClient, err := hn.poolClient()
if err != nil {
return err
}

_, err = poolClient.GetInfo(ctxt, &poolrpc.GetInfoRequest{})
if err != nil {
return err
_, err = poolClient.GetInfo(
ctxt, &poolrpc.GetInfoRequest{},
)
if err != nil {
return err
}
}

tapMode, _ := hn.Cfg.ActiveArgs.getArg("taproot-assets-mode")
if tapMode != terminal.ModeDisable {
tapClient, err := hn.tapClient()
if err != nil {
Expand Down
26 changes: 16 additions & 10 deletions terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1409,18 +1409,24 @@ func (g *LightningTerminal) validateSuperMacaroon(ctx context.Context,
// initSubServers registers the faraday and loop sub-servers with the
// subServerMgr.
func (g *LightningTerminal) initSubServers() {
g.subServerMgr.AddServer(subservers.NewFaradaySubServer(
g.cfg.Faraday, g.cfg.faradayRpcConfig, g.cfg.Remote.Faraday,
g.cfg.faradayRemote,
))
if g.cfg.FaradayMode != ModeDisable {
g.subServerMgr.AddServer(subservers.NewFaradaySubServer(
g.cfg.Faraday, g.cfg.faradayRpcConfig,
g.cfg.Remote.Faraday, g.cfg.faradayRemote,
))
}

g.subServerMgr.AddServer(subservers.NewLoopSubServer(
g.cfg.Loop, g.cfg.Remote.Loop, g.cfg.loopRemote,
))
if g.cfg.LoopMode != ModeDisable {
g.subServerMgr.AddServer(subservers.NewLoopSubServer(
g.cfg.Loop, g.cfg.Remote.Loop, g.cfg.loopRemote,
))
}

g.subServerMgr.AddServer(subservers.NewPoolSubServer(
g.cfg.Pool, g.cfg.Remote.Pool, g.cfg.poolRemote,
))
if g.cfg.PoolMode != ModeDisable {
g.subServerMgr.AddServer(subservers.NewPoolSubServer(
g.cfg.Pool, g.cfg.Remote.Pool, g.cfg.poolRemote,
))
}

if g.cfg.TaprootAssetsMode != ModeDisable {
g.subServerMgr.AddServer(subservers.NewTaprootAssetsSubServer(
Expand Down