channeldb: isolate migrations#3633
Conversation
This commit is a direct copy of the complete channeldb package. It only changes the package declaration at the top of every file. We make this full copy so that review can be focused on the actual changes made. Otherwise changes may drown in all the file moves. Linting for the new package is disabled, as it contains lots of pre-existing issues.
This commit removes the migrations from channeldb and references those in the migrations_01_to_11 package. This creates a one-way dependency on the migrations. Future changes to channeldb won't be able to break migrations anymore.
a63de58 to
eb870ce
Compare
Roasbeef
left a comment
There was a problem hiding this comment.
Seems like this diff can be much smaller (only copy the essentials).
There was a problem hiding this comment.
Do we really need to copy over all the tests as well? Can't we just copy the call graph of any encode/decode functions used in the migration.
There was a problem hiding this comment.
Previously I found that I needed some test code because it was reused. Left all of it in, but I think that also had a lot of deps that prevents more removal of code. Will look at the diff again.
There was a problem hiding this comment.
Ok, removed many more lines. Down to 5k lines now.
I used staticcheck from https://github.com/dominikh/go-tools with the -unused.whole-program flag to find more unused code.
eb870ce to
5048fd5
Compare
8114062 to
838ffb0
Compare
|
Unit tests failing. Even by only removing code, I seem to have broken something. Will investigate. |
838ffb0 to
fbfc3c2
Compare
|
Test fixed. Problem was only an uninitialized logger. Not something magical triggered by code removal. Ready for review again. |
halseth
left a comment
There was a problem hiding this comment.
not pretty, but I think it works. LGTM 🐸
There was a problem hiding this comment.
ok, guess the code is removed here.
There was a problem hiding this comment.
Not sure what this refers to. Probably you reviewed a previous version of the pr?
2f8e88f to
a29bdce
Compare
a29bdce to
60503d6
Compare
channeldb/migration_01_to_11/meta.go
Outdated
|
|
||
| // FetchMeta fetches the meta data from boltdb and returns filled meta | ||
| // structure. | ||
| func (d *DB) FetchMeta(tx *bbolt.Tx) (*Meta, error) { |
There was a problem hiding this comment.
Is this code used by anything now?
Also I wouldn't mind removing tests, since they could depend on code that otherwise could be deleted.
There was a problem hiding this comment.
The code is used to do syncVersion for migration tests. But that isn't really necessary to test every time. Added a commit that removes it.
Non-migration tests are all removed (afaik), the _test.go files that remain just contain some vars and helpers that are used in the migration tests.
Fixes #3628