Commit Graph
100 Commits
Author SHA1 Message Date
Elle 695bfc8414 Merge pull request #7736 from ellemouton/towerInterfaces
watchtower+refactor: CommitmentType and JusticeKit interface
2024-01-04 16:04:11 +02:00
Elle Mouton 4daa0f309c docs: add release note for 7736 2024-01-04 14:37:42 +02:00
Elle Mouton 154e9fafec watchtower: convert JusticeKit to interface
In this commit, we convert the `JusticeKit` struct to an interface.
Then, we add two implementations of that interface:
1) The `legacyJusticeKit` which implements all the methods of
   `JusticeKit`
2) The `anchorJusticKit` which wraps the `legacyJusticeKit` and just
   re-implements the `ToRemoteOutputSpendInfo` method since.
2024-01-04 14:37:42 +02:00
Elle Mouton 048dc54110 watchtower/blob: move code to justice_kit_packet.go
In preparation for the next commit which will introduce the `JusticeKit`
interface, here we just move the code related to building the actual
justice kit packet into a separate file.
2024-01-04 14:37:42 +02:00
Elle Mouton 204ca6cb0f watchtower: introduce CommitmentType
In this commit a new enum, CommitmentType, is introduced and initially
there are 3 CommitmentTypes: Legacy, LegacyTweakless and Anchor.

Then, various methods are added to `CommitmentType`. This allows us to
remove a bunch of "if-else" chains from the `wtclient` and `lookout`
code. This will also make things easier to extend when a new commitment
type (like Taproot) is added.
2024-01-04 14:37:42 +02:00
Elle Mouton 645eb44f66 docs: update release notes 2023-12-11 09:12:05 +02:00
Elle Mouton a242ad5acb channeldb+discovery: use timestamps to maybe revive zombie 2023-12-11 09:12:05 +02:00
Elle Mouton ebe0755a97 channeldb: make MarkEdgeLive logic reusable
This commit is a set-up commit. It extracts the logic from
`MarkEdgeLive` to a helper `markEdgeLive` method so that the logic can
be called from within other kvdb.Update blocks. This will be used in the
next commit.
2023-12-11 09:12:05 +02:00
Elle Mouton e12321cfd6 multi: extract and pass through IsZombieChannel method 2023-12-11 09:12:05 +02:00
Elle Mouton 67df687f08 discovery: start sending timestamps if requested 2023-12-11 09:12:05 +02:00
Elle Mouton 0ad4ef373a channeldb+discovery: fetch timestamps from DB if required 2023-12-11 09:12:05 +02:00
Elle Mouton 50e17dab59 channeldb: reformat TestFilterChannelRange 2023-12-11 09:12:04 +02:00
Elle Mouton a439cc970f multi: start asking for update timestamps in QueryChannelRange
This commit also adds a new `protocol.no-timestamp-query-option` option
to disable the new behaviour.
2023-12-11 09:12:04 +02:00
Elle Mouton 893147d83e channeldb: don't initialise edge index bkt as top level
The `edgeIndexBucket` key name is used to key a sub-bucket within the
`edgeBucket` bucket. And so the `edgeIndexBucket` is not a top level
bucket.
2023-12-11 09:12:04 +02:00
Elle Mouton 49a0370dcd lnwire: add timestamps to ReplyChannelRange msg 2023-12-11 09:12:04 +02:00
Elle Mouton 4872010779 lnwire: sort scids before encoding
This is for later when the timestamps also need to be sorted according
to the SCIDs.
2023-12-11 09:12:04 +02:00
Elle Mouton c882223ead lnwire+discovery: rename ShortChannelIDEncoding to QueryEncoding
Since the the encoding can be used for multiple different fields, we
rename it here to be more generic.
2023-12-11 09:12:04 +02:00
Elle Mouton 341bae098c lnwire: add QueryOptions to QueryChannelRange 2023-12-11 09:12:04 +02:00
Elle Mouton 8efd141347 lnwire: add QueryOptions type
This commit adds a new QueryOptions type which will later be used in the
QueryReplyRange message.
2023-12-11 09:12:03 +02:00
Elle 4fa483f1bc Merge pull request #7702 from ellemouton/towerClientMux
wtclient: Tower Client Multiplexer
2023-12-05 12:27:05 +02:00
Elle Mouton 59ebe02fa4 docs: update release notes 2023-11-28 11:01:52 +02:00
Elle Mouton e800aacff4 wtclient+server: unexport and rename TowerClient
Rename and unexport the `TowerClient` struct to `client` and rename the
`TowerClientManager` interface to `ClientManager`.
2023-11-28 11:01:51 +02:00
Elle Mouton fcfdf699e3 multi: move BackupState and RegisterChannel to Manager
This commit moves over the last two methods, `RegisterChannel` and
`BackupState` from the `Client` to the `Manager` interface. With this
change, we no longer need to pass around the individual clients around
and now only need to pass the manager around.

To do this change, all the goroutines that handle channel closes,
closable sessions needed to be moved to the Manager and so a large part
of this commit is just moving this code from the TowerClient to the
Manager.
2023-11-28 10:59:40 +02:00
Elle Mouton ab2f781b4a wtclient+lnrpc: move Policy to Manager 2023-11-28 09:54:03 +02:00
Elle Mouton 4e51bf3a3f wtclient+lnrpc: move LookupTower to Manager 2023-11-28 09:54:02 +02:00
Elle Mouton 0b3d751e33 wtclient+lnrpc: move RegisteredTowers to Manager
Move the `RegisteredTowers` method from the `Client` to the `Manager`
interface.
2023-11-28 09:54:02 +02:00
Elle Mouton 4348f2062a wtclient+lnrpc: move Stats to Manager
Move the `Stats` method from the `Client` to the `Manager` interface.
2023-11-28 09:54:02 +02:00
Elle Mouton f38b5cf258 lnrpc+wtclient: refactor ClientStats
This commit removes the mutex from ClientStats and instead puts that in
clientStats which wraps ClientStats with a mutex. This is so that the
tower client interface can return a ClientStats struct without worrying
about copying a mutex.
2023-11-28 09:54:02 +02:00
Elle Mouton a5e7d35af2 wtclient+lnrpc: move RemoveTower to Manager
Simiarly to the previous commit, this commit moves the RemoveTower
method from the Client to the TowerClientManager interface. The manager
handles any DB related handling. The manager will first attempt to
remove the tower from the in-memory state of each client and then will
attempt to remove the tower from the DB. If the removal from the DB
fails, the manager will re-add the tower to the in-memory state of each
client.
2023-11-28 09:54:02 +02:00
Elle Mouton a44bf381c4 multi: move AddTower to Tower Client Manager
In this commit we move the AddTower method from the Client interface to
the TowerClientManager interface. The wtclientrpc is updated to call the
`AddTower` method of the Manager instead of calling the `AddTower`
method of each individual client. The TowerClient now is also only
concerned with adding a new tower (or new tower address) to its
in-memory state; the tower Manager will handle adding the tower to the
DB.
2023-11-28 09:54:02 +02:00
Elle Mouton 2abc422aac watchtower+server: let manager Start & Stop the clients
In this commit, the `Stop` and `Start` methods are removed from the
`Client` interface and instead added to the new `Manager`. Callers now
only need to call the Manager to start or stop the clients instead of
needing to call stop/start on each individual client.
2023-11-28 09:54:01 +02:00
Elle Mouton ab0375e0c1 wtclient+server: introduce tower client Manager
Introduce a wtclient `Manager` which handles tower clients. It indexes
clients by the policy used. The policy field is thus removed from the
`Config` struct which configures the Manager and is instead added to a
new `towerClientCfg` which configures a specific client managed by the
manager. For now, only the `NewClient` method is added to the Manager.
It can be used to construct a new `TowerClient`. The Manager currently
does notthing with the clients added to it.
2023-11-28 09:51:15 +02:00
Elle Mouton 3642cb6d40 docs: update release notes 2023-11-27 20:01:17 +02:00
Elle Mouton 4131ced707 wtdb/migration8: migrate channel max heights 2023-11-27 20:01:17 +02:00
Elle Mouton fee94ae5af watchtower: start using the new channel max heights
This commit also adds tests for the DB changes made in the previous
commit since we can now read the new field with the FetchChanInfos
method.

The commit following this one does the backfill migration.
2023-11-27 20:01:17 +02:00
Elle Mouton 01ba2661db watchtower/wtdb: start populating channel max commitment
In this commit, a new key, cChanMaxCommitmentHeight, is added to the
channel details bucket. This key will hold the highest commitment number
that the tower has been handed for this channel. In this commit, we
start writing to it in the two places where a backup is first persisted
in the tower client db: 1) CommitUpdate and 2) in the Queue's `addItem`
method. The logic for both 1 & 2 is tested in the next commit which adds
a DB helper that allows us to read the new field.

A follow up commit will do a migration to back-fill the new field.
2023-11-27 20:01:17 +02:00
Elle ed179e3e7d Merge pull request #8180 from carlaKC/8128-brontideflake
peer/test: fix race in TestHandleNewPendingChannel
2023-11-16 10:10:24 +02:00
Elle 5e369a02bb Merge pull request #8171 from ellemouton/zombieChansUseCorrectChanID
channeldb+discovery: pass correct SCID to `MarkEdgeLive`
2023-11-14 11:05:57 +02:00
Elle Mouton ac58100558 docs: update release notes 2023-11-13 20:58:27 +02:00
Elle Mouton 7ff4a8b157 discovery: use correct channel ID for MarkEdgeLive
In processZombieUpdate, the SCID passed to MarkEdgeLive should _not_ be
derived from the ChannelEdgeInfo ChannelID field since this field will
not be populated when GetChannelByID returns a ChannelEdgeInfo along
with an ErrZombieEdge error. So this commit ensures that a usable
SCID is provided to processZombieUpdate.
2023-11-13 20:58:06 +02:00
Elle Mouton 0193274c10 multi: return error from MarkEdgeLive if not found
Let MarkEdgLive return a new ErrNotZombieEdge error if an entry with the
given channel ID cannot be found. In processZombieUpdate, we then
check for this error and log accordingly.
2023-11-13 20:58:06 +02:00
Elle Mouton 034283db10 channeldb: update TestGraphZombieIndex to use require 2023-11-13 20:58:05 +02:00
Elle a3f8011ed6 Merge pull request #8156 from hieblmi/improve-fc-logging
contractcourt: log amount if incoming htlc times out
2023-11-09 17:32:18 +02:00
Elle 6122452509 Merge pull request #8117 from ellemouton/removeDBFromChannelDBSchemas
channeldb+refactor: remove `kvdb.Backend` from channel DB schemas
2023-11-09 07:47:11 +02:00
Elle Mouton 0e82293e45 multi: address linter issues 2023-11-08 14:50:35 +02:00
Elle Mouton 84cdcd6847 multi: move DB schemas to channeldb/models
This commit moves the ChannelEdgePolicy, ChannelEdgeInfo,
ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models`
package.
2023-11-08 14:50:35 +02:00
Elle Mouton be23986eda docs: update release notes 2023-11-08 14:50:35 +02:00
Elle Mouton 78ff28fea1 channeldb: remove unused func arguments 2023-11-08 14:50:35 +02:00
Elle Mouton 3a17479ff4 multi: remove LightningNode from ChannelEdgePolicy
Finally, The LightningNode object is removed from ChannelEdgePolicy.
This is a step towards letting ChannelEdgePolicy reflect exactly the
schema that is on disk.

This is also nice because the `Node` object is not necessarily always
required when the ChannelEdgePolicy is loaded from the DB, so now it
only get's loaded when needed.
2023-11-08 14:50:34 +02:00
Elle Mouton 6c76d31e89 multi: let FetchLightningNode take an optional tx
In preparation for the next commit which will remove the
`*LightningNode` from the `ChannelEdgePolicy` struct,
`FetchLightningNode` is modified to take in an optional transaction so
that it can be utilised in places where a transaction exists.
2023-11-08 14:50:34 +02:00
Elle Mouton 9a62a46aa3 channeldb: remove kvdb.Backend from ChannelEdgePolicy 2023-11-08 14:50:34 +02:00
Elle Mouton f06f08f596 channeldb: remove kvdb.Backend from ChannelEdgeInfo 2023-11-08 14:50:34 +02:00
Elle Mouton 9dc1a1dfec channeldb: convert FetchOtherNode to ChannelGraph method
To prepare for the `kvdb.Backend` member of `ChannelEdgeInfo` being
removed, the `FetchOtherNode` method is moved from the `ChannelEdgeInfo`
to the `ChannelGraph` struct.
2023-11-08 14:50:34 +02:00
Elle Mouton 6d878c65fc channeldb: remove kvdb.Backend from LightningNode
Now that the kvdb.Backend is no longer required, it is removed from the
LightningNode struct.
2023-11-08 14:50:34 +02:00
Elle Mouton d37f5d7e1a autopilot: use pointer receivers for dbNode methods 2023-11-08 14:50:21 +02:00
Elle Mouton fa7c1e250b multi: let ForEachChannel be a method on ChannelGraph
Having a `ForEachChannel` method on the `LightningNode` struct itself
results in a `kvdb.Backend` object needing to be stored within the
LightningNode struct. In this commit, this method is replaced with a
`ForEachNodeChannel` method on the `ChannelGraph` struct will perform
the same function without needing the db pointer to be stored within the
LightningNode. This change, the LightningNode struct more closely
represents the schema on disk.

The existing `ForEachNodeChannel` method on `ChannelGraph` is renamed to
`ForEachNodeDirectedChannel`. It performs a slightly different function
since it's call-back operates on Cached policies.
2023-11-08 10:51:50 +02:00
Elle Mouton 53b33c75c4 config: edit error strings to account for signet option 2023-10-06 16:34:47 -07:00
Elle Mouton 1211e7eb7b multi: use "bitcoin" chain name constant
Make use of the `bitcoinChainName` constant instead of re-writing the
"bitcoin" string.
2023-10-06 16:34:47 -07:00
Elle Mouton 8a195ed761 sample-lnd.conf: replace ${chain} with "bitcoin" 2023-10-06 16:34:47 -07:00
Elle Mouton 275201de5b scripts: remove litecoin strings from script 2023-10-06 16:34:47 -07:00
Elle Mouton a454a8ab44 docs: add release note for 7867 2023-10-06 16:34:47 -07:00
Elle Mouton 23a63ef328 config: update to satisfy linter 2023-10-06 16:34:47 -07:00
Elle Mouton a7e723e570 lncli: remove chain option from profile 2023-10-06 16:34:47 -07:00
Elle Mouton 7fa05f92f5 htlcswitch: remove Network type 2023-10-06 16:34:47 -07:00
Elle Mouton 77908d6c92 lnrpc: deprecate chains field in GetInfoResponse 2023-10-06 16:34:47 -07:00
Elle Mouton 031dbd7760 multi: remove ChainRegistry 2023-10-06 16:34:47 -07:00
Elle Mouton 2a7fffe441 lnrpc: remove litecoin from lightning.proto 2023-10-06 16:34:47 -07:00
Elle Mouton 215e0f26fe docker: remove litcoin docker scripts 2023-10-06 16:34:47 -07:00
Elle Mouton 0d89a45abe docs: remove Litecoin references from INSTALL.md file 2023-10-06 16:34:47 -07:00
Elle Mouton be90bcbe46 multi: remove litecoin references and comments 2023-10-06 16:34:47 -07:00
Elle Mouton a24a4c2996 zpay32: remove litecoin tests 2023-10-06 16:34:47 -07:00
Elle Mouton 94c4642db6 lncfg+config: only allow btcd or bitcoind backends 2023-10-06 16:34:47 -07:00
Elle Mouton 913aa36fe9 chainreg: remove Litecoin support
This commit removes the Litecoin, LtcMode and LitcoinMode members from
the chainreg `Config` struct.
2023-10-06 16:34:47 -07:00
Elle Mouton a76bdf606b chainreg: let IsTestnet consider bitcoin only 2023-10-06 16:34:47 -07:00
Elle Mouton d128c18cc5 keychain+chainreg: remove Litecoin CoinType 2023-10-06 16:34:47 -07:00
Elle Mouton 3912d5a0c6 multi: remove Litecoin config options
This commit removes the `Litecoin`, `LtcMode` and `LitecoindMode`
members from the main LND `Config` struct. Since only the bitcoin
blockchain is now supported, this commit also deprecates the
`cfg.Bitcoin.Active` config option.
2023-10-06 16:34:47 -07:00
Elle Mouton ba93cde07a sample-lnd.conf: remove litecoin conf options 2023-10-06 16:34:47 -07:00
Elle Mouton 95c2bfe181 docs: add entry for 7981 2023-09-14 10:33:07 +02:00
Elle Mouton 273b934f62 wtdb+lnrpc: return correct NumAckedUpdates from wtclientrpc 2023-09-14 10:33:04 +02:00
Elle Mouton 2a9339805e watchtower: account for rogue updates
In this commit, we introduce the concept of a rogue update. An update is
rogue if we need to ACK it but we have already deleted all the data for
the associated channel due to the channel being closed. In this case, we
now no longer error out and instead keep count of how many rogue updates
a session has backed-up.
2023-09-14 10:33:02 +02:00
Elle Mouton c33cd0ea38 wtdb: refactor getRangesWriteBucket
A pure refactor commit that passes the required buckets to the
`getRangesWriteBucket` instead of re-fetching them.
2023-09-14 10:30:00 +02:00
Elle Mouton adb87dcfb8 wtclient: demo un-acked update of closed channel bug
This commit adds a new test to the tower client to demonstrate a bug
that can happen if a channel is closed while an update for it has yet to
be acked by the tower server. This will be fixed in an upcomming commit.
2023-09-14 10:28:56 +02:00
Elle Mouton ff0d8fc619 watchtower: completely remove the mock tower client DB
Remove the use of the mock tower client DB and use the actual bbolt DB
everywhere instead.
2023-09-13 12:21:04 +02:00
Elle Mouton f889c9b1cc watchtower: use bbolt db instead of mock DB for client tests
The watchtower client test framework currently uses a mock version of
the tower client DB. This can lead to bugs if the mock DB works slightly
differently to the actual bbolt DB. So this commit ensures that we only
use the bbolt db for the tower client tests. We also increment the
`waitTime` used in the tests a bit to account for the slightly longer DB
read and write times. Doing this switch resulted in one bug being
caught: we were not removing sessions from the in-memory set on deletion
of the session and so that is fixed here too.
2023-09-13 12:13:22 +02:00
Elle 15d2ff0c4d netann+docs: remove nil value from variadic list (#7922)
The nil value in the variadic list causes a panic when the variadic
parameters are iterated over.
2023-08-24 11:47:42 -07:00
Elle Mouton dfec4a65cb multi: update lightning-onion version
Update the lighting-onion dependency to include the lates changes which
support route blinding.
2023-08-23 12:09:53 +02:00
Elle Mouton b9560b067a refactor: move State server REST registration
This commit moves the registration of the State server with a REST proxy
into the `RegisterWithRestProxy` method in order to keep all the REST
registrations in one place.
2023-08-08 11:43:25 +02:00
Elle Mouton 5203b35316 go.mod: bump neutrino and btcwallet versions 2023-08-05 08:53:39 +02:00
Elle Mouton 7bf07d8875 docs: add release note for 6895 2023-07-19 10:10:15 +02:00
Elle Mouton 3ea67983b5 wtclient: replay un-acked updates onto pipeline
In this commit, the bugs demonstrated in prior commits are fixed. In the
case where an session has persisted a CommittedUpdate and the tower is
being removed, the session will now replay that update on to the main
task pipeline so that it can be backed up using a different session.
2023-07-18 16:28:27 +02:00
Elle Mouton c432899bf9 watchtower: add DeleteCommittedUpdate DB method
Add a new DeleteCommittedUpdate method to the wtdb In preparation for an
upcoming commit that will replay committed updates from one session to
another.
2023-07-18 16:28:27 +02:00
Elle Mouton cfb81c00a6 wtclient: tower with unacked updates cant be removed after restart
This commit demonstrates that if a session has persisted committed
updates and the client is restarted _after_ these committed updates have
been persisted, then removing the tower will fail.
2023-07-18 16:28:27 +02:00
Elle Mouton af1506bff1 wtclient: demo "tower has unacked updates" bug
In this commit, we demonstrate the situation where a client has
persisted CommittedUpdates but has not yet recieved Acks for them from
the tower. If this happens and the client attempts to remove the tower,
it will with the "tower has unacked updates" error.
2023-07-18 16:28:26 +02:00
Elle Mouton 552ef4bf81 wtclient: replay pending tasks on sessionQueue stop
This commit does a few things:
- First, it gives the sessionQueue access to the TowerClient task
  pipeline so that it can replay backup tasks onto the pipeline on Stop.
- Given that the above is done, the ForceQuit functionality of the
  sessionQueue and TowerClient can be removed.
- The bug demonstrated in a prior commit is now fixed due to the above
  changes.
2023-07-18 16:28:26 +02:00
Elle Mouton 449d6b5500 wtclient: fix handleStaleTower comment 2023-07-18 14:27:14 +02:00
Elle Mouton 25c4d3f1f7 wtclient: make sessionQueueSet thread safe
In preparation for an upcoming commit where multiple threads will have
access to the TowerClient sessionQueueSet, we turn it into a thread safe
struct.
2023-07-18 14:27:04 +02:00
Elle Mouton c4fec3ebc9 wtclient: show that bound tasks are not replayed
This commit demonstrates a bug. It shows that if backup tasks have been
bound to a session with a tower (ie, the tasks are in the session's
pendingQueue) and then the tower is removed and a new one is added, then
the tasks from the pendingQueue are _not_ replayed to the session with
the new tower. Instead, they are silently lost. This will be fixed in an
upcoming commit.
2023-07-18 14:26:51 +02:00
Elle Mouton feb35e65d8 wtclient: show that a client can switch towers
This commit adds a new watchtower client test to demonstrate that a
client is able to successfully switch to a new tower and continue
backing up updates to that new tower.
2023-07-18 14:26:35 +02:00
Elle Mouton d8af5fcc92 wtclient: ensure that waitForUpdates has no race condition on timeout
Enforce that the fail timeout in `waitForUpdates` is greater than the
ping timeout.
2023-07-18 14:25:58 +02:00
Elle Mouton d979f59331 wtclient: move server specific methods to serverHarness 2023-07-18 14:15:46 +02:00