Commit Graph

456 Commits

Author SHA1 Message Date
Oliver Gugger
e99e6662cf
multi: update linter, fix new issues 2024-08-20 19:14:44 +02:00
yyforyongyu
b6049ff94b
multi: add NewLogClosure in lnutils to avoid repetition
And replaces all usage of `logClosure` with `lnutils.LogClosure`.
2024-07-25 21:25:23 +08:00
yyforyongyu
8da68bb7db
multi: apply the new type lntypes.WeightUnit 2024-05-25 13:37:13 +08:00
erik
c7f81d3142 multi: replace ioutil.Discard 2024-04-25 11:23:54 +02:00
yyforyongyu
e771993785
multi: make input.OutPoint return wire.OutPoint 2024-04-19 21:33:32 +08:00
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
undefinedor
028959f5a0
kvdb+watchtower: fix unreachable code 2024-03-25 21:04:48 +08:00
Oliver Gugger
5cb4811e86
Merge pull request #8425 from ProofOfKeags/refactor/lnwallet/chan-point-leaks
[EZ Review]: avoid leaking pointers to authoritative ChannelPoint
2024-03-11 00:55:41 -06:00
Keagan McClelland
db39a905cb multi: make NewChanIDFromOutpoint accept value instead of pointer 2024-03-08 15:47:55 -08:00
cuinix
60bc30dd08 remove repetitive words
Signed-off-by: cuinix <915115094@qq.com>
2024-03-07 14:05:47 +08:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Elle Mouton
a9648cbdd1
wtclient: load all active towers into memory
Load an active tower into memory regardless of whether or not it has any
sessions.
2024-02-20 14:44:38 +02:00
Elle Mouton
24702ede14
wtclient: add TerminateSession method 2024-02-20 14:44:37 +02:00
Elle Mouton
05c03400a9
wtdb: add TerminateSession method 2024-02-20 14:44:11 +02:00
Elle Mouton
41582c0b8b
wtdb: create and remove tower should no longer change session status 2024-02-20 14:44:11 +02:00
Elle Mouton
cbf08940ca
wtdb: let DeleteCommitedUpdates move session to terminal
In this commit, we adjust the DeleteCommitmentUpdate method so that it
marks a session as Terminal (if there are updates to delete) since once
we have deleted a commitment update from a session - the session is no
longer useable.
2024-02-20 14:44:11 +02:00
Elle Mouton
5cb8c8df7e
wtdb: rename CSessionInactive to CSessionTerminal
Since we will now change this to mean that the session should not ever
be activated again.
2024-02-20 14:44:11 +02:00
Elle Mouton
beb9b2eeb8
wtclient: add DeactivateTower method
This commit adds the DeactiateTower method to the wtclient.ClientManager
interface along with its implementation. A test is also added for the
new method.
2024-02-20 14:44:09 +02:00
Elle Mouton
4548e72f79
wtdb: add a DeactivateTower method
This new method sets the tower's status to inactive so that it is not
loaded at startup as a candidate tower. We also ensure that a tower's
status is set to active if the CreateTower is called when the tower
already exists.
2024-02-20 09:02:36 +02:00
Elle Mouton
0bb1816fff
watchtower: add filter function to ListTowers
And then only load active towers on client start up.
2024-02-20 08:58:46 +02:00
Elle Mouton
ffd355c6c4
wtdb: add TowerStatus to Tower
This is added as a TLV record meaning that all the towers currently on
disk that don't have this new field will be seen as Active.
2024-02-20 08:58:46 +02:00
Elle Mouton
1ae802812c
watchtower: update DeleteCommittedUpdate to delete all
This commit updates the DeleteCommittedUpdate DB method to delete all of
a given session's committed updates instead of just one at a time. The
reason for this is that in an upcoming commit, we will introduce a
"Terminal" session state - once we have deleted a committed update for a
session it should be considered "Terminal" and there is never a case
where we would only want to delete one committed update and not the
rest. So we want these two actions (deleting committed updates of a
session and setting it's status to terminal) to be atomic.
2024-02-20 08:58:45 +02:00
Oliver Gugger
d7796b464e
Merge pull request #8377 from ellemouton/towerTestFlakeFix
wtclient: ensure correct disk mode for overflow queue
2024-01-23 09:47:27 -06:00
Elle Mouton
660f1f361e
watchtower/wtclient: prep client for taproot towers 2024-01-19 15:33:06 +02:00
Elle Mouton
c50aa10194
watchtower/lookout: make justice desciptor taproot ready 2024-01-18 18:06:00 +02:00
Elle Mouton
5960253357
watchtower/blob: add taproot Commitment type 2024-01-18 18:05:58 +02:00
Elle Mouton
d84a98e3db
watchtower/blob: add taprootJusticeKit implementation 2024-01-18 17:59:14 +02:00
Elle Mouton
0ec3f31780
watchtower/blob: add justiceKitPacketV1 encoding
In preparation for the new Taproot commitment type being supported by
watchtowers, we add a new justice packet type.
2024-01-18 17:58:13 +02:00
Elle Mouton
20a107600f
watchtower: add new TaprootCommit Type and flag
This commit adds a new FlagTaprootChannel Flag which is then used to
construct a new blob Type: TypeAltruistTaprootCommit. New watchtower
feature bits are also added (4/5).
2024-01-18 17:56:49 +02:00
Elle Mouton
65de80be7d
wtclient: remove temporary bug demonstration logic and test
This commit removes the temporary members added to the DiskOverflowQueue
that made it possible to more easily demonstrate a previous bug that
existed.
2024-01-15 17:28:43 +02:00
Elle Mouton
3d201dde50
wtclient: ensure correct disk mode for overflow queue
Before this commit, in the watchtower client's DiskOverflowQueue, there
could be a situation _if no consumer was reading from the queue_ that
could lead to an in-memory build up of backup tasks instead of the
expected disk overflow. This commit fixes this by ensuring that if a
task is read from disk, then the mode is set to disk mode to ensure that
any new items are persisted to disk in this scenario.
The unit tests added in the previous commit is updated here in order to
show that the fix does in-fact fix the test.
2024-01-15 17:28:17 +02:00
Elle Mouton
d4fefda10a
wtclient: demonstrate overflow queue flake
In this commit, some temporary variables and logic is added to the
DiskOverflowQueue for easy stop/go control from unit tests. This is then
used to write a temporary unit tests that demonstrates a race condition
that can cause the queue to be in disk mode when it should be in memory
mode. This new code & test will be removed after the issue has been
fixed.
2024-01-15 17:26:34 +02:00
Yong
26c466aa80
Merge pull request #8372 from mohamedawnallah/deep-copy-transactions-GetBlock
routing: deep copy any transaction we obtain from `GetBlock` call.
2024-01-15 20:13:00 +08:00
Mohamed Awnallah
99908ed2dc
routing: deep copy any transaciton we obtain from GetBlock call. 2024-01-15 11:35:55 +02:00
Elle Mouton
1daec3e890
wtclient: use the new filter options to fix the demo'd bug
In this commit, we use the newly added session listing options to ensure
that we only see a session as exhausted if it does not have any un-acked
updates on disk. This fixes the bug previously demonstrated.
2024-01-12 08:25:28 +02:00
Elle Mouton
776f2a026c
wtdb: supply commited update count to PostEvaluateFilterFn
In this commit, we adjust the PostEvaluateFilterFn to also take in a
count representing the number of committed updates (ie, persisted
un-acked updates) that the session has. This will be made use of in an
upcoming commit.
2024-01-12 08:23:02 +02:00
Elle Mouton
bdf9ec1423
wtclient: demonstrate "tower has un-acked updates" bug
This commit adds a test to demonstrate an edge case that can result in
the "tower has un-acked updates" error being thrown when a user is
attempting to remove a tower. This will be fixed in an upcoming commit.
2024-01-11 15:13:02 +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
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