Skip to content
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

Add Validator component structure draft #9464

Draft
wants to merge 42 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
75f500e
lnd+lncfg: Refactor `RemoteSigner` Config
ViktorTigerstrom Dec 9, 2024
eb1e3a3
multi: correct `DefaultRemoteSignerRPCTimeout` docs
ViktorTigerstrom May 20, 2024
6ba5628
lnd: add new `remotesigner` macaroon entity
ViktorTigerstrom Aug 23, 2024
6bb48c0
walletrpc: add `SignCoordinatorStreams` RPC
ViktorTigerstrom May 14, 2024
9d2eaae
rpcwallet: add `RemoteSignerConnection` interface
ViktorTigerstrom May 14, 2024
b0fcf5e
rpcwallet: add `OutboundConnection` implementation
ViktorTigerstrom May 14, 2024
5f9ce73
rpcwallet: add `RemoteSignerConnectionBuilder`
ViktorTigerstrom May 14, 2024
178168c
rpcwallet: use `RemoteSignerConnection` in RPCKeyRing
ViktorTigerstrom May 14, 2024
eac1511
lnd: refactor `createLivenessMonitor` signature
ViktorTigerstrom Dec 17, 2024
c244bb9
multi: use `RemoteSignerConnection` for health check
ViktorTigerstrom May 14, 2024
424ebff
multi: Add `watchonlynode` Namespace to `Config`
ViktorTigerstrom Dec 6, 2024
6449c8f
fn: add CancelOrQuit helper
ViktorTigerstrom Dec 5, 2024
dedf3b5
multi: bump `fn` to `v2.0.6`
ViktorTigerstrom Dec 17, 2024
0d8c173
rpcwallet: add `RemoteSignerClient` struct
ViktorTigerstrom May 14, 2024
243d761
f - rpcwallet: use GoroutineManager in remote signer signer client
ViktorTigerstrom Oct 31, 2024
5041883
rpcwallet: Add `RemoteSignerClientBuilder`
ViktorTigerstrom Sep 1, 2024
45bdc94
lnd: add `RemoteSignerClient` instance on startup
ViktorTigerstrom May 14, 2024
2ba3937
lncfg: allow `watchonlynode.enable`
ViktorTigerstrom Dec 6, 2024
dbd3190
conf: add `remotesigner.allowinboundconnection`
ViktorTigerstrom Dec 6, 2024
2feddb0
rpcwallet: add `SignCoordinator` struct
ViktorTigerstrom May 14, 2024
6bc042c
rpcwallet: add `InboundConnection` implementation
ViktorTigerstrom Dec 6, 2024
39630d8
lnrpc: add `AllowRemoteSigner` `WalletState` proto
ViktorTigerstrom May 14, 2024
f290570
rpcperms: allow some RPCs before `rpcActive` state
ViktorTigerstrom May 14, 2024
5a63bf9
rpcperms: fix `SetServerActive` function docs typo
ViktorTigerstrom May 14, 2024
8fcbd9a
multi: enable `RpcServer` before dependencies exist
ViktorTigerstrom May 14, 2024
6c0e4b8
multi: add `RemoteSignerConnection` to walletrpc conf
ViktorTigerstrom May 14, 2024
3dcccd4
walletrpc: implement `SignCoordinatorStreams` RPC
ViktorTigerstrom May 14, 2024
e59ef6f
multi: populate `RemoteSignerConnection` ref early
ViktorTigerstrom May 28, 2024
c9616c0
f - multi: populate `RemoteSignerConnection` ref early
ViktorTigerstrom Dec 5, 2024
15f98fe
multi: add `ReadySignal` to `WalletController`
ViktorTigerstrom May 14, 2024
6e4518f
lnd: await remote signer connection on startup
ViktorTigerstrom May 28, 2024
7f89d0d
multi: allow `remotesigner.allowinboundconnection`
ViktorTigerstrom Dec 6, 2024
a0d77c7
docs: add outbound signer to remote signing docs
ViktorTigerstrom May 13, 2024
9e34789
docs: update release notes
ViktorTigerstrom Oct 31, 2024
d3113e2
lntest: separate creation/start of watch-only node
ViktorTigerstrom May 14, 2024
132afcb
itest: add outbound remote signer itest
ViktorTigerstrom May 14, 2024
96f202e
itest: add testOutboundRSMacaroonEnforcement itest
ViktorTigerstrom Aug 28, 2024
642659f
itest: wrap deriveCustomScopeAccounts at 80 chars
ViktorTigerstrom May 17, 2024
939771a
validator: introduce ValidationResult type
ViktorTigerstrom Jan 30, 2025
cee432f
validator: add validation skeleton
ViktorTigerstrom Jan 30, 2025
8a39d1c
rpcwallet: use validator in remote signer client
ViktorTigerstrom Jan 30, 2025
0ad76af
validator: add rough pseudo code for validation impl
ViktorTigerstrom Jan 30, 2025
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
22 changes: 18 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,15 @@ type Config struct {

RPCMiddleware *lncfg.RPCMiddleware `group:"rpcmiddleware" namespace:"rpcmiddleware"`

// RemoteSigner defines how to connect to a remote signer node. If this
// is enabled, the node acts as a watch-only node in a remote signer
// setup.
RemoteSigner *lncfg.RemoteSigner `group:"remotesigner" namespace:"remotesigner"`

// WatchOnlyNode defines how to connect to a watch-only node. If this is
// enabled, the node acts as a remote signer in a remote signer setup.
WatchOnlyNode *lncfg.WatchOnlyNode `group:"watchonlynode" namespace:"watchonlynode"`

Sweeper *lncfg.Sweeper `group:"sweeper" namespace:"sweeper"`

Htlcswitch *lncfg.Htlcswitch `group:"htlcswitch" namespace:"htlcswitch"`
Expand Down Expand Up @@ -720,10 +727,9 @@ func DefaultConfig() Config {
ChannelCommitBatchSize: defaultChannelCommitBatchSize,
CoinSelectionStrategy: defaultCoinSelectionStrategy,
KeepFailedPaymentAttempts: defaultKeepFailedPaymentAttempts,
RemoteSigner: &lncfg.RemoteSigner{
Timeout: lncfg.DefaultRemoteSignerRPCTimeout,
},
Sweeper: lncfg.DefaultSweeperConfig(),
RemoteSigner: lncfg.DefaultRemoteSignerCfg(),
WatchOnlyNode: lncfg.DefaultWatchOnlyNodeCfg(),
Sweeper: lncfg.DefaultSweeperConfig(),
Htlcswitch: &lncfg.Htlcswitch{
MailboxDeliveryTimeout: htlcswitch.DefaultMailboxDeliveryTimeout,
},
Expand Down Expand Up @@ -1739,6 +1745,13 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
)
}

// Validate that the node isn't configured as both a remote signer and a
// watch-only node.
if cfg.RemoteSigner.Enable && cfg.WatchOnlyNode.Enable {
return nil, fmt.Errorf("cannot enable both the remotesigner " +
"and watchonly mode simultaneously")
}

// Validate the subconfigs for workers, caches, and the tower client.
err = lncfg.Validate(
cfg.Workers,
Expand All @@ -1749,6 +1762,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
cfg.HealthChecks,
cfg.RPCMiddleware,
cfg.RemoteSigner,
cfg.WatchOnlyNode,
cfg.Sweeper,
cfg.Htlcswitch,
cfg.Invoices,
Expand Down
42 changes: 37 additions & 5 deletions config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,28 +844,57 @@ func (d *RPCSignerWalletImpl) BuildChainControl(
partialChainControl *chainreg.PartialChainControl,
walletConfig *btcwallet.Config) (*chainreg.ChainControl, func(), error) {

// Keeps track of both the remote signer and the chain control clean up
// functions.
var (
cleanUpTasks []func()
cleanUp = func() {
for _, fn := range cleanUpTasks {
fn()
}
}
)

walletController, err := btcwallet.New(
*walletConfig, partialChainControl.Cfg.BlockCache,
)
if err != nil {
err := fmt.Errorf("unable to create wallet controller: %w", err)
d.logger.Error(err)
return nil, nil, err
return nil, cleanUp, err
}

remoteSignerConnBuilder := rpcwallet.NewRemoteSignerConnectionBuilder(
d.DefaultWalletImpl.cfg.RemoteSigner,
)

// Create the remote signer connection instance.
remoteSignerConn, err := remoteSignerConnBuilder.Build(
context.Background(),
)
if err != nil {
err := fmt.Errorf("unable to set up remote signer: %w", err)
d.logger.Error(err)

return nil, cleanUp, err
}

cleanUpTasks = append(cleanUpTasks, remoteSignerConn.Stop)

baseKeyRing := keychain.NewBtcWalletKeyRing(
walletController.InternalWallet(), walletConfig.CoinType,
)

rpcKeyRing, err := rpcwallet.NewRPCKeyRing(
baseKeyRing, walletController,
d.DefaultWalletImpl.cfg.RemoteSigner, walletConfig.NetParams,
remoteSignerConn, walletConfig.NetParams,
)
if err != nil {
err := fmt.Errorf("unable to create RPC remote signing wallet "+
"%v", err)
d.logger.Error(err)
return nil, nil, err

return nil, cleanUp, err
}

// Create, and start the lnwallet, which handles the core payment
Expand All @@ -884,15 +913,18 @@ func (d *RPCSignerWalletImpl) BuildChainControl(

// We've created the wallet configuration now, so we can finish
// initializing the main chain control.
activeChainControl, cleanUp, err := chainreg.NewChainControl(
activeChainControl, ccCleanUp, err := chainreg.NewChainControl(
lnWalletConfig, rpcKeyRing, partialChainControl,
)
if err != nil {
err := fmt.Errorf("unable to create chain control: %w", err)
d.logger.Error(err)
return nil, nil, err

return nil, cleanUp, err
}

cleanUpTasks = append(cleanUpTasks, ccCleanUp)

return activeChainControl, cleanUp, nil
}

Expand Down
9 changes: 9 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
are now [sorted](https://github.com/lightningnetwork/lnd/pull/9337) based on
the `InvoiceHTLC.HtlcIndex`.

* [SignCoordinatorStreams](https://github.com/lightningnetwork/lnd/pull/8754)
allows a remote signer to connect to the lnd node, if the
`remotesigner.allowinboundconnection` cfg value has been set to `true`.

## lncli Additions

* [A pre-generated macaroon root key can now be specified in `lncli create` and
Expand All @@ -120,6 +124,11 @@

* LND updates channel.backup file at shutdown time.

* [Added](https://github.com/lightningnetwork/lnd/pull/8754) support for a new
remote signer type `outbound`, which makes an outbound connection to the
watch-only node, instead of requiring on an inbound connection from the
watch-only node.

## RPC Updates

* Some RPCs that previously just returned an empty response message now at least
Expand Down
Loading