From cee52763208caa4c2197d11fcf0e0f8e7abbf769 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Sat, 4 Nov 2023 14:21:38 -0600 Subject: [PATCH] Should work with wasmvm forks (#194) * Should work with wasmvm forks * update label, return empty version for non-wasmvm chains * switch to new repo --- builder/builder.go | 13 ++++++++++--- chains.yaml | 11 +++++++++++ dockerfile/cosmos/Dockerfile | 4 +++- dockerfile/cosmos/local.Dockerfile | 6 ++++-- dockerfile/cosmos/localcross.Dockerfile | 8 +++++--- dockerfile/cosmos/native.Dockerfile | 4 +++- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/builder/builder.go b/builder/builder.go index 53e809d..3c38180 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -213,13 +213,15 @@ func getModFile( // getWasmvmVersion will get the wasmvm version from the mod file func getWasmvmVersion(modFile *modfile.File) string { - wasmvmRepo := "github.com/CosmWasm/wasmvm" + const defaultWasmvmRepo = "github.com/CosmWasm/wasmvm" + wasmvmRepo := defaultWasmvmRepo wasmvmVersion := "" // First check all the "requires" for _, item := range modFile.Require { // Must have 2 tokens, repo & version if (len(item.Syntax.Token) == 2) && (strings.Contains(item.Syntax.Token[0], wasmvmRepo)) { + wasmvmRepo = item.Syntax.Token[0] wasmvmVersion = item.Syntax.Token[1] } } @@ -228,13 +230,18 @@ func getWasmvmVersion(modFile *modfile.File) string { for _, item := range modFile.Replace { // Must have 3 or more tokens if (len(item.Syntax.Token) > 2) && (strings.Contains(item.Syntax.Token[0], wasmvmRepo)) { + wasmvmRepo = item.Syntax.Token[len(item.Syntax.Token)-2] wasmvmVersion = item.Syntax.Token[len(item.Syntax.Token)-1] } } - fmt.Println("WasmVM version from go.mod: ", wasmvmVersion) + fmt.Printf("WasmVM from go.mod: repo: %s, version: %s\n", wasmvmRepo, wasmvmVersion) - return wasmvmVersion + if wasmvmVersion == "" { + return "" + } + + return wasmvmRepo + " " + wasmvmVersion } // buildChainNodeDockerImage builds the requested chain node docker image diff --git a/chains.yaml b/chains.yaml index 5a2060d..5547adc 100644 --- a/chains.yaml +++ b/chains.yaml @@ -1130,6 +1130,17 @@ build-env: - BUILD_TAGS=muslc +# Terra Classic +- name: terra-classic + github-organization: classic-terra + github-repo: core + dockerfile: cosmos + build-target: make install + binaries: + - /go/bin/terrad + build-env: + - BUILD_TAGS=muslc + # Thorchain - name: thorchain repo-host: gitlab.com diff --git a/dockerfile/cosmos/Dockerfile b/dockerfile/cosmos/Dockerfile index d0c4342..6398984 100644 --- a/dockerfile/cosmos/Dockerfile +++ b/dockerfile/cosmos/Dockerfile @@ -50,7 +50,9 @@ RUN set -eux;\ fi;\ fi;\ if [ ! -z "${WASMVM_VERSION}" ]; then\ - wget -O $LIBDIR/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$ARCH.a;\ + WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\ + WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\ + wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.${ARCH}.a;\ fi;\ export GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"';\ if [ ! -z "$PRE_BUILD" ]; then sh -c "${PRE_BUILD}"; fi;\ diff --git a/dockerfile/cosmos/local.Dockerfile b/dockerfile/cosmos/local.Dockerfile index 32236d4..297634c 100644 --- a/dockerfile/cosmos/local.Dockerfile +++ b/dockerfile/cosmos/local.Dockerfile @@ -15,8 +15,10 @@ WORKDIR /go/src/${REPO_HOST}/${GITHUB_ORGANIZATION}/${GITHUB_REPO} # Download CosmWasm libwasmvm if found RUN set -eux; \ export ARCH=$(uname -m); \ - if [ ! -z "${WASMVM_VERSION}" ]; then \ - wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$(uname -m).a; \ + if [ ! -z "${WASMVM_VERSION}" ]; then\ + WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\ + WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\ + wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.$(uname -m).a;\ fi; ARG BUILD_DIR diff --git a/dockerfile/cosmos/localcross.Dockerfile b/dockerfile/cosmos/localcross.Dockerfile index 7c7960e..8fa4023 100644 --- a/dockerfile/cosmos/localcross.Dockerfile +++ b/dockerfile/cosmos/localcross.Dockerfile @@ -30,6 +30,7 @@ ARG BUILD_ENV ARG BUILD_TAGS ARG PRE_BUILD ARG BUILD_DIR +ARG WASMVM_VERSION RUN set -eux;\ LIBDIR=/lib;\ @@ -48,9 +49,10 @@ RUN set -eux;\ export CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++;\ fi;\ fi;\ - WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $NF}');\ - if [ ! -z "${WASM_VERSION}" ]; then\ - wget -O $LIBDIR/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.$ARCH.a;\ + if [ ! -z "${WASMVM_VERSION}" ]; then\ + WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\ + WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\ + wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.${ARCH}.a;\ fi;\ export GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"';\ if [ ! -z "$PRE_BUILD" ]; then sh -c "${PRE_BUILD}"; fi;\ diff --git a/dockerfile/cosmos/native.Dockerfile b/dockerfile/cosmos/native.Dockerfile index 069d5ec..584da11 100644 --- a/dockerfile/cosmos/native.Dockerfile +++ b/dockerfile/cosmos/native.Dockerfile @@ -28,7 +28,9 @@ ARG WASMVM_VERSION RUN set -eux;\ export ARCH=$(uname -m);\ if [ ! -z "${WASMVM_VERSION}" ]; then\ - wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$(uname -m).a;\ + WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\ + WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\ + wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.$(uname -m).a;\ fi;\ export CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"';\ if [ ! -z "$PRE_BUILD" ]; then sh -c "${PRE_BUILD}"; fi;\