Skip to content

Commit

Permalink
Unify version name constants in images (#2096)
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
(cherry picked from commit 3540618)
  • Loading branch information
roy-dydx authored and mergify[bot] committed Aug 16, 2024
1 parent 39e1921 commit f360d25
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 15 deletions.
1 change: 1 addition & 0 deletions protocol/testing/containertest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/containertest/containertest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand Down
6 changes: 2 additions & 4 deletions protocol/testing/containertest/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion protocol/testing/containertest/testnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
5 changes: 0 additions & 5 deletions protocol/testing/current_version.sh

This file was deleted.

2 changes: 1 addition & 1 deletion protocol/testing/mainnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM dydxprotocol-base
RUN apk add --no-cache bash jq aws-cli
RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]

COPY ./testing/current_version.sh /dydxprotocol/
COPY ./testing/version/. /dydxprotocol/
COPY ./testing/mainnet/. /dydxprotocol/

ENV HOME /dydxprotocol
Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/mainnet/vars.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion protocol/testing/testnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM dydxprotocol-base
RUN apk add --no-cache bash jq aws-cli
RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]

COPY ./testing/current_version.sh /dydxprotocol/
COPY ./testing/version/. /dydxprotocol/
COPY ./testing/testnet/. /dydxprotocol/

ENV HOME /dydxprotocol
Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/testnet/vars.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions protocol/testing/version/README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions protocol/testing/version/VERSION_CURRENT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v6.0.0
1 change: 1 addition & 0 deletions protocol/testing/version/VERSION_PREUPGRADE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v5.2.0
6 changes: 6 additions & 0 deletions protocol/testing/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package version

import _ "embed"

//go:embed VERSION_CURRENT
var CurrentVersion string
7 changes: 7 additions & 0 deletions protocol/testing/version/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
CURRENT_VERSION=$(<VERSION_CURRENT)
PREUPGRADE_VERSION=$(<VERSION_PREUPGRADE)

# Define the mapping from version to amd64 URL
declare -A version_to_url
version_to_url["$PREUPGRADE_VERSION"]="https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2F$PREUPGRADE_VERSION/dydxprotocold-$PREUPGRADE_VERSION-linux-amd64.tar.gz"

0 comments on commit f360d25

Please sign in to comment.