From bdf5410be356ca97a92fe5202ec2d06df97d8882 Mon Sep 17 00:00:00 2001 From: Core Dev Date: Fri, 11 Sep 2026 10:06:52 +0800 Subject: [PATCH 1/3] fix: hotfix for wasmd v0.54.10-rc.2 --- Dockerfile | 83 +++++-- Makefile | 4 +- app/config/const.go | 1 + app/upgrade_handler.go | 9 + app/upgrades/v2.21/upgrade.go | 20 ++ go.mod | 12 +- go.sum | 8 +- integration-tests/package.json | 3 +- .../chain-upgrade/upgrade-simulation-21.sh | 227 ++++++++++++++++++ 9 files changed, 328 insertions(+), 39 deletions(-) create mode 100644 app/upgrades/v2.21/upgrade.go create mode 100755 integration-tests/src/setup/chain-upgrade/upgrade-simulation-21.sh diff --git a/Dockerfile b/Dockerfile index 3d89f08f..39e4bae6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,13 +10,12 @@ FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} AS base ############################################################################### FROM base AS builder-stage-1 -ARG GO_VERSION="1.22.10" +ARG GO_VERSION="1.23.6" ARG GIT_COMMIT ARG GIT_VERSION ARG BUILDPLATFORM ARG GOOS=linux \ GOARCH=amd64 - ENV GOOS=$GOOS \ GOARCH=$GOARCH @@ -35,7 +34,8 @@ RUN set -eux &&\ linux-headers \ build-base \ cmake \ - git + git \ + patchelf # install mimalloc for musl WORKDIR ${GOPATH}/src/mimalloc @@ -53,33 +53,57 @@ RUN set -eux &&\ WORKDIR ${GOPATH}/src/app COPY ledger-go ./ledger-go COPY go.mod go.sum ./ + +# Hotfix to wire private wasmd +COPY .modcache/ /modcache/ +ENV GOPROXY=file:///modcache,https://proxy.golang.org,direct RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ go mod download -x - -# Cosmwasm - Download correct libwasmvm version -RUN set -eux &&\ - WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \ - WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \ - wget ${WASMVM_DOWNLOADS}/checksums.txt -O /tmp/checksums.txt; \ - if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \ - WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.x86_64.a"; \ - WASMVM_FILE="libwasmvm_muslc.x86_64.a"; \ - elif [ ${BUILDPLATFORM} = "linux/arm64" ]; then \ - WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.aarch64.a"; \ - WASMVM_FILE="libwasmvm_muslc.aarch64.a"; \ - # elif [ ${BUILDPLATFORM} = "darwin/amd64" ]; then \ - # WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ - # elif [ ${BUILDPLATFORM} = "darwin/arm64" ]; then \ - # WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ +RUN apk add --no-cache xz \ + && unxz -c "$(go list -mod=readonly -m -f '{{.Dir}}' github.com/CosmWasm/wasmvm/v2)/internal/api/libwasmvm_muslc.$(uname -m).a.xz" \ + > "/lib/libwasmvm_muslc.$(uname -m).a" +RUN set -eux; \ + if [ "${BUILDPLATFORM}" = "linux/amd64" ]; then \ + WASMVM_ARCH="x86_64"; \ + WASMVM_SHA256="3032aa5b8d486625327073dc60e007bcebd5a6202cdcecb7d5b21ca8bc0a4889"; \ + elif [ "${BUILDPLATFORM}" = "linux/arm64" ]; then \ + WASMVM_ARCH="aarch64"; \ + WASMVM_SHA256="ebd660d24d0d698c4784f8d4598e487c7fd8c8f8b64f70282734cf9669527a74"; \ else \ - echo "Unsupported Build Platfrom ${BUILDPLATFORM}"; \ + echo "Unsupported build platform: ${BUILDPLATFORM}"; \ exit 1; \ fi; \ - wget ${WASMVM_URL} -O /lib/${WASMVM_FILE}; \ - CHECKSUM=`sha256sum /lib/${WASMVM_FILE} | cut -d" " -f1`; \ - grep ${CHECKSUM} /tmp/checksums.txt; \ - rm /tmp/checksums.txt + echo "${WASMVM_SHA256} /lib/libwasmvm_muslc.${WASMVM_ARCH}.a" | sha256sum -c - + + +#RUN --mount=type=cache,target=/root/.cache/go-build \ +# --mount=type=cache,target=/root/go/pkg/mod \ +# go mod download -x + +# Cosmwasm - Download correct libwasmvm version +#RUN set -eux &&\ + #WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \ + #WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \ + #wget ${WASMVM_DOWNLOADS}/checksums.txt -O /tmp/checksums.txt; \ + #if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \ + #WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.x86_64.a"; \ + #WASMVM_FILE="libwasmvm_muslc.x86_64.a"; \ + #elif [ ${BUILDPLATFORM} = "linux/arm64" ]; then \ + #WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.aarch64.a"; \ + #WASMVM_FILE="libwasmvm_muslc.aarch64.a"; \ + ## elif [ ${BUILDPLATFORM} = "darwin/amd64" ]; then \ + ## WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ + ## elif [ ${BUILDPLATFORM} = "darwin/arm64" ]; then \ + ## WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ + #else \ + #echo "Unsupported Build Platfrom ${BUILDPLATFORM}"; \ + #exit 1; \ + #fi; \ + #wget ${WASMVM_URL} -O /lib/${WASMVM_FILE}; \ + #CHECKSUM=`sha256sum /lib/${WASMVM_FILE} | cut -d" " -f1`; \ + #grep ${CHECKSUM} /tmp/checksums.txt; \ + #rm /tmp/checksums.txt ############################################################################### @@ -91,6 +115,8 @@ ARG GOOS=linux \ ENV GOOS=$GOOS \ GOARCH=$GOARCH +ENV GOPROXY=file:///modcache,https://proxy.golang.org,direct + # Copy the remaining files COPY . . @@ -102,16 +128,21 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ -tags "netgo,muslc" \ -ldflags " \ -w -s -linkmode=external -extldflags \ - '-L/go/src/mimalloc/build -lmimalloc -Wl,-z,muldefs -static' \ + '-L/go/src/mimalloc/build -lmimalloc -Wl,-z,muldefs -static-pie -z noexecstack' \ -X github.com/cosmos/cosmos-sdk/version.Name='terrad' \ -X github.com/cosmos/cosmos-sdk/version.AppName='terrad' \ -X github.com/cosmos/cosmos-sdk/version.Version=${GIT_VERSION} \ -X github.com/cosmos/cosmos-sdk/version.Commit=${GIT_COMMIT} \ -X github.com/cosmos/cosmos-sdk/version.BuildTags='netgo,muslc' \ " \ + -buildmode=pie \ -trimpath \ ./... +# Strip the RPATH/RUNPATH baked in by the external linker so the released +# binary does not try to load libraries from build-time paths +RUN patchelf --remove-rpath /go/bin/terrad + ################################################################################ FROM alpine:${ALPINE_VERSION} as terra-core @@ -123,4 +154,4 @@ RUN addgroup -g 1000 terra && \ WORKDIR /app -CMD ["terrad", "--home", "/app", "start"] \ No newline at end of file +CMD ["terrad", "--home", "/app", "start"] diff --git a/Makefile b/Makefile index 21594b72..8da01c10 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ BINDIR ?= $(GOPATH)/bin BUILDDIR ?= $(CURDIR)/build DOCKER := $(shell which docker) SHA256_CMD = sha256sum -GO_VERSION ?= "1.22.10" +GO_VERSION ?= "1.23.6" # don't override user values ifeq (,$(VERSION)) VERSION := $(shell git describe --tags) @@ -323,4 +323,4 @@ localnet-stop: localnet-start: localnet-stop localnet-build-env localnet-build-nodes -.PHONY: localnet-stop localnet-start localnet-build-env localnet-build-nodes localnet-rmi \ No newline at end of file +.PHONY: localnet-stop localnet-start localnet-build-env localnet-build-nodes localnet-rmi diff --git a/app/config/const.go b/app/config/const.go index 0714094c..bf57c326 100644 --- a/app/config/const.go +++ b/app/config/const.go @@ -230,4 +230,5 @@ const ( Upgrade2_18 = "v2.18" Upgrade2_19 = "v2.19" Upgrade2_20 = "v2.20" + Upgrade2_21 = "v2.21" ) diff --git a/app/upgrade_handler.go b/app/upgrade_handler.go index 68dfc9d9..230ab8dc 100644 --- a/app/upgrade_handler.go +++ b/app/upgrade_handler.go @@ -18,6 +18,7 @@ import ( v2_19 "github.com/terra-money/core/v2/app/upgrades/v2.19" v2_2_0 "github.com/terra-money/core/v2/app/upgrades/v2.2.0" v2_20 "github.com/terra-money/core/v2/app/upgrades/v2.20" + v2_21 "github.com/terra-money/core/v2/app/upgrades/v2.21" v2_3_0 "github.com/terra-money/core/v2/app/upgrades/v2.3.0" v2_4 "github.com/terra-money/core/v2/app/upgrades/v2.4" v2_5 "github.com/terra-money/core/v2/app/upgrades/v2.5" @@ -192,6 +193,14 @@ func (app *TerraApp) RegisterUpgradeHandlers() { app.Keepers, ), ) + app.Keepers.UpgradeKeeper.SetUpgradeHandler( + terraappconfig.Upgrade2_21, + v2_21.CreateUpgradeHandler( + app.GetModuleManager(), + app.GetConfigurator(), + app.Keepers, + ), + ) } func (app *TerraApp) RegisterUpgradeStores() { diff --git a/app/upgrades/v2.21/upgrade.go b/app/upgrades/v2.21/upgrade.go new file mode 100644 index 00000000..46e5346b --- /dev/null +++ b/app/upgrades/v2.21/upgrade.go @@ -0,0 +1,20 @@ +package v2_21 + +import ( + "context" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/terra-money/core/v2/app/keepers" +) + +func CreateUpgradeHandler( + mm *module.Manager, + cfg module.Configurator, + k keepers.TerraAppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, cfg, vm) + } +} diff --git a/go.mod b/go.mod index 94c56aa6..e2d3939a 100644 --- a/go.mod +++ b/go.mod @@ -19,10 +19,10 @@ require ( cosmossdk.io/x/tx v0.13.8 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmd v0.54.9 - github.com/CosmWasm/wasmvm/v2 v2.2.8 + github.com/CosmWasm/wasmvm/v2 v2.2.9-rc.2 github.com/cometbft/cometbft v0.38.21 github.com/cometbft/cometbft-db v0.14.1 // indirect - github.com/cosmos/btcutil v1.0.5 + github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-db v1.1.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.50.15 @@ -53,10 +53,7 @@ require ( google.golang.org/grpc v1.70.0 ) -require ( - github.com/hashicorp/go-metrics v0.5.3 - golang.org/x/crypto v0.33.0 -) +require github.com/hashicorp/go-metrics v0.5.3 require ( cloud.google.com/go v0.115.0 // indirect @@ -205,6 +202,7 @@ require ( go.opentelemetry.io/otel/trace v1.32.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.17.0 // indirect + golang.org/x/crypto v0.33.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/net v0.35.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect @@ -228,6 +226,8 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + github.com/CosmWasm/wasmd => github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.2 + github.com/CosmWasm/wasmvm/v2 => github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.2 github.com/cosmos/cosmos-sdk => github.com/phoenix-directive/cosmos-sdk v0.50.15-terra.0 github.com/cosmos/ledger-cosmos-go => ./ledger-go github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 diff --git a/go.sum b/go.sum index 74536c47..3d182b8c 100644 --- a/go.sum +++ b/go.sum @@ -237,10 +237,10 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CosmWasm/wasmd v0.54.9 h1:rca0ee3o6rLaoTt07Z4bKq6toYl/5nWHWEdO1tUmSqo= -github.com/CosmWasm/wasmd v0.54.9/go.mod h1:4uTpkoUHtKJtNyjqKCiASR1eslzjpNJqlgIzFuuPdmU= -github.com/CosmWasm/wasmvm/v2 v2.2.8 h1:7RqbEOTntOba8WjaWpQY5zU9xyyCVDKq0i4RSRa+M6M= -github.com/CosmWasm/wasmvm/v2 v2.2.8/go.mod h1:Aj/rB2KMRM8nAdbWxkO23rnQYb5KsoPuH9ZizSi0sVg= +github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.2 h1:RAvnc8Bl19znzW8Hg7RAzVX5afOUMvBVq5VekXG6PW4= +github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.2/go.mod h1:KqdFBLaM9TpeSp/cRjU715t3XUyy5Ne4d+fRCG46rNo= +github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.2 h1:yS1qKBilhE7eioSWpcczmcr6bZzpm+hiWsnWYzZ5rCI= +github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.2/go.mod h1:Aj/rB2KMRM8nAdbWxkO23rnQYb5KsoPuH9ZizSi0sVg= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= diff --git a/integration-tests/package.json b/integration-tests/package.json index d36e4015..12536b00 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -16,6 +16,7 @@ "test:chain:upgrade:v18": "bash src/setup/chain-upgrade/upgrade-simulation-18.sh", "test:chain:upgrade:v19": "bash src/setup/chain-upgrade/upgrade-simulation-19.sh", "test:chain:upgrade:v20": "bash src/setup/chain-upgrade/upgrade-simulation-20.sh", + "test:chain:upgrade:v21": "bash src/setup/chain-upgrade/upgrade-simulation-21.sh", "test:start": "jest --runInBand --detectOpenHandles", "start": "npm run test:init && npm run test:relayer && npm run test:start", "test:clean": "rm -rf src/test-data chain-upgrade-data && pkill terrad && pkill terrad && pkill relayer" @@ -49,4 +50,4 @@ "long": "^5.3.1" }, "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" -} \ No newline at end of file +} diff --git a/integration-tests/src/setup/chain-upgrade/upgrade-simulation-21.sh b/integration-tests/src/setup/chain-upgrade/upgrade-simulation-21.sh new file mode 100755 index 00000000..b4703b7b --- /dev/null +++ b/integration-tests/src/setup/chain-upgrade/upgrade-simulation-21.sh @@ -0,0 +1,227 @@ +#!/bin/bash + +OLD_VERSION=release/v2.20 +UPGRADE_HEIGHT=30 +CHAIN_ID=test-1 +CHAIN_HOME=$(pwd)/chain-upgrade-data +CONTRACT_PATH=$(pwd)/src/contracts/counter.wasm +DENOM=uluna +SOFTWARE_UPGRADE_NAME="v2.21" +GOV_PERIOD="3s" + +VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion" +VAL_MNEMONIC_2="alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart" +WALLET_MNEMONIC_1="banner spread envelope side kite person disagree path silver will brother under couch edit food venture squirrel civil budget number acquire point work mass" +WALLET_MNEMONIC_2="veteran try aware erosion drink dance decade comic dawn museum release episode original list ability owner size tuition surface ceiling depth seminar capable only" +WALLET_MNEMONIC_3="vacuum burst ordinary enact leaf rabbit gather lend left chase park action dish danger green jeans lucky dish mesh language collect acquire waste load" + +export OLD_BINARY=$CHAIN_HOME/terrad_old +export NEW_BINARY=$CHAIN_HOME/terrad_new + +rm -rf /tmp/terra +rm -r $CHAIN_HOME +mkdir $CHAIN_HOME +killall terrad_old +killall terrad_new + +# install old binary +if ! command -v $OLD_BINARY &> /dev/null +then + mkdir -p /tmp/terra + cd /tmp/terra + git clone https://github.com/terra-money/core + cd core + git checkout $OLD_VERSION + make build + cp /tmp/terra/core/build/terrad $CHAIN_HOME/terrad_old + cd $CHAIN_HOME +fi + +# install new binary +if ! command -v $NEW_BINARY &> /dev/null +then + cd ../.. + make build + cp build/terrad $NEW_BINARY +fi + +# init genesis +$OLD_BINARY init test --home $CHAIN_HOME --chain-id=$CHAIN_ID +echo $VAL_MNEMONIC_1 | $OLD_BINARY keys add val1 --home $CHAIN_HOME --recover --keyring-backend=test +VAL_ADDR_1=$($OLD_BINARY keys show val1 --home $CHAIN_HOME --keyring-backend=test --output=json | jq .address -r) + +echo $WALLET_MNEMONIC_1 | $OLD_BINARY keys add wallet1 --home $CHAIN_HOME --recover --keyring-backend=test +WALLET_ADDR_1=$($OLD_BINARY keys show wallet1 --home $CHAIN_HOME --keyring-backend=test --output=json | jq .address -r) + +echo $WALLET_MNEMONIC_2 | $OLD_BINARY keys add wallet2 --home $CHAIN_HOME --recover --keyring-backend=test +WALLET_ADDR_2=$($OLD_BINARY keys show wallet2 --home $CHAIN_HOME --keyring-backend=test --output=json | jq .address -r) + +echo $WALLET_MNEMONIC_3 | $OLD_BINARY keys add wallet3 --home $CHAIN_HOME --recover --keyring-backend=test +WALLET_ADDR_3=$($OLD_BINARY keys show wallet3 --home $CHAIN_HOME --keyring-backend=test --output=json | jq .address -r) + +$OLD_BINARY genesis add-genesis-account $($OLD_BINARY --home $CHAIN_HOME keys show val1 --keyring-backend test -a) 100000000000uluna --home $CHAIN_HOME + +CURRENT_TIME=$(date +%s) +echo "Current time: $CURRENT_TIME" +$OLD_BINARY genesis add-genesis-account $($OLD_BINARY --home $CHAIN_HOME keys show wallet1 --keyring-backend test -a) 100000000000uluna --vesting-amount 200000000uluna --vesting-start-time $CURRENT_TIME --vesting-end-time $(($CURRENT_TIME + 10000)) --home $CHAIN_HOME + +$OLD_BINARY genesis gentx val1 1000000000uluna --home $CHAIN_HOME --chain-id $CHAIN_ID --keyring-backend test --commission-max-rate 0.01 --commission-rate 0.01 --commission-max-change-rate 0.01 +$OLD_BINARY genesis collect-gentxs --home $CHAIN_HOME + +sed -i -e "s/\"max_deposit_period\": \"172800s\"/\"max_deposit_period\": \"$GOV_PERIOD\"/g" $CHAIN_HOME/config/genesis.json +sed -i -e "s/\"voting_period\": \"172800s\"/\"voting_period\": \"$GOV_PERIOD\"/g" $CHAIN_HOME/config/genesis.json + +sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_HOME/config/config.toml +sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_HOME/config/config.toml +sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_HOME/config/config.toml +sed -i -e 's/enable = false/enable = true/g' $CHAIN_HOME/config/app.toml +sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_HOME/config/app.toml + +# run old node +echo "Starting old binary on a separate process" +if [[ "$OSTYPE" == "darwin"* ]]; then + screen -L -dmS node1 $OLD_BINARY start --log_level trace --log_format json --home $CHAIN_HOME --pruning=nothing +else + screen -L -Logfile $CHAIN_HOME/log-screen.log -dmS node1 $OLD_BINARY start --log_level trace --log_format json --home $CHAIN_HOME --pruning=nothing +fi + +sleep 5 + +VALOPER_ADDR_1=$($OLD_BINARY q staking validators --output=json --home $CHAIN_HOME | jq .validators[0].operator_address -r) + +echo "Create new periodic vesting account $WALLET_ADDR_2" +echo '{ + "start_time": '$(date +%s)', + "periods":[ + { + "coins": "10000000uluna", + "length_seconds": 10000 + }, + { + "coins": "10000000uluna", + "length_seconds": 10000 + } + ] +}' > $CHAIN_HOME/create-periodic-vesting-account.json +NO_ECHO=$($OLD_BINARY tx vesting create-periodic-vesting-account $WALLET_ADDR_2 $CHAIN_HOME/create-periodic-vesting-account.json --from val1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y -o json) +sleep 1 +NO_ECHO=$($OLD_BINARY tx vesting create-periodic-vesting-account $WALLET_ADDR_3 $CHAIN_HOME/create-periodic-vesting-account.json --from val1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y -o json) +sleep 1 + +GOV_ADDRESS=$($OLD_BINARY query auth module-account gov --home $CHAIN_HOME --output json | jq .account.base_account.address -r) +echo '{ + "messages": [ + { + "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + "authority" : "'"$GOV_ADDRESS"'", + "plan" : { + "name": "'"$SOFTWARE_UPGRADE_NAME"'", + "time": "0001-01-01T00:00:00Z", + "height": "'"$UPGRADE_HEIGHT"'", + "upgraded_client_state": null + } + } + ], + "metadata": "", + "deposit": "550000000'$DENOM'", + "title": "Upgrade to '$SOFTWARE_UPGRADE_NAME'", + "summary": "Source Code Version https://github.com/terra-money/core" +}' > $CHAIN_HOME/software-upgrade.json + +echo "Submit proposal" +NO_ECHO=$($OLD_BINARY tx gov submit-proposal $CHAIN_HOME/software-upgrade.json --from val1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y) +sleep 2 +echo "Vote" +NO_ECHO=$($OLD_BINARY tx gov vote 1 yes --from val1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y) + +## determine block_height to halt +while true; do + BLOCK_HEIGHT=$($OLD_BINARY status --home $CHAIN_HOME | jq '.SyncInfo.latest_block_height' -r) + if [ $BLOCK_HEIGHT = "$UPGRADE_HEIGHT" ]; then + # assuming running only 1 terrad + echo "BLOCK HEIGHT = $UPGRADE_HEIGHT REACHED, STOPPING OLD BINARY" + pkill terrad_old + break + else + STATUS=$($OLD_BINARY query gov proposal 1 --output=json --home $CHAIN_HOME | jq ".status" -r) + echo "BLOCK_HEIGHT = $BLOCK_HEIGHT $STATUS" + sleep 1 + fi +done +sleep 1 + +# run new binary +echo "Starting new binary" +LOG_FILE="$CHAIN_HOME/log-screen.log" + +screen -dmS node1 bash -c \ + "$NEW_BINARY start --log_format json --home '$CHAIN_HOME' --pruning=nothing >> '$LOG_FILE' 2>&1" + +sleep 15 + +echo "Upgrade successful" + +# get new block height +NEW_BLOCK_HEIGHT=$($NEW_BINARY status --home $CHAIN_HOME | jq '.sync_info.latest_block_height' -r) +echo "NEW_BLOCK_HEIGHT $NEW_BLOCK_HEIGHT" + +# assert that the new block height is greater than the upgrade height +if [ $NEW_BLOCK_HEIGHT -le $UPGRADE_HEIGHT ]; then + echo "New block height is less than or equal to the upgrade height" + exit 1 +fi + + +echo "Performing some sanity checks" + +# Create a new token +echo "Create a new token" +NO_ECHO=$($NEW_BINARY tx tokenfactory create-denom test --from wallet1 --keyring-backend test --gas auto --gas-adjustment 1.5 --home $CHAIN_HOME --chain-id $CHAIN_ID -y) +sleep 1 +TOKEN_DENOM=$($NEW_BINARY query tokenfactory denoms-from-creator $WALLET_ADDR_1 --home $CHAIN_HOME --output=json | jq .denoms[0] -r) +echo "TOKEN_DENOM $TOKEN_DENOM" +echo "Mint token" +NO_ECHO=$($NEW_BINARY tx tokenfactory mint 1000000000$TOKEN_DENOM --from wallet1 --keyring-backend test --gas auto --gas-adjustment 1.5 --home $CHAIN_HOME --chain-id $CHAIN_ID -y) +sleep 1 + +# Upload a contract +echo "Upload a contract" +# NO_ECHO=$($OLD_BINARY tx wasm store $CONTRACT_PATH --from wallet1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y) +NO_ECHO=$($NEW_BINARY tx wasm store $CONTRACT_PATH --from wallet1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME --gas auto --gas-adjustment 1.5 -y) +sleep 1 + +# Instantiate a contract +echo "Instantiate a contract" +NO_ECHO=$($NEW_BINARY tx wasm instantiate 1 '{"count":0}' --amount 100000000$TOKEN_DENOM --from wallet1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME --label "counter" --no-admin -y) +sleep 1 +CONTRACT_ADDRESS=$($NEW_BINARY query wasm list-contract-by-code 1 --output=json --home $CHAIN_HOME | jq .contracts[0] -r) +echo "CONTRACT_ADDRESS $CONTRACT_ADDRESS" +CONTRACT_BALANCE=$($NEW_BINARY query bank balances $CONTRACT_ADDRESS --home $CHAIN_HOME --output=json | jq ".balances[0].amount") +if [[ "$CONTRACT_BALANCE" == "100000000" ]]; then + echo "Contract balance is less than 100000000" + exit 1 +fi + +# Check period vesting account +echo "Check period vesting account" +PERIOD_VESTING_BALANCE_1=$($NEW_BINARY query bank spendable-balances $WALLET_ADDR_2 --home $CHAIN_HOME --output=json | jq ".balances[0].amount") +echo "PERIOD_VESTING_BALANCE_1 $PERIOD_VESTING_BALANCE_1" +sleep 5 +PERIOD_VESTING_BALANCE_2=$($NEW_BINARY query bank spendable-balances $WALLET_ADDR_2 --home $CHAIN_HOME --output=json | jq ".balances[0].amount") +echo "PERIOD_VESTING_BALANCE_2 $PERIOD_VESTING_BALANCE_2" +if (( ${PERIOD_VESTING_BALANCE_2//\"} <= ${PERIOD_VESTING_BALANCE_1//\"} )); then + echo "Period vesting account balance must be updated every block" + exit 1 +fi + +# Check libwasmvm version +echo "Check libwasmvm version" +WASMVM_VERSION=$($NEW_BINARY query wasm libwasmvm-version --home "$CHAIN_HOME") + +if [[ "$WASMVM_VERSION" != "2.2.9-rc.2" ]]; then + echo "Wrong libwasmvm version: $WASMVM_VERSION" + exit 1 +fi + +# kill screen +screen -X -S node1 quit From 467e9ad75a9a53b57d9dcaa3ed480c2331da48f4 Mon Sep 17 00:00:00 2001 From: Core Dev Date: Tue, 22 Sep 2026 00:10:55 +0800 Subject: [PATCH 2/3] fix: wasmd rc3 --- Dockerfile | 4 ++-- go.mod | 6 +++--- go.sum | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 39e4bae6..eaf73fd0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,10 +66,10 @@ RUN apk add --no-cache xz \ RUN set -eux; \ if [ "${BUILDPLATFORM}" = "linux/amd64" ]; then \ WASMVM_ARCH="x86_64"; \ - WASMVM_SHA256="3032aa5b8d486625327073dc60e007bcebd5a6202cdcecb7d5b21ca8bc0a4889"; \ + WASMVM_SHA256="c2e4018d532138fad3113a140ccb6c73cfa41b5c9889633b08299e59568616b9"; \ elif [ "${BUILDPLATFORM}" = "linux/arm64" ]; then \ WASMVM_ARCH="aarch64"; \ - WASMVM_SHA256="ebd660d24d0d698c4784f8d4598e487c7fd8c8f8b64f70282734cf9669527a74"; \ + WASMVM_SHA256="0b52937b401b5595232c91ab98e4645f5fdcc86220105a6eab60eba938cf8f46"; \ else \ echo "Unsupported build platform: ${BUILDPLATFORM}"; \ exit 1; \ diff --git a/go.mod b/go.mod index e2d3939a..785969ee 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( cosmossdk.io/x/tx v0.13.8 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmd v0.54.9 - github.com/CosmWasm/wasmvm/v2 v2.2.9-rc.2 + github.com/CosmWasm/wasmvm/v2 v2.2.9-rc.3 github.com/cometbft/cometbft v0.38.21 github.com/cometbft/cometbft-db v0.14.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect @@ -226,8 +226,8 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - github.com/CosmWasm/wasmd => github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.2 - github.com/CosmWasm/wasmvm/v2 => github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.2 + github.com/CosmWasm/wasmd => github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.3 + github.com/CosmWasm/wasmvm/v2 => github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.3 github.com/cosmos/cosmos-sdk => github.com/phoenix-directive/cosmos-sdk v0.50.15-terra.0 github.com/cosmos/ledger-cosmos-go => ./ledger-go github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 diff --git a/go.sum b/go.sum index 3d182b8c..7662ede1 100644 --- a/go.sum +++ b/go.sum @@ -237,10 +237,10 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.2 h1:RAvnc8Bl19znzW8Hg7RAzVX5afOUMvBVq5VekXG6PW4= -github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.2/go.mod h1:KqdFBLaM9TpeSp/cRjU715t3XUyy5Ne4d+fRCG46rNo= -github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.2 h1:yS1qKBilhE7eioSWpcczmcr6bZzpm+hiWsnWYzZ5rCI= -github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.2/go.mod h1:Aj/rB2KMRM8nAdbWxkO23rnQYb5KsoPuH9ZizSi0sVg= +github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.3 h1:PUUYiJyrR10pPwJuQN228dWzuwuslrxrgq1URUZK7OM= +github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.3/go.mod h1:pdyJ9E0rSXa5TogZ33ifSDYVMqlTW6vhuFBdUu0ceb0= +github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.3 h1:DqG31AYhsyKUgnmWonSUqU0HnLLs9Wu+oNSvhz8Zwis= +github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.3/go.mod h1:Aj/rB2KMRM8nAdbWxkO23rnQYb5KsoPuH9ZizSi0sVg= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= From a34bed7aa49b3b9177976015526e3bce8c3aed59 Mon Sep 17 00:00:00 2001 From: Core Dev Date: Wed, 30 Sep 2026 15:48:07 +0800 Subject: [PATCH 3/3] update: wasmd and wasmvm --- Dockerfile | 66 ++++++++++++++++++------------------------------------ go.mod | 6 ++--- go.sum | 8 +++---- 3 files changed, 28 insertions(+), 52 deletions(-) diff --git a/Dockerfile b/Dockerfile index eaf73fd0..4f0af20f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,56 +54,34 @@ WORKDIR ${GOPATH}/src/app COPY ledger-go ./ledger-go COPY go.mod go.sum ./ -# Hotfix to wire private wasmd -COPY .modcache/ /modcache/ -ENV GOPROXY=file:///modcache,https://proxy.golang.org,direct + RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ go mod download -x -RUN apk add --no-cache xz \ - && unxz -c "$(go list -mod=readonly -m -f '{{.Dir}}' github.com/CosmWasm/wasmvm/v2)/internal/api/libwasmvm_muslc.$(uname -m).a.xz" \ - > "/lib/libwasmvm_muslc.$(uname -m).a" -RUN set -eux; \ - if [ "${BUILDPLATFORM}" = "linux/amd64" ]; then \ - WASMVM_ARCH="x86_64"; \ - WASMVM_SHA256="c2e4018d532138fad3113a140ccb6c73cfa41b5c9889633b08299e59568616b9"; \ - elif [ "${BUILDPLATFORM}" = "linux/arm64" ]; then \ - WASMVM_ARCH="aarch64"; \ - WASMVM_SHA256="0b52937b401b5595232c91ab98e4645f5fdcc86220105a6eab60eba938cf8f46"; \ + +# Cosmwasm - Download correct libwasmvm version +RUN set -eux &&\ + WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \ + WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \ + wget ${WASMVM_DOWNLOADS}/checksums.txt -O /tmp/checksums.txt; \ + if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \ + WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.x86_64.a"; \ + WASMVM_FILE="libwasmvm_muslc.x86_64.a"; \ + elif [ ${BUILDPLATFORM} = "linux/arm64" ]; then \ + WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.aarch64.a"; \ + WASMVM_FILE="libwasmvm_muslc.aarch64.a"; \ + elif [ ${BUILDPLATFORM} = "darwin/amd64" ]; then \ + WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ + elif [ ${BUILDPLATFORM} = "darwin/arm64" ]; then \ + WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ else \ - echo "Unsupported build platform: ${BUILDPLATFORM}"; \ + echo "Unsupported Build Platfrom ${BUILDPLATFORM}"; \ exit 1; \ fi; \ - echo "${WASMVM_SHA256} /lib/libwasmvm_muslc.${WASMVM_ARCH}.a" | sha256sum -c - - - -#RUN --mount=type=cache,target=/root/.cache/go-build \ -# --mount=type=cache,target=/root/go/pkg/mod \ -# go mod download -x - -# Cosmwasm - Download correct libwasmvm version -#RUN set -eux &&\ - #WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \ - #WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \ - #wget ${WASMVM_DOWNLOADS}/checksums.txt -O /tmp/checksums.txt; \ - #if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \ - #WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.x86_64.a"; \ - #WASMVM_FILE="libwasmvm_muslc.x86_64.a"; \ - #elif [ ${BUILDPLATFORM} = "linux/arm64" ]; then \ - #WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.aarch64.a"; \ - #WASMVM_FILE="libwasmvm_muslc.aarch64.a"; \ - ## elif [ ${BUILDPLATFORM} = "darwin/amd64" ]; then \ - ## WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ - ## elif [ ${BUILDPLATFORM} = "darwin/arm64" ]; then \ - ## WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm.dylib"; \ - #else \ - #echo "Unsupported Build Platfrom ${BUILDPLATFORM}"; \ - #exit 1; \ - #fi; \ - #wget ${WASMVM_URL} -O /lib/${WASMVM_FILE}; \ - #CHECKSUM=`sha256sum /lib/${WASMVM_FILE} | cut -d" " -f1`; \ - #grep ${CHECKSUM} /tmp/checksums.txt; \ - #rm /tmp/checksums.txt + wget ${WASMVM_URL} -O /lib/${WASMVM_FILE}; \ + CHECKSUM=`sha256sum /lib/${WASMVM_FILE} | cut -d" " -f1`; \ + grep ${CHECKSUM} /tmp/checksums.txt; \ + rm /tmp/checksums.txt ############################################################################### diff --git a/go.mod b/go.mod index 785969ee..17aa744b 100644 --- a/go.mod +++ b/go.mod @@ -18,8 +18,8 @@ require ( cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/tx v0.13.8 cosmossdk.io/x/upgrade v0.1.4 - github.com/CosmWasm/wasmd v0.54.9 - github.com/CosmWasm/wasmvm/v2 v2.2.9-rc.3 + github.com/CosmWasm/wasmd v0.54.10 + github.com/CosmWasm/wasmvm/v2 v2.2.9 github.com/cometbft/cometbft v0.38.21 github.com/cometbft/cometbft-db v0.14.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect @@ -226,8 +226,6 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - github.com/CosmWasm/wasmd => github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.3 - github.com/CosmWasm/wasmvm/v2 => github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.3 github.com/cosmos/cosmos-sdk => github.com/phoenix-directive/cosmos-sdk v0.50.15-terra.0 github.com/cosmos/ledger-cosmos-go => ./ledger-go github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 diff --git a/go.sum b/go.sum index 7662ede1..bcb9ba82 100644 --- a/go.sum +++ b/go.sum @@ -237,10 +237,10 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.3 h1:PUUYiJyrR10pPwJuQN228dWzuwuslrxrgq1URUZK7OM= -github.com/CosmWasm/priv_wasmd_sec v0.54.10-rc.3/go.mod h1:pdyJ9E0rSXa5TogZ33ifSDYVMqlTW6vhuFBdUu0ceb0= -github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.3 h1:DqG31AYhsyKUgnmWonSUqU0HnLLs9Wu+oNSvhz8Zwis= -github.com/CosmWasm/priv_wasmvm_sec/v2 v2.2.9-rc.3/go.mod h1:Aj/rB2KMRM8nAdbWxkO23rnQYb5KsoPuH9ZizSi0sVg= +github.com/CosmWasm/wasmd v0.54.10 h1:oBimGq6b0huSdJJdjSBeKxBaNV/vi3ynUboSAOaD0c8= +github.com/CosmWasm/wasmd v0.54.10/go.mod h1:vj2tGXyqjKSk9jm04VCi5VVwdsJ5DacijspfaMGWyRM= +github.com/CosmWasm/wasmvm/v2 v2.2.9 h1:SdMuA2RAGE0IBkKvHn4GoBqnaWmdanCAGl7oadZdxNw= +github.com/CosmWasm/wasmvm/v2 v2.2.9/go.mod h1:Aj/rB2KMRM8nAdbWxkO23rnQYb5KsoPuH9ZizSi0sVg= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=