Commit Graph

456 Commits

Author SHA1 Message Date
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
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
Michael Rooke
78d9996620
trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
Olaoluwa Osuntokun
12be6a37a7
Merge branch 'master' into handleRogueUpdates 2023-09-18 13:55:41 -07:00
Olaoluwa Osuntokun
ce93b236aa
input+lnwallet: modify musig2 interfaces use explicit optional local nonces
In this commit, we modify the musig2 interfaces to instead use an
explicit value for the local nonces. Before this commit, we used the
functional option, but we want to also support specifying this value
over RPC for the remote signer. The functional option pattern is opaque,
so we can't get the nonce value we need. To get around this, we'll just
make this an explicit pointer, then map this to the functional option at
the very last moment.
2023-09-18 11:42:13 -07: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
Olaoluwa Osuntokun
9a65806c09
input+wallet: extract musig2 session management into new module
In this commit, we extract the musig2 session management into a new
module. This allows us to re-use the session logic elsewhere in unit
tests so we don't need to instantiate the entire wallet.
2023-08-22 16:30:39 -07:00
Olaoluwa Osuntokun
b368e476c5
lnwire: update Sig to support both ECDSA and schnorr sigs
In this commit, we update the Sig type to support ECDSA and schnorr
signatures. We need to do this as the HTLC signatures will become
schnorr sigs for taproot channels. The current spec draft opts to
overload this field since both the sigs are actually 64 bytes in length.
The only consideration with this move is that callers need to "coerce" a
sig to the proper type if they need schnorr signatures.
2023-08-22 16:29:19 -07: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
Elle Mouton
2ed5788de3
wtclient: separate server from testHarness
In this commit, a serverHarness is added to the test framework. This
will allow us to create more mock servers appart from the main server.
2023-07-18 14:15:26 +02:00
Elle Mouton
f3525e8b7c
multi: add default watchtower config to main LND config
In this commit, a `DefaultWatchtowerCfg` function is added which is used
to construct a default `lncfg.Watchtower` struct. This is then used to
populate the default watchtower config in the main LND config struct.
2023-06-15 11:36:44 +02:00
Oliver Gugger
56dba2df03
multi: update linter, fix new issues 2023-06-13 11:58:33 +02:00
Matt Morehouse
f53c8d6e91
wtclient: AddressIterator fuzz test
Test AddressIterator for the absence of panics, nil addresses, and empty
lists.

This fuzz test finds https://github.com/lightningnetwork/lnd/issues/7552
in seconds. No other panics found after 300+ CPU-hours of fuzzing.
2023-06-01 08:46:45 -05:00
Matt Morehouse
4c2e712581
wtwire: use require package for fuzz tests
Simplify code by using the require package instead of t.Fatal().
2023-05-23 08:37:22 -05:00
Elle Mouton
8abe2f89e1
watchtower: use a stable blob identifier
In this commit, we add an Identifier method to the blob.Type struct
which returns a unique identifier for a given blob type. This identifier
is then used for initialising the disk overflow queue of the given
client.
2023-05-18 15:17:22 +02:00
Elle Mouton
db145bfd8e
wtclient: check un-checked errors
Some errors are not checked during startup and shutdown of the tower
client. These are checked now.
2023-05-18 15:13:24 +02:00
Elle Mouton
56cd825695
watchtower: replace taskpipeline with disk overflow queue 2023-05-16 10:57:50 +02:00
Elle Mouton
e91fe50878
watchtower/wtclient: generic disk overflow queue
In this commit, a new generic DiskOverflowQueue implementation is added.
This allows a user to specify a maximum number of items that the queue
can hold in-memory. Any new items will then overflow to disk. The
producer and consumer of the queue items will interact with the queue
just like a normal in-memory queue.
2023-05-16 10:57:50 +02:00
Elle Mouton
66f6bf3955
watchtower/wtmock: add in-memory impl of Queue
This commit adds an in-memory implementation of the Queue interface.
This can be used for tests.
2023-05-16 10:57:49 +02:00
Elle Mouton
5cc7438d33
watchtower/wtdb: add bolt db impl of Queue
This commit adds a new generic DiskQueueDB type which is an
bbolt implementation of the Queue interface.
2023-05-16 10:57:49 +02:00
Elle Mouton
a946715b7e
watchtower/wtdb: add a generic Queue interface 2023-05-16 10:57:49 +02:00
Elle Mouton
01e2f10797
wtclient: demo that in-mem updates are lost
This commit adds a test to the wtclient. The test demonstrates that if a
client tries to back up states while it has no active sessions with a
server then those updates are accumlated in memory and lost on restart.
This will be fixed in upcoming commits.
2023-05-16 10:57:49 +02:00
Elle Mouton
08cde98869
wtclient: add mutex locking in perUpdate
Lock the `backupMu` when accessing `c.chanCommitHeights` in the `New`
function. It is not strictly necessary right now but good to add it so
that there is no accidental oversight if the `perUpdate` method is ever
extracted and reused in future.
2023-04-24 13:15:40 +02:00
Elle Mouton
65dc20f2cc
wtclient: let task pipeline only carry wtdb.BackupID
Since the retrubution info of a backup task is now only constructed at
the time that the task is being bound to a session, the in-memory queue
only needs to carry the BackupID of the task.
2023-04-24 13:15:40 +02:00
Elle Mouton
2371bbf09a
wtclient: only fetch retribution info when needed.
Only construct the retribution info at the time that the backup task is
being bound to a session.
2023-04-24 13:15:40 +02:00
Elle Mouton
458ac32146
multi: build retribution info in TowerClient
Since the TowerClient now has a callback that it can use to retrieve the
retribution for a certain channel and commit height, let it use this
call back instead of requiring the info to be passed to it through
BackupState.
2023-04-24 13:15:40 +02:00
Elle Mouton
530a8cae5d
wtclient: lint the package
This commit fixes some lints in the wtclient package. This is done so
that upcoming logic changes are easier to parse.
2023-04-24 13:15:40 +02:00
Elle Mouton
85ec38f447
multi: pass BuildBreachRetribution callback to tower client
In this commit, a new BuildBreachRetribution callback is added to the
tower client's Config struct. The main LND server provides the client
with an implementation of the callback.
2023-04-24 13:15:40 +02:00
Elle Mouton
cab0560d5e
wtclient: cleanup the test file
This commit just does some linting of the client_test.go file so that
future commits are easier to parse.
2023-04-24 13:10:12 +02:00
Elle Mouton
ba33f6a697
wtclient: spin session key indices if required
If the tower returns CreateSessionCodeAlreadyExists in response to the
CreateSession message from the client, then skip forward a few key
indices until we find one that the server does not return the error
for. This will allow a client to recover after a data loss incident.
2023-03-31 12:05:58 +02:00
Elle Mouton
24016c35c7
watchtower: add forceNext to NextSessionKeyIndex
This commit adds a forceNext boolean parameter to NextSessionKeyIndex.
Setting this param to true will force the index to cycle over 1000 key
indices before returning the new key.
2023-03-31 12:04:57 +02:00
Elle Mouton
204585c620
watchtower: demo StateUpdateCodeClientBehind error
In this commit, a test is added to demonstrate how clients can end up
getting the StateUpdateCodeClientBehind error from a tower server. This
can happen if a client ever deletes their db. If they do this then the
sessions they create with the tower will have the same IDs as the
sessions created in the now deleted db. This is because the session keys
(and thus session IDs) are calculated deterministically from a counter
(which is reset if the db is deleted). The tower server then throws this
error because the client would say that the sequence ID is 1 for the
next update.
2023-03-31 12:04:57 +02:00
Elle Mouton
4f7e871b42
wtclient: add clarifying comments to the AddressIterator 2023-03-30 14:46:56 +02:00
Elle Mouton
9e4c8dd509
wtclient: make addr iterator panic safe
Ensure that calling Next twice in a row without first calling Reset is
safe when the iterator is at the end of its list. Also alter the
towerListIterator to call Reset after hitting an error on Next.
2023-03-30 12:29:41 +02:00
Elle Mouton
1047514515
wtclient: demo addr iterator panic
This commit adds a test that shows that it is possible to cause the
AddressIterator to panic if the `Next` method is ever called twice when
the iterator is at the end of its list without Reset first being called.
2023-03-30 12:29:24 +02:00
Elle Mouton
de80fffa6c
wtclient: divide addr_iter tests into subtests
Split out the existing tests into logical subtests.
2023-03-30 12:29:06 +02:00
Elle Mouton
1af31bfea7
wtclient: fix info log line format 2023-03-20 20:14:01 +02:00
Elle Mouton
8623e6107d
wtclient: don't unnecessarily load exhausted sessions
In this commit, a new `ExhaustedSessionFilter` function is added and
used as a PostEvalFilterFn used when loading sessions from the DB. It
allows us to not unnecessarily load exhausted sessions into memory for
areas of the code where they will not be needed.
2023-03-20 20:14:01 +02:00
Elle Mouton
49cd23725a
watchtower: add PostEvaluateFilterFn call-back option
This commit adds a new PostEvaluateFilterFn call-back option to
`wtdb.ClientSessionListCfg`. This call-back is run _after_ all the other
evaluation call-backs in `wtdb.ClientSessionListCfg` and is only used to
determine if the session should be included in the returned list or not.
2023-03-20 20:14:01 +02:00
Elle Mouton
7bc86ca42e
watchtower: add PreEvaluateFilterFn callback
In this commit, a PreEvaluateFilterFn option is added to the
wtdb.ClientSessionListCfg and it is used instead of a separate
ClientSessionFilterFn parameter. This neatens quiet a few function
signatures.
2023-03-20 20:14:01 +02:00
Elle Mouton
d840761cc4
watchtower: dont load closed channel details
In this commit, the FetchChanSummaries method is adapted to skip loading
any channel summaries if the channel has been marked as closed.
2023-03-20 16:51:51 +02:00
Elle Mouton
26e628c0fe
watchtowers: handle closable sessions
Add a routine to the tower client that informs towers of sessions they
can delete and also deletes any info about the session from the client
DB.
2023-03-20 16:51:51 +02:00
Elle Mouton
8478b56ce6
watchtower: method to dial tower and send DeleteSession
This commit adds a deleteSessionFromTower method which can be used to
dial the tower that we created a given session with and then sends that
tower the DeleteSession method.
2023-03-20 16:51:33 +02:00
Elle Mouton
0209e6feb8
watchtower/wtclient: add Copy method to AddressIterator 2023-03-20 16:51:32 +02:00
Elle Mouton
2b08d3443f
watchtowers: add thread safe min-heap
In this commit, a thread-safe min-heap is implemented. It will carry
sessionCloseItems which carry a sessionID and a block height at which
the session should be closed.
2023-03-20 16:51:32 +02:00
Elle Mouton
16008c0032
watchtower: handle channel closures
Add a channel-close handler that waits for channel close events and
marks channels as closed in the tower client DB.
2023-03-20 16:51:25 +02:00
Elle Mouton
41e36c7ec7
watchtower: add wtclient.ClientSession constructor 2023-03-20 10:46:53 +02:00
Elle Mouton
0ed5c750c8
watchtower: add GetTower to tower iterator
Add a GetTower method to the tower iterator.
2023-03-20 10:46:53 +02:00
Elle Mouton
e432261dab
watchtower: add DeleteSession method
Add a DeleteSession method to the tower client DB. This can be used to
delete a closable session along with any references to the session.
2023-03-20 10:46:52 +02:00
Elle Mouton
3577c829d3
watchtower: add ListClosableSessions method
This commit adds a new ListClosableSessions method to the tower client
DB. This method will return a map of sessionIDs to block heights. The
IDs belong to sessions that are considered closable and the block
heights are the block height at which the last associated channel for
the session was closed in.
2023-03-20 10:46:52 +02:00
Elle Mouton
571966440c
watchtower: add MarkChannelClosed db method
This commit adds a `MarkChannelClosed` method to the tower client DB.
This function can be called when a channel is closed and it will
check the channel's associated sessions to see if any of them are
"closable". Any closable sessions are added to a new
`cClosableSessionsBkt` bucket so that they can be evaluated in future.
Note that only the logic for this function is added in this commit and
it is not yet called.
2023-03-20 10:46:52 +02:00
Elle Mouton
a3050ed213
watchtower: add GetClientSession func to DB
This commit adds a new `GetClientSession` method to the tower client DB
which can be used to fetch a session by its ID from the DB.
2023-03-20 10:46:52 +02:00
Elle Mouton
5283e2c341
watchtower/wtdb: remove unnecessary tower load 2023-03-20 10:46:52 +02:00
Elle Mouton
ee0353dd24
watchtower: build channel to sessionIDs index
In this commit, a migration is added that adds an index from channel to
sessionIDs (using the DB-assigned session IDs). This will make it easier
in future to know which sessions have updates for which channels.
2023-03-20 10:46:52 +02:00
Elle Mouton
b16df45076
watchtower: add sessionID index
In this commit, a new session-ID index is added to the tower client db
with the help of a migration. This index holds a mapping from a
db-assigned-ID (a uint64 encoded using BigSize encoding) to real session
ID (33 bytes). This mapping will help us save space in future when
persisting references to sessions.
2023-03-20 10:46:52 +02:00
Elle Mouton
c1be420696
watchtower: make use of the new ClientSessionFilterFn option
In this commit, the wtclient starts making use of the new
ClientSessionFilterFn to do any session filtering instead of doing it in
memory.
2023-03-16 14:59:08 +02:00
Elle Mouton
40ac82e439
watchtower: add ClientSessionFilterFn to session requests
In this commit, a new ClientSessionFilterFn parameter is added to the
DB's ListClientSession method which can be used to allow the caller to
specify a filter function for filtering sessions read from the DB.
Currently all filtering of sessions are done after the sessions have
been read from the DB, so adding this option should provide some
efficiency.
2023-03-16 14:59:08 +02:00
Elle Mouton
f6ef3db6ea
watchtower/wtdb: add tower-to-session index entry for all towers
In this commit, a small migration is added to the watchtower client DB
to ensure that there is an entry in the towerID-to-sessionID index for
all towers in the db regardless of if they have sessions or not. This is
required as a follow up to migration 1 since that migration only created
entries in the index for towers that had associated sessions which would
lead to "tower not found" errors on start up.
2023-03-08 11:00:40 +02:00
Elle Mouton
33b7b9221a
channeldb+wtdb: fix migration function name lint
Rename the ApplyMigrationWithDb function to ApplyMigrationWithDB to make
the linter happy.
2023-02-16 07:51:49 +02:00
Oliver Gugger
ce5fa2e043
multi: add version to MuSig2 API, bump btcd/btcec to v2.3.2
With this commit we bump the github.com/btcd/btcec/v2 library to v2.3.2
which implements the MuSig2 BIP version v1.0.0rc2. With this the
github.com/btcsuite/btcd/btcec/v2/schnorr/musig2 package becomes
v1.0.0rc2 and the github.com/lightningnetwork/lnd/internal/musig2v040
stays at the old v0.4.0 version.
2023-02-03 18:30:10 +01:00
Oliver Gugger
d960fcd68a
multi: remove gomnd disable directives 2023-01-17 19:43:26 +01:00
Elle Mouton
c3a2368f46
multi: migrate towers to use RangeIndex for AckedUpdates
In this commit, a migration is done that takes all the AckedUpdates of
all sessions and stores them in the RangeIndex pattern instead and
deletes the session's old AckedUpdates bucket. All the logic in the code
is also updates in order to write and read from this new structure.
2023-01-11 13:59:03 +02:00
Elle Mouton
50ad10666c
watchtower/wtdb: add migration code for AckedUpdates
In this commit, the code for migration 4 is added. This migration takes
all the existing session acked updates and migrates them to be stored in
the RangeIndex form instead. Note that this migration is not activated
in this commit. This is done in a follow up commit in order to keep this
one smaller.
2023-01-11 13:59:03 +02:00
Elle Mouton
870a91a1e8
watchtower/wtdb: add ability for a multi-tx db migration
In this commit, we add the ability to add a wtdb version migration that
does not get given a transaction but rather a whole db object. This will
be useful for migrations that are best done in multiple transaction in
order to use less RAM.
2023-01-11 13:59:03 +02:00
Elle Mouton
0f6229d9e6
watchtower: convert helpers to methods
In preparation for an upcoming commit where some helper functions will
need access to the ClientDB's ackedRangeIndex member, this commit
converts those helper functions into methods on the ClientDB struct.
2023-01-11 13:59:02 +02:00
Elle Mouton
e2ae563304
watchtower: add in-mem acked range index to ClientDB
In this commit, an RangeIndex set is added to the ClientDB along with
getter methods that can be used to populate this in-memory set from the
DB.
2023-01-11 13:59:02 +02:00
Elle Mouton
4ea6c7d2ae
watchtower: refactor putClientSessionBody
Refactor the putClientSessionBody to take in a session sub-bucket rather
than the top-level session bucket. This is mainly to make an upcoming
commit diff easier to parse.
2023-01-11 13:59:02 +02:00
Elle Mouton
25afc8ad90
watchtower: add RangeIndex and tests
In this commit, a new concept called a RangeIndex is introduced. It
provides an efficient way to keep track of numbers added to a set by
keeping track of various ranges instead of individual numbers.

Notably, it also provides a way to map the contents & diffs applied to
the in memory RangeIndex (which uses a sorted array structure) to a
persisted KV structure.
2023-01-11 13:46:55 +02:00
Elle Mouton
fdba28ab7d
watchtower: add channelID index
In this commit, a new channel-ID index is added to the tower client db
with the help of a migration. This index holds a mapping from a
db-assigned-ID (a uint64 encoded using BigSize encoding) to real channel
ID (32 bytes). This mapping will help us save space in future when
persisting references to channels.
2023-01-11 13:46:55 +02:00
Elle Mouton
d03047f313
watchtower: migrate channel summaries
In this commit a migration of the tower client db is done. The migration
creates a new top-level cChanDetailsBkt bucket and for each channel
found in the old cChanSummaryBkt bucket, it creates a new sub-bucket. In
the subbucket, the ClientChanSummary is then stored under the
cChannelSummary key. The reason for this migration is that it will be
useful in future when we want to store more easily accessible data under
a specific client ID.
2023-01-11 13:46:55 +02:00
Elle Mouton
4ab8c57eae
watchtower: make better use of getChanSummary
Small refactor just to make the upcoming commit easier to parse. In
this commit, we make better use of the getChanSummary helper function.
2023-01-11 13:46:54 +02:00
Oliver Gugger
55b53555e9
multi: improve readability of goroutine defers
This commit fixes the readability of some of the defer calls in
goroutines by making sure the defer stands out properly.
2022-11-21 13:54:24 +01:00
Matt Morehouse
e15d3e898e
brontide,lnwire,wtwire,zpay32: appease linter
Address all linter complaints for the newly migrated fuzz tests.
2022-11-11 08:44:30 -06:00
Matt Morehouse
5a48568806
brontide,lnwire,wtwire,zpay32: use CamelCase
Rename fuzz test functions to use CamelCase.
2022-11-11 08:44:24 -06:00
Conner
1ed2a1bc28
wtwire: migrate fuzz tests 2022-11-11 08:44:01 -06:00
Elle Mouton
3ff5abc9e3
watchtower: allow removal during session negotiation
In this commit, the bug demonstrated in the previous commit is fixed.
The locking capabilities of the AddressIterator are used to lock
addresses if they are being used for session negotiation. So now, when a
request comes through to remove a tower address then a check is first
done to ensure that the address is not currently in use. If it is not,
then the request can go through.
2022-10-20 15:46:56 +02:00
Elle Mouton
b2039f245e
watchtower: demo cant remove tower during negotiation bug
In this commit, a new test is added to demonstrate that an error is
thrown if a user attempts to remove a tower during session negotiation
even if no current negotiation is taking place with the tower.
2022-10-20 15:46:55 +02:00
Elle Mouton
8a7329b988
watchtower: make use of the new AddressIterator
This commit upgrades the wtclient package to make use of the new
`AddressIterator`. It does so by first creating new `Tower` and
`ClientSession` types. The new `Tower` type has an `AddressIterator`
instead of a list of addresses. The `ClientSession` type contains a
`Tower`.
2022-10-20 15:46:52 +02:00
Elle Mouton
7924542500
watchtower: add AddressIterator and tests
In this commit, a new AddressIterator type is added. It is a type that
can be used to iterate over a list of addresses. It strictly disallows
the list of addresses it holds to be empty. It also allows callers to
place locks on certain addresses in order to prevent other callers from
removing the addresses in question from the iterator.
2022-10-20 15:46:03 +02:00
Elle Mouton
5bc8ee48fc
watchtower: demo that client cant update tower address
In this commit, a test is added to demonstrate that if a client tries to
update the address of a tower for an active tower session, then this new
address will not be used until the client restarts. This is a bug that
will be fixed in a future commit.
2022-10-20 11:32:08 +02:00
Elle Mouton
60f58b7812
watchtower: simplify the newHarness test function 2022-10-19 18:49:18 +02:00
Elle Mouton
4828fd902d
wtclient: allow multiplie callback dial functions
This commit is a step towards prepping the watchtower client test
harness to be able to handle the case where the client connects to
multiple mock servers.
2022-10-19 18:49:18 +02:00
Elle Mouton
ab4d4a19be
watchtower/wtclient: upgrade pkg to use require
Upgrade all the tests in the wtclient package to make use of the
`require` package.
2022-10-19 18:49:17 +02:00