Skip to content

Commit 84158d3

Browse files
committed
fixup: Simplify generation of docker compose artifacts
1 parent 24a7b48 commit 84158d3

File tree

8 files changed

+44
-72
lines changed

8 files changed

+44
-72
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ARG AVALANCHEGO_NODE_IMAGE
66

77
# ============= Compilation Stage ================
8-
FROM golang:1.21.9-bullseye AS builder
8+
FROM golang:1.21.10-bullseye AS builder
99

1010
WORKDIR /build
1111

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module github.com/ava-labs/subnet-evm
22

3-
go 1.21.9
3+
go 1.21.10
44

55
require (
66
github.com/VictoriaMetrics/fastcache v1.10.0
7-
github.com/ava-labs/avalanchego v1.11.6-0.20240506185313-bcac3aef13ad
7+
github.com/ava-labs/avalanchego v1.11.6-0.20240511033838-ad654210e3f2
88
github.com/cespare/cp v0.1.0
99
github.com/davecgh/go-spew v1.1.1
1010
github.com/deckarep/golang-set/v2 v2.1.0
@@ -95,7 +95,6 @@ require (
9595
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
9696
github.com/hashicorp/hcl v1.0.0 // indirect
9797
github.com/huin/goupnp v1.3.0 // indirect
98-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
9998
github.com/jackpal/gateway v1.0.6 // indirect
10099
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
101100
github.com/klauspost/compress v1.15.15 // indirect
@@ -123,7 +122,6 @@ require (
123122
github.com/russross/blackfriday/v2 v2.1.0 // indirect
124123
github.com/sirupsen/logrus v1.9.0 // indirect
125124
github.com/spf13/afero v1.8.2 // indirect
126-
github.com/spf13/cobra v1.5.0 // indirect
127125
github.com/spf13/jwalterweatherman v1.1.0 // indirect
128126
github.com/subosito/gotenv v1.3.0 // indirect
129127
github.com/supranational/blst v0.3.11 // indirect

go.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
5656
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
5757
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
5858
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
59-
github.com/ava-labs/avalanchego v1.11.6-0.20240506185313-bcac3aef13ad h1:jyoQE9jlda2CkJrTWZEsGpwlTZLIy2OvVFg7KqWXU5M=
60-
github.com/ava-labs/avalanchego v1.11.6-0.20240506185313-bcac3aef13ad/go.mod h1:kIad6DhZYRRpzssQXdgF9gNuiwLiATVcTiY3cg42XtQ=
59+
github.com/ava-labs/avalanchego v1.11.6-0.20240511033838-ad654210e3f2 h1:C5Ioei00V2aLguNwykw0x41NBu/XEl3cYBCdcrFGSHw=
60+
github.com/ava-labs/avalanchego v1.11.6-0.20240511033838-ad654210e3f2/go.mod h1:O1e2KiYK0IBE5ypTHmmQ2aDXP5r5hnfoKetTL3Lq6yw=
6161
github.com/ava-labs/coreth v0.13.4-0.20240506124912-82b6c4e91557 h1:92JWd4u2pqpO551gXUIZ/qDZu3l7vn8jIxX2qRyyFwM=
6262
github.com/ava-labs/coreth v0.13.4-0.20240506124912-82b6c4e91557/go.mod h1:yMIxezDyB/5moKt8LlATlfwR/Z5cmipY3gUQ1SqHvQ0=
6363
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
@@ -350,7 +350,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
350350
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
351351
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
352352
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
353-
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
354353
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
355354
github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI=
356355
github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0=
@@ -527,8 +526,6 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
527526
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
528527
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
529528
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
530-
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
531-
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
532529
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
533530
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
534531
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=

scripts/build_antithesis_images.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,31 @@ function build_images {
5454
# Define default build command
5555
local docker_cmd="docker buildx build --build-arg GO_VERSION=${GO_VERSION} --build-arg NODE_IMAGE=${node_image_name}"
5656

57-
# Build node image first to allow the config and workload image builds to use it.
57+
# Build node image first to allow the workload image to be based on it.
5858
${docker_cmd} --build-arg AVALANCHEGO_NODE_IMAGE="${avalanche_node_image}" -t "${node_image_name}" \
5959
-f "${node_dockerfile}" "${SUBNET_EVM_PATH}"
60-
${docker_cmd} --build-arg IMAGE_TAG="${TAG}" -t "${config_image_name}" -f "${base_dockerfile}.config" "${SUBNET_EVM_PATH}"
60+
TARGET_PATH="${SUBNET_EVM_PATH}/build/antithesis"
61+
if [[ -d "${TARGET_PATH}" ]]; then
62+
# Ensure the target path is empty before generating the compose config
63+
rm -r "${TARGET_PATH}"
64+
fi
65+
66+
# Ensure avalanchego and subnet-evm binaries are available to create an initial db state that includes subnets.
67+
"${AVALANCHEGO_CLONE_PATH}"/scripts/build.sh
68+
PLUGIN_PATH="${TARGET_PATH}"/plugins
69+
"${SUBNET_EVM_PATH}"/scripts/build.sh "${PLUGIN_PATH}"/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
70+
71+
# Generate compose config and db state for the config image
72+
TARGET_PATH="${TARGET_PATH}"\
73+
IMAGE_TAG="${TAG}"\
74+
AVALANCHEGO_PATH="${AVALANCHEGO_CLONE_PATH}/build/avalanchego"\
75+
AVALANCHEGO_PLUGIN_DIR="${PLUGIN_PATH}"\
76+
go run "${SUBNET_EVM_PATH}/tests/antithesis/gencomposeconfig"
77+
78+
# Build config image
79+
${docker_cmd} -t "${config_image_name}" -f "${base_dockerfile}.config" "${SUBNET_EVM_PATH}"
80+
81+
# Build workload image
6182
${docker_cmd} -t "${workload_image_name}" -f "${base_dockerfile}.workload" "${SUBNET_EVM_PATH}"
6283
}
6384

scripts/tests.build_antithesis_images.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@ docker cp "${CONTAINER_NAME}":/docker-compose.yml "${COMPOSE_FILE}"
5454
# Copy the volume paths out of the container
5555
docker cp "${CONTAINER_NAME}":/volumes "${TMPDIR}/"
5656

57-
# Run the docker compose project for 2 minutes without error. 2
58-
# minutes is suggested because the way docker-compose brings all
59-
# containers up simultaneously and the lack of coordination results in
60-
# exponential back-off on the nodes trying to bootstrap.
57+
# Run the docker compose project for 30 seconds without error. Local
58+
# network bootstrap is ~6s, but github workers can be much slower.
6159
${COMPOSE_CMD} up -d
62-
sleep 120
60+
sleep 30
6361
if ${COMPOSE_CMD} ps -q | xargs docker inspect -f '{{ .State.Status }}' | grep -v 'running'; then
6462
echo "An error occurred."
6563
exit 255

scripts/versions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# shellcheck disable=SC2034
55

66
# Don't export them as they're used in the context of other calls
7-
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'bcac3aef1'}
7+
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'ad654210e'}
88
GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'}
99

1010
# This won't be used, but it's here to make code syncs easier

tests/antithesis/Dockerfile.config

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,6 @@
1-
# The version is supplied as a build argument rather than hard-coded
2-
# to minimize the cost of version changes.
3-
ARG GO_VERSION
4-
5-
# NODE_IMAGE needs to identify an existing subnet-evm node image and should include the tag
6-
ARG NODE_IMAGE
7-
8-
# ============= Node Image State ================
9-
FROM $NODE_IMAGE AS node
10-
11-
# If this is not an instrumented node image, fake the antithesis dependencies expected by the builder.
12-
RUN [ ! -d /symbols ] && mkdir /symbols || true
13-
RUN [ ! -f /usr/lib/libvoidstar.so ] && touch /usr/lib/libvoidstar.so || true
14-
15-
# ============= Compilation Stage ================
16-
FROM golang:$GO_VERSION-bullseye AS builder
17-
18-
WORKDIR /build
19-
# Copy and download avalanche dependencies using go mod
20-
COPY go.mod .
21-
COPY go.sum .
22-
RUN go mod download
23-
24-
# Copy the code into the container
25-
COPY . .
26-
27-
# IMAGE_TAG should be set to the tag for the images in the generated docker compose file.
28-
ARG IMAGE_TAG=latest
29-
30-
# Copy the avalanchego binary and plugin from the node image
31-
RUN mkdir -p ./build/plugins
32-
COPY --from=node /avalanchego/build/avalanchego ./build
33-
COPY --from=node /avalanchego/build/plugins/* ./build/plugins/
34-
35-
# Copy antithesis dependencies required by instrumented binaries
36-
COPY --from=node /symbols /symbols
37-
COPY --from=node /usr/lib/libvoidstar.so /usr/lib/libvoidstar.so
38-
39-
# Generate docker compose configuration. If the command fails, it will likely be due to a
40-
# node configuration problem. Attempt to start a node with the same configuration so that
41-
# its logging output will be available to aid in troubleshooting.
42-
RUN export AVALANCHEGO_PATH=./build/avalanchego\
43-
export AVALANCHEGO_PLUGIN_DIR=./build/plugins;\
44-
TARGET_PATH=./build IMAGE_TAG="$IMAGE_TAG" go run ./tests/antithesis/gencomposeconfig\
45-
|| ${AVALANCHEGO_PATH} --log-display-level=debug\
46-
--config-file=$(find /root/.tmpnet/networks -name "flags.json" | head -n 1)
47-
48-
# ============= Cleanup Stage ================
491
FROM scratch AS execution
502

51-
# Copy the docker compose file and volumes into the container
52-
COPY --from=builder /build/build/docker-compose.yml /docker-compose.yml
53-
COPY --from=builder /build/build/volumes /volumes
3+
# Copy config artifacts from the build path. For simplicity, artifacts
4+
# are built outside of the docker image.
5+
COPY ./build/antithesis/docker-compose.yml /
6+
COPY ./build/antithesis/volumes /volumes

tests/antithesis/gencomposeconfig/main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ func main() {
5050
genesisPath := filepath.Join(cwd, "tests/load/genesis/genesis.json")
5151

5252
// Create a network with an xsvm subnet
53-
network := tmpnet.LocalNetworkOrDie()
53+
network := tmpnet.LocalNetworkOrPanic()
5454
network.Subnets = []*tmpnet.Subnet{
5555
utils.NewTmpnetSubnet("subnet-evm", genesisPath, utils.DefaultChainConfig, network.Nodes...),
5656
}
5757

58-
if err := antithesis.InitDBVolumes(network, avalancheGoPath, pluginDir, targetPath); err != nil {
59-
log.Fatalf("failed to initialize db volumes: %s", err)
58+
bootstrapVolumePath, err := antithesis.GetBootstrapVolumePath(targetPath)
59+
if err != nil {
60+
log.Fatalf("failed to get bootstrap volume path: %v", err)
61+
}
62+
63+
if err := antithesis.InitBootstrapDB(network, avalancheGoPath, pluginDir, bootstrapVolumePath); err != nil {
64+
log.Fatalf("failed to initialize db volumes: %v", err)
6065
}
6166

6267
if err := antithesis.GenerateComposeConfig(network, nodeImageName, workloadImageName, targetPath); err != nil {

0 commit comments

Comments
 (0)