Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace github.com/btcsuite/goleveldb imports with github.com/syndtr/goleveldb #1780

Merged
merged 1 commit into from Mar 8, 2022

Conversation

anupcshan
Copy link
Contributor

Generated using

$ find -name '*.go' | xargs sed -i "s#github.com/btcsuite/goleveldb#github.com/syndtr/goleveldb#g"
$ go mod tidy
$ go test -v ./...

Upstream goleveldb has 3+ years of bugfixes and improvements over the fork, which would be great to pull in.
I've been burned by a corruption which was fixed in syndtr/goleveldb@eb13543.

Related to #1770

@coveralls
Copy link

coveralls commented Dec 9, 2021

Pull Request Test Coverage Report for Build 1953020277

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+9.8%) to 79.676%

Totals Coverage Status
Change from base Build 1896270968: 9.8%
Covered Lines: 1231
Relevant Lines: 1545

💛 - Coveralls

@anupcshan
Copy link
Contributor Author

FWIW, the failing test seems to be flaky on current master commit

$ go version
go version go1.17.3 linux/amd64

$ git rev-parse --short HEAD
780cc088

$ GORACE=halt_on_error=1 go test -race -tags=rpctest -covermode atomic -coverprofile=profile.cov -test.count 1000 ./connmgr
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
FAIL
coverage: 66.5% of statements
FAIL    github.com/btcsuite/btcd/connmgr        140.646s
FAIL

@kcalvinalvin
Copy link
Collaborator

kcalvinalvin commented Dec 10, 2021

FWIW, the failing test seems to be flaky on current master commit

$ go version
go version go1.17.3 linux/amd64

$ git rev-parse --short HEAD
780cc088

$ GORACE=halt_on_error=1 go test -race -tags=rpctest -covermode atomic -coverprofile=profile.cov -test.count 1000 ./connmgr
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:297: retry: 127.0.0.1:18555 - want state 4, got state 3
--- FAIL: TestRetryPermanent (0.00s)
    connmanager_test.go:272: retry: 127.0.0.1:18555 - want state 0, got state 3
FAIL
coverage: 66.5% of statements
FAIL    github.com/btcsuite/btcd/connmgr        140.646s
FAIL

Ah yeah this happens all the time. The test sometimes passes and sometimes doesn't. Could you git --amend so that you'll get a different commit hash and force push to trigger github actions?

Also, this PR looks good to me.

@guggero
Copy link
Collaborator

guggero commented Mar 8, 2022

I also think we should use the original version instead of the fork if possible.
It looks like the fork was mainly created to add go module support? Though there also is this commit: btcsuite/goleveldb@9168d88 which adds a bunch of functionality.
@davecgh do you remember if that added any btcd specific functionality or was a pure sync with upstream? I don't really see some of those changes in the upstream repo, so not sure how to approach the diff.

@davecgh
Copy link
Member

davecgh commented Mar 8, 2022

It was primarily added prior to modules because, back in those days, Go had many of the same problems as node.js in terms of packages being able to disappear and or get updated in an incompatible way which could either break go get (aka builds back then) or allow backdoors to be introduced. We didn't want to vendor it in the main repo, so creating the fork was the most reasonable option.

Nowadays, with modules, the module mirror, and MVS, all of those issues are solved much more nicely, so I agree that it's better to use the upstream. That is, in fact, what we do in dcrd now.

@guggero
Copy link
Collaborator

guggero commented Mar 8, 2022

Yeah, I understand that concern, I probably would've done something similar.

So you can confirm that no btcd specific functionality was added in the fork and bumping to the latest upstream version shouldn't break anything?

@davecgh
Copy link
Member

davecgh commented Mar 8, 2022

Yes, unless anything was introduced after I stopped working on btcsuite, which it doesn't look like it from the commit history, nothing unique was introduced in the fork, so changing to the upstream module shouldn't break anything and is what I would recommend as well.

@guggero
Copy link
Collaborator

guggero commented Mar 8, 2022

Can confirm that the unit tests run fine locally.

The btcutil/go.sum needs to be updated though. I added your commit in my PR (#1823) to fast-track this fix.

@anupcshan
Copy link
Contributor Author

FWIW, I've been running an instance of btcd with this applied, and it was able to get fully synced up without crashes - this doesn't guarantee correctness or consistency, but I can verify it doesn't crash.

@guggero
Copy link
Collaborator

guggero commented Mar 8, 2022

Cool! Can you run go mod tidy in btcutil to fix the go mod error I get when running make unit?
That will also trigger the unit tests again. Then we can also merge this PR as it is instead of adding the commit to my PR.

@anupcshan
Copy link
Contributor Author

Cool! Can you run go mod tidy in btcutil to fix the go mod error I get when running make unit? That will also trigger the unit tests again. Then we can also merge this PR as it is instead of adding the commit to my PR.

Done. make unit passes now. Didn't realize that was broken.

@anupcshan
Copy link
Contributor Author

Actually, CI will not run automatically since this is my first btcd PR. Someone will need to approve this change before tests run.

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK, LGTM 🎉

@guggero
Copy link
Collaborator

guggero commented Mar 8, 2022

cc @Roasbeef.

@Roasbeef
Copy link
Member

Roasbeef commented Mar 8, 2022

It looks like the fork was mainly created to add go module support? Though there also is this commit: btcsuite/goleveldb@9168d88 which adds a bunch of functionality.

Correct, given that we have the option to do go mod vendor and commit those deps, we no longer really need the forks.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🦖

I think that given the sub-module sum files were updated as a result, we'll also need to push new minor tags there?

@Roasbeef Roasbeef merged commit 21b37c0 into btcsuite:master Mar 8, 2022
@anupcshan anupcshan deleted the replace-imports branch March 8, 2022 23:49
guggero added a commit to guggero/lnd that referenced this pull request Mar 21, 2022
With the recent PR lightningnetwork#6285 merged that bumped the btcd dependency, we no
longer need to bump the github.com/onsi/ginkgo package with a replace
directive. Instead it was bumped indirectly by merging
btcsuite/btcd#1780 which is included in the btcd
version we reference.
guggero added a commit to guggero/lnd that referenced this pull request Mar 21, 2022
With the recent PR lightningnetwork#6285 merged that bumped the btcd dependency, we no
longer need to bump the github.com/onsi/ginkgo package with a replace
directive. Instead it was bumped indirectly by merging
btcsuite/btcd#1780 which is included in the btcd
version we reference.
gabbyprecious pushed a commit to gabbyprecious/lnd that referenced this pull request Apr 1, 2022
With the recent PR lightningnetwork#6285 merged that bumped the btcd dependency, we no
longer need to bump the github.com/onsi/ginkgo package with a replace
directive. Instead it was bumped indirectly by merging
btcsuite/btcd#1780 which is included in the btcd
version we reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants