-
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
Update btcd to master, make itest btcd harness more robust #4765
Conversation
0510c6d
to
6504203
Compare
Can be rebased now the the dependent PR is in! |
6504203
to
d243d6e
Compare
Ping when ready for review. |
d243d6e
to
215443d
Compare
I wanted to do more |
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.
tACK, looking fwd to this!
@@ -88,7 +88,7 @@ func NewBackend(miner string, netParams *chaincfg.Params) ( | |||
// make sure they stay connected if it happens. | |||
"--nobanning", | |||
} | |||
chainBackend, err := rpctest.New(netParams, nil, args) | |||
chainBackend, err := rpctest.New(netParams, nil, args, GetBtcdBinary()) |
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.
what benefit does this give us? Mostly for local testing?
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.
It avoids the test harness compiling btcd
for every run by invoking go build
. That way we also have more certainty that the actually built version of btcd
is what we define in go.mod
. Also we don't overwrite any pre-installed btcd
on the system anymore.
@@ -32,7 +31,7 @@ COMMIT_HASH := $(shell git rev-parse HEAD) | |||
|
|||
BTCD_COMMIT := $(shell cat go.mod | \ | |||
grep $(BTCD_PKG) | \ | |||
tail -n1 | \ | |||
head -n1 | \ |
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.
hm, was this wrong?
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.
It caused an error if you had a replace
directive for btcd
. The way we now compile the binary actually allows replace directives to be used. Only the unit tests still won't work with the replace (will pick what's in the upper part of go.mod
). Maybe we should try to switch the unit tests over to an explicit binary as well and get rid of the DEPGET
invocation for btcd
?
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.
Sure, but could probably be done in another PR 👍
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, wasn't thinking about adding it to this PR.
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.
👍 ran into this the other day!
@$(call print, "Building itest lnd and lncli.") | ||
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lnd | ||
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lncli | ||
@$(call print, "Building itest btcd and lnd.") |
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.
to see what actually changes here, and what is simply a refactor, would be great if you could split the commit!
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, you're right. I split the commit.
|
||
# Windows insists on having the .exe suffix for an executable, we need to add | ||
# that here if necessary. | ||
EXEC="$WORKDIR"/itest.test"$EXEC_SUFFIX" | ||
LND_EXEC="$WORKDIR"/lnd-itest"$EXEC_SUFFIX" | ||
echo $EXEC -test.v "$@" -logoutput -goroutinedump -logdir=.logs-tranche$TRANCHE -lndexec=$LND_EXEC -splittranches=$NUM_TRANCHES -runtranche=$TRANCHE | ||
BTCD_EXEC="$WORKDIR"/btcd-itest"$EXEC_SUFFIX" |
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.
what is the benefit of explicitly specifying it here?
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.
You mean why in this file and not in the Makefile
? I guess I wanted to avoid passing in even more parameters.
With this commit we update btcd to the latest version which allows us to specify the btcd binary we want to use when spinning up a new node.
With the new btcd version we can specify our own listen address generator function for any btcd nodes. This should reduce flakiness as the previous way of getting a free port was based on just picking a random number which lead to conflicts. We also double the default values for connection retries and timeouts, effectively waiting up to 4 seconds in total now.
215443d
to
afe9c06
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.
LGTM ✔️
@@ -32,7 +31,7 @@ COMMIT_HASH := $(shell git rev-parse HEAD) | |||
|
|||
BTCD_COMMIT := $(shell cat go.mod | \ | |||
grep $(BTCD_PKG) | \ | |||
tail -n1 | \ | |||
head -n1 | \ |
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.
👍 ran into this the other day!
To make the Makefile a bit easier to understand, we remove the implicit ITEST goal/command variable and switch all itest execution over to explicit goals in the main Makefile.
To remove the need to have an extra make goal for the Windows itests, we instead add the flag windows=1 that sets the make variable EXEC_SUFFIX to properly add the ".exe" suffix to all executable names.
To make sure we build the exact version of btcd that is referenced in the project's go.mod file and to not overwrite any binary the user might already have installed on the system, we compile btcd into an explicit file in the itest directory. This should also speed up invocations of "make itest-only" because the test harness doesn't always compile btcd on its own. We also fix a bug with the version parsing where adding a "replace" directive in the go.mod would result in the awk commands to extract the wrong version. Because we no longer use the DEPGET goal to build and install btcd, using a replace directive now actually works for itests.
afe9c06
to
b42c5e5
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.
LGTM 🔥
This PR updates
btcd
to current master and fixes some flakes that were caused bybtcd
's random listening port selection during itests that sometimes resulted in collisions.