From f360d2511051ad1107fcc3c3e8bda28ea111cb30 Mon Sep 17 00:00:00 2001 From: roy-dydx <133032749+roy-dydx@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:03:24 -0400 Subject: [PATCH] Unify version name constants in images (#2096) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> (cherry picked from commit 35406185052eab36e72d9c8a105a1f440d953aab) --- protocol/testing/containertest/Dockerfile | 1 + protocol/testing/containertest/containertest.sh | 2 +- protocol/testing/containertest/testnet.go | 6 ++---- protocol/testing/containertest/testnet_test.go | 3 ++- protocol/testing/current_version.sh | 5 ----- protocol/testing/mainnet/Dockerfile | 2 +- protocol/testing/mainnet/vars.sh | 2 +- protocol/testing/testnet/Dockerfile | 2 +- protocol/testing/testnet/vars.sh | 2 +- protocol/testing/version/README.md | 1 + protocol/testing/version/VERSION_CURRENT | 1 + protocol/testing/version/VERSION_PREUPGRADE | 1 + protocol/testing/version/version.go | 6 ++++++ protocol/testing/version/version.sh | 7 +++++++ 14 files changed, 26 insertions(+), 15 deletions(-) delete mode 100755 protocol/testing/current_version.sh create mode 100644 protocol/testing/version/README.md create mode 100644 protocol/testing/version/VERSION_CURRENT create mode 100644 protocol/testing/version/VERSION_PREUPGRADE create mode 100644 protocol/testing/version/version.go create mode 100755 protocol/testing/version/version.sh diff --git a/protocol/testing/containertest/Dockerfile b/protocol/testing/containertest/Dockerfile index 6f4f1f3ceab..0cf132ae8c3 100644 --- a/protocol/testing/containertest/Dockerfile +++ b/protocol/testing/containertest/Dockerfile @@ -7,6 +7,7 @@ COPY ./testing/containertest/preupgrade_genesis.json /dydxprotocol/preupgrade_ge COPY ./testing/genesis.sh /dydxprotocol/genesis.sh COPY ./daemons/pricefeed/client/constants/testdata /dydxprotocol/exchange_config COPY ./testing/delaymsg_config /dydxprotocol/delaymsg_config +COPY ./testing/version/. /dydxprotocol/ RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0 diff --git a/protocol/testing/containertest/containertest.sh b/protocol/testing/containertest/containertest.sh index fbaf6df002a..b7680e58000 100755 --- a/protocol/testing/containertest/containertest.sh +++ b/protocol/testing/containertest/containertest.sh @@ -5,9 +5,9 @@ set -eo pipefail # This file should be run as part of `docker-compose.yml`. source "./genesis.sh" +source "./version.sh" CHAIN_ID="localdydxprotocol" -PREUPGRADE_VERSION="v5.1.0-rc2" # Define mnemonics for all validators. MNEMONICS=( diff --git a/protocol/testing/containertest/testnet.go b/protocol/testing/containertest/testnet.go index 4d83280c563..ff1d657d554 100644 --- a/protocol/testing/containertest/testnet.go +++ b/protocol/testing/containertest/testnet.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/price_function/testexchange" pricefeed "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types" + "github.com/dydxprotocol/v4-chain/protocol/testing/version" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" pricefeed_testutil "github.com/dydxprotocol/v4-chain/protocol/testutil/pricefeed" "github.com/ory/dockertest/v3" @@ -24,9 +25,6 @@ const persistentPeers = "17e5e45691f0d01449c84fd4ae87279578cdd7ec@testnet-local- // Resources will expire in 10 minutes const resourceLifetimeSecs = 600 -// The version of that we're upgrading to (aka the current commit) -const UpgradeToVersion = "v6.0.0" - func monikers() map[string]string { return map[string]string{ "alice": constants.AliceMnenomic, @@ -158,7 +156,7 @@ func (t *Testnet) initializeNode(moniker string) (*Node, error) { Env: []string{ "DAEMON_NAME=dydxprotocold", fmt.Sprintf("DAEMON_HOME=/dydxprotocol/chain/.%s", moniker), - fmt.Sprintf("UPGRADE_TO_VERSION=%s", UpgradeToVersion), + fmt.Sprintf("UPGRADE_TO_VERSION=%s", version.CurrentVersion), }, ExtraHosts: []string{ fmt.Sprintf("%s:host-gateway", testexchange.TestExchangeHost), diff --git a/protocol/testing/containertest/testnet_test.go b/protocol/testing/containertest/testnet_test.go index 4f78736829b..d8a0473419a 100644 --- a/protocol/testing/containertest/testnet_test.go +++ b/protocol/testing/containertest/testnet_test.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/gogoproto/jsonpb" "github.com/cosmos/gogoproto/proto" "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types" + "github.com/dydxprotocol/v4-chain/protocol/testing/version" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" "github.com/dydxprotocol/v4-chain/protocol/testutil/daemons/pricefeed/exchange_config" assets "github.com/dydxprotocol/v4-chain/protocol/x/assets/types" @@ -282,6 +283,6 @@ func TestUpgrade(t *testing.T) { defer testnet.MustCleanUp() node := testnet.Nodes["alice"] - err = UpgradeTestnet(constants.AliceAccAddress.String(), t, node, UpgradeToVersion) + err = UpgradeTestnet(constants.AliceAccAddress.String(), t, node, version.CurrentVersion) require.NoError(t, err) } diff --git a/protocol/testing/current_version.sh b/protocol/testing/current_version.sh deleted file mode 100755 index bb0a2af3aa3..00000000000 --- a/protocol/testing/current_version.sh +++ /dev/null @@ -1,5 +0,0 @@ -CURRENT_VERSION="v6.0.0" - -# Define the mapping from version to URL -declare -A version_to_url -version_to_url["v5.2.0"]="https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv5.2.0/dydxprotocold-v5.2.0-linux-amd64.tar.gz" diff --git a/protocol/testing/mainnet/Dockerfile b/protocol/testing/mainnet/Dockerfile index f5eccfcacf1..d6796ae52b2 100644 --- a/protocol/testing/mainnet/Dockerfile +++ b/protocol/testing/mainnet/Dockerfile @@ -3,7 +3,7 @@ FROM dydxprotocol-base RUN apk add --no-cache bash jq aws-cli RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0 -COPY ./testing/current_version.sh /dydxprotocol/ +COPY ./testing/version/. /dydxprotocol/ COPY ./testing/mainnet/. /dydxprotocol/ ENV HOME /dydxprotocol diff --git a/protocol/testing/mainnet/vars.sh b/protocol/testing/mainnet/vars.sh index c786aeca5f0..85e4b77fd8c 100755 --- a/protocol/testing/mainnet/vars.sh +++ b/protocol/testing/mainnet/vars.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -source "./current_version.sh" +source "./version.sh" # Full node home directories will be set up for indices 0 to LAST_FULL_NODE_INDEX LAST_FULL_NODE_INDEX=5 diff --git a/protocol/testing/testnet/Dockerfile b/protocol/testing/testnet/Dockerfile index b79ee15e566..1e9df43957b 100644 --- a/protocol/testing/testnet/Dockerfile +++ b/protocol/testing/testnet/Dockerfile @@ -3,7 +3,7 @@ FROM dydxprotocol-base RUN apk add --no-cache bash jq aws-cli RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0 -COPY ./testing/current_version.sh /dydxprotocol/ +COPY ./testing/version/. /dydxprotocol/ COPY ./testing/testnet/. /dydxprotocol/ ENV HOME /dydxprotocol diff --git a/protocol/testing/testnet/vars.sh b/protocol/testing/testnet/vars.sh index ffb9161bec1..2a29294a74a 100755 --- a/protocol/testing/testnet/vars.sh +++ b/protocol/testing/testnet/vars.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -source "./current_version.sh" +source "./version.sh" # Full node home directories will be set up for indices 0 to LAST_FULL_NODE_INDEX LAST_FULL_NODE_INDEX=2 diff --git a/protocol/testing/version/README.md b/protocol/testing/version/README.md new file mode 100644 index 00000000000..4a6f2b1d220 --- /dev/null +++ b/protocol/testing/version/README.md @@ -0,0 +1 @@ +This directory contains files to configure version names used for upgrade tests and internal nodes. These versions are used for things such as upgrade proposals and cosmovisor directory names. When updating tests and images for a new version, most of the time you just need to change the `VERSION_CURRENT` and `VERSION_PREUPGRADE` files. diff --git a/protocol/testing/version/VERSION_CURRENT b/protocol/testing/version/VERSION_CURRENT new file mode 100644 index 00000000000..9f925ba24c9 --- /dev/null +++ b/protocol/testing/version/VERSION_CURRENT @@ -0,0 +1 @@ +v6.0.0 \ No newline at end of file diff --git a/protocol/testing/version/VERSION_PREUPGRADE b/protocol/testing/version/VERSION_PREUPGRADE new file mode 100644 index 00000000000..f01c12bcd9f --- /dev/null +++ b/protocol/testing/version/VERSION_PREUPGRADE @@ -0,0 +1 @@ +v5.2.0 \ No newline at end of file diff --git a/protocol/testing/version/version.go b/protocol/testing/version/version.go new file mode 100644 index 00000000000..fa91f19a784 --- /dev/null +++ b/protocol/testing/version/version.go @@ -0,0 +1,6 @@ +package version + +import _ "embed" + +//go:embed VERSION_CURRENT +var CurrentVersion string diff --git a/protocol/testing/version/version.sh b/protocol/testing/version/version.sh new file mode 100755 index 00000000000..f7886f8c311 --- /dev/null +++ b/protocol/testing/version/version.sh @@ -0,0 +1,7 @@ +#!/bin/bash +CURRENT_VERSION=$(