Commit Graph

18 Commits

Author SHA1 Message Date
Elle Mouton
2c786ec66f
channeldb: add local and remote balance to revocation log
This commit re-adds the LocalBalance and RemoteBalance fields to the
RevocationLog. The channeldb/migration30 is also adjusted so that anyone
who has not yet run the optional migration will not lose these fields if
they run the migration after this commit.

The reason for re-adding these fields is that they are needed if we want
to reconstruct all the info of the lnwallet.BreachRetribution without
having access to the breach spend transaction. In most cases we would
have access to the spend tx since we would see it on-chain at which time
we would want to reconstruct the retribution info. However, for the
watchtower subsystem, we sometimes want to construct the retribution
info withouth having access to the spend transaction.

A user can use the `--no-rev-log-amt-data` flag to opt-out of storing
these amount fields.
2023-02-16 20:47:35 +02:00
Elle Mouton
0730337cc7
multi: add new NoRevLogAmtData config option
In this commit, a new `--db.no-rev-log-amt-data` flag is added. The
config option is passed though to everywhere that it will be used. Note
that it is still a no-op in this commit. An upcoming commit will make
use of the flag.
2023-02-16 20:47:29 +02:00
Elle Mouton
9c01916bc0
channeldb: add NoAmountData field to MigrateRevLogConfigImpl
Add a NoAmountData field to the MigrateRevLogConfigImpl struct and set
it for tests. This field is still a no-op in the migration.
2023-02-16 20:46:05 +02:00
Elle Mouton
70e3f8f511
multi: pass in a MigrationConfig to all optional migrations
Define a MigrationConfig interface that should be used to pass the
config of an optional migration function. An implementation of this
interface is added for migration30 (the only current optional
migration).
2023-02-16 20:45:08 +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
Elle Mouton
ce8e7ecfa7
channeldb: prepare RevocationLog for optional fields
This commit is a pure refactor. It restructures the RevocationLog
serialize and deserialize methods so that optional TLV fields can be
easily added.
2023-02-16 07:51:48 +02:00
Elle Mouton
af076d8ff4
channeldb: add shouldFail param to ApplyMigrationWithDB
Add a shouldFail boolean parameter to the migtest ApplyMigrationWithDB
in order to make it easier to test migration failures.
2023-01-11 13:59:03 +02:00
Eng Zer Jun
dd07cb850d
channeldb: use T.TempDir to create temporary test directory
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-08-24 08:58:16 +08:00
yyforyongyu
0735522194
multi: fix make fmt 2022-08-23 22:10:24 +08:00
yyforyongyu
b391503ddf
migration30: validate migration results before deleting old buckets
This commit adds a new method `validateMigration` to be used prior to
the deletion of the old buckets to be extraly cautious.
2022-07-12 21:01:12 +08:00
yyforyongyu
78a73f9761
migration30: cover the case where v0.15.0 is active
This commit changes how we locate the next migration height by including
the scenario where `lnd@v0.15.0` is active. In the new version, we will
see a mixed of new and old logs under the same open channel bucket.
Hence, we need to alter how we locate the next un-migrated height.
2022-07-12 21:01:12 +08:00
yyforyongyu
1832a93d19
migration30: add benchmark test 2022-07-12 21:01:11 +08:00
yyforyongyu
5316fcd6c9
migration30+migtest: add unit tests for migration 2022-07-12 21:01:11 +08:00
yyforyongyu
61bff6086c
migration30: add migration to convert old revocation logs
This commit adds the migration that's used to convert the old revocation
logs into the new format. The migration is fault-tolerant, meaning the
process can be interrupted and the migration will pick up what's left
when running again. We also cap how many records to be processed in each
db transaction to prevent OOM.
2022-07-12 21:01:08 +08:00
yyforyongyu
2a06145137
migration30: add unit tests for iterator 2022-07-12 20:51:48 +08:00
yyforyongyu
75dbbb55ad
migration30: add supporting functions to help with unit tests
This commit adds supporting functions that will be used in the unit
test. The testing data are also added as hard-coded. We choose to copy
the most of the testing data from our itest results such that a) they
are "real" data that can be used to calculate scripts and b) we preserve
the result generated by the current code so a future change won't affect
our test.
2022-07-12 20:51:48 +08:00
yyforyongyu
ebbdf78d52
migration30: add iterator to assist migration
This commit adds several utility functions to assist the migration. In
particular, an updateLocator is added to gives us the next un-migration
position in our buckets. This locator helps us to continue the job
in case of an interrupted migration. It also serves as an indicator on
whether the migration is finished or not.
2022-07-12 20:51:45 +08:00
yyforyongyu
674b0ec5fb
migration30: add related revocation log and lnwallet code
This commit adds relevant code from the revocation_log.go and the
package lnwallet. The code is needed to migrate the data, and we choose
to copy the code instead of importing to preserve the version such that
a future change won't affect current migration. An alternative would be
tagging each of the packages imported.
2022-07-08 13:17:57 +08:00