-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Itest: proper connect/disconnect miner #4589
Itest: proper connect/disconnect miner #4589
Conversation
13b2720
to
06ffce6
Compare
|
||
// After shutting down the chain backend, we'll make a copy of | ||
// the log file before deleting the temporary log dir. | ||
logFile := logDir + "/" + netParams.Name + "/btcd.log" | ||
err := CopyFile("./output_btcd_chainbackend.log", logFile) | ||
if err != nil { | ||
fmt.Printf("unable to copy file: %v\n", err) | ||
errStr += fmt.Sprintf("unable to copy file: %v\n", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add \n
if errStr != ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. The newline is added above when the first error appears.
06ffce6
to
62f4441
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, I definitely agree that having more control over the miner connection will ease debugging.
Left a few small comments. Could you add a more detailed explanation to the PR description how the linked btcd PR is needed for the tests to pass?
lntest/itest/lnd_test.go
Outdated
@@ -14458,6 +14460,14 @@ func TestLightningNetworkDaemon(t *testing.T) { | |||
ht.Fatalf("unable to request transaction notifications: %v", err) | |||
} | |||
|
|||
// Connect chainbackend to miner. | |||
if chainBackend.Name() != "neutrino" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could instead make the neutrino ConnectMiner
a noop return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that's cleaner, changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, my bad, now fixed😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, I definitely agree that having more control over the miner connection will ease debugging.
Left a few small comments. Could you add a more detailed explanation to the PR description how the linked btcd PR is needed for the tests to pass?
The description is updated, previous investigation can be found in this issue #4553.
lntest/itest/lnd_test.go
Outdated
@@ -14458,6 +14460,14 @@ func TestLightningNetworkDaemon(t *testing.T) { | |||
ht.Fatalf("unable to request transaction notifications: %v", err) | |||
} | |||
|
|||
// Connect chainbackend to miner. | |||
if chainBackend.Name() != "neutrino" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that's cleaner, changed.
62f4441
to
79a45b4
Compare
make/testing_flags.mk
Outdated
@@ -69,4 +69,4 @@ endif | |||
# Construct the integration test command with the added build flags. | |||
ITEST_TAGS := $(DEV_TAGS) $(RPC_TAGS) rpctest $(backend) | |||
|
|||
ITEST := rm lntest/itest/*.log; date; $(GOTEST) -v ./lntest/itest -tags="$(ITEST_TAGS)" $(TEST_FLAGS) -logoutput -goroutinedump | |||
ITEST := rm lntest/itest/*.log; rm -r lntest/itest/.minerlogs; rm -r lntest/itest/.backendlogs; date; $(GOTEST) -v ./lntest/itest -tags="$(ITEST_TAGS)" $(TEST_FLAGS) -logoutput -goroutinedump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really needed? Won't they be deleted on shutdown, or alternatively overwritten on next run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have doubts too. Normally it would be fine until there are .gz
files, which won't be cleaned if a sequence of itest fails consecutively.
It might be more related to a different PR that focuses on fixing .gz
files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would make that a separate PR if it is a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now removed.
Thanks for the detailed explanation, it makes a lot of sense now 👍 We should update our btcd dependency to check whether that will get rid of some of the flakes, but when that is in I think this PR is more or less ready :) |
c90653e
to
2812dc2
Compare
@yyforyongyu changes look great! can you add a commit that pulls in the btcd dep so we can get a clean run of the itests? |
2812dc2
to
6e662a0
Compare
Previously the chainbackend connected to the miner using a permanent connection, which would retry the connection when it’s disconnected. It would leave multiple connections between the chainbackend and the miner, causing difficulties in debugging. Currently, there are two occasions when disconnection happens. One happens when running the open channel reorg test, the miner is connected/disconnected multiple times on purpose. The other happens when the chainbackend receives a MSG_WITNESS_TX type from the miner, which would be considered as an invalid type and disconnects the miner. With the latter one being fixed in btcd, the chainbackend will still be disconnected from the miner if it reaches the ban score by requesting too many notfound messages in a short time which is why the `--nobanning` flag is added.
6e662a0
to
2fd236b
Compare
2fd236b
to
65383a1
Compare
The Initially, I was using --- FAIL: TestLightningNetworkDaemon (31.06s)
lnd_test.go:14526: Running 66 integration tests
--- FAIL: TestLightningNetworkDaemon/sweep_coins (2.81s)
lnd_test.go:112: Failed: (sweep coins): exited with error:
*errors.errorString unable to sweep coins: rpc error: code = Unknown desc = unable to broadcast sweep transaction: unmatched backend error: -1: sendrawtransaction "hexstring" ( maxfeerate ) Specifically, in this line. I'm suspecting the change in this commit is causing the problem of using It's unclear if the bug is in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💫
@yyforyongyu do you still want to investigate the windows build? i restarted travis and it passed first time. otherwise i think this is ready to merge
Yes, I'm still investigating the test flake. Don't know if it's the best approach, but I've run the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great change, thanks again! 🌟
This PR tries to make it easier to catch flakes in itest. It,
The last one is somewhat tricky. Before this fix, the
btcd
chain backend automatically retries connecting to the miner on several occasions,testOpenChannelAfterReorg
, we manually disconnected the chain backend and the miner. Still, the chain backend retried in 5s and succeeded.The miner ended with multiple connections with the chain backend, which makes debugging difficult.
And a recent change in btcd validates the not found message and disconnects the peer when needed.
When this
InvTypeWitnessTx
is receieved by thechainbackend
, it's considered invalid and the miner will be disconnected. Currently, due to the permanent connection, the chainbackend will retry connection in 5 seconds. This is more clear in the following log, notice that the miner and chainbackend logs are combined and ordered by time,The ending
1073741825
is a type,The above log happened during test setup, right after this line. After generating the blocks, we would wait for the balance to be synced. It wouldn't happen though, as the miner was disconnected and later the sync would time out.
Detailed logs can be found here.
Current itest won't pass, blocked by this fix in btcd btcsuite/btcd#1625
Related #4553, #4561 and #4563.