Skip to content

Commit a02809e

Browse files
committed
upgrade test 2
1 parent 0e18ac5 commit a02809e

File tree

7 files changed

+112
-53
lines changed

7 files changed

+112
-53
lines changed

.github/workflows/protocol-build-and-push-snapshot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy
66
- main
77
- 'release/protocol/v[0-9]+.[0-9]+.x' # e.g. release/protocol/v0.1.x
88
- 'release/protocol/v[0-9]+.x' # e.g. release/protocol/v1.x
9+
- upgrade_9.4*
910

1011
jobs:
1112
build-and-push-snapshot-dev:

.github/workflows/protocol-build-and-push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy
66
- main
77
- 'release/protocol/v[0-9]+.[0-9]+.x' # e.g. release/protocol/v0.1.x
88
- 'release/protocol/v[0-9]+.x' # e.g. release/protocol/v1.x
9+
- upgrade_9.4*
910

1011
jobs:
1112
build-and-push-dev:

protocol/testing/genesis.sh

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,33 +2223,33 @@ function edit_genesis() {
22232223
dasel put -t string -f "$GENESIS" ".app_state.listing.listing_vault_deposit_params.main_vault_deposit_amount" -v "0" # 0 USDC
22242224
dasel put -t int -f "$GENESIS" ".app_state.listing.listing_vault_deposit_params.num_blocks_to_lock_shares" -v '2592000' # 30 days
22252225

2226-
# Vaults
2227-
# Set default quoting params.
2228-
dasel put -t int -f "$GENESIS" ".app_state.vault.default_quoting_params.spread_min_ppm" -v '3000'
2229-
# Set operator params.
2230-
dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.operator" -v 'dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky'
2231-
dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.metadata.name" -v 'Governance'
2232-
dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.metadata.description" -v 'Governance Module Account'
2233-
# Set total shares and owner shares.
2234-
if [ -z "${INPUT_TEST_ACCOUNTS[0]}" ]; then
2235-
vault_owner_address='dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4' # alice as default vault owner
2236-
else
2237-
vault_owner_address="${INPUT_TEST_ACCOUNTS[0]}"
2238-
fi
2239-
total_deposit=$((DEFAULT_SUBACCOUNT_QUOTE_BALANCE_VAULT * ${#INPUT_VAULT_NUMBERS[@]}))
2240-
dasel put -t string -f "$GENESIS" ".app_state.vault.total_shares.num_shares" -v "${total_deposit}"
2241-
dasel put -t json -f "$GENESIS" ".app_state.vault.owner_shares.[]" -v '{}'
2242-
dasel put -t string -f "$GENESIS" ".app_state.vault.owner_shares.[0].owner" -v "${vault_owner_address}"
2243-
dasel put -t string -f "$GENESIS" ".app_state.vault.owner_shares.[0].shares.num_shares" -v "${total_deposit}"
2244-
# Set vaults.
2245-
vault_idx=0
2246-
for number in "${INPUT_VAULT_NUMBERS[@]}"; do
2247-
dasel put -t json -f "$GENESIS" '.app_state.vault.vaults.[]' -v '{}'
2248-
dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_id.type" -v 'VAULT_TYPE_CLOB'
2249-
dasel put -t int -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_id.number" -v "${number}"
2250-
dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_params.status" -v 'VAULT_STATUS_QUOTING'
2251-
vault_idx=$(($vault_idx + 1))
2252-
done
2226+
# # Vaults
2227+
# # Set default quoting params.
2228+
# dasel put -t int -f "$GENESIS" ".app_state.vault.default_quoting_params.spread_min_ppm" -v '3000'
2229+
# # Set operator params.
2230+
# dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.operator" -v 'dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky'
2231+
# dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.metadata.name" -v 'Governance'
2232+
# dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.metadata.description" -v 'Governance Module Account'
2233+
# # Set total shares and owner shares.
2234+
# if [ -z "${INPUT_TEST_ACCOUNTS[0]}" ]; then
2235+
# vault_owner_address='dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4' # alice as default vault owner
2236+
# else
2237+
# vault_owner_address="${INPUT_TEST_ACCOUNTS[0]}"
2238+
# fi
2239+
# total_deposit=$((DEFAULT_SUBACCOUNT_QUOTE_BALANCE_VAULT * ${#INPUT_VAULT_NUMBERS[@]}))
2240+
# dasel put -t string -f "$GENESIS" ".app_state.vault.total_shares.num_shares" -v "${total_deposit}"
2241+
# dasel put -t json -f "$GENESIS" ".app_state.vault.owner_shares.[]" -v '{}'
2242+
# dasel put -t string -f "$GENESIS" ".app_state.vault.owner_shares.[0].owner" -v "${vault_owner_address}"
2243+
# dasel put -t string -f "$GENESIS" ".app_state.vault.owner_shares.[0].shares.num_shares" -v "${total_deposit}"
2244+
# # Set vaults.
2245+
# vault_idx=0
2246+
# for number in "${INPUT_VAULT_NUMBERS[@]}"; do
2247+
# dasel put -t json -f "$GENESIS" '.app_state.vault.vaults.[]' -v '{}'
2248+
# dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_id.type" -v 'VAULT_TYPE_CLOB'
2249+
# dasel put -t int -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_id.number" -v "${number}"
2250+
# dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_params.status" -v 'VAULT_STATUS_QUOTING'
2251+
# vault_idx=$(($vault_idx + 1))
2252+
# done
22532253

22542254
# Update accountplus module.
22552255
dasel put -t bool -f "$GENESIS" '.app_state.dydxaccountplus.params.is_smart_account_active' -v 'true'

protocol/testing/snapshotting/snapshot.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ LOG_PATH="/dydxprotocol/chain/local_node/snapshots/dydxprotocol/dydxprotocol_log
3535
# data directory to snapshot. this contains the blockchain state.
3636
DATA_PATH="/dydxprotocol/chain/local_node/data/"
3737
RPC_ADDRESS="http://127.0.0.1:26657"
38+
PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"
3839

3940
while [ $# -gt 0 ]; do
4041

@@ -62,12 +63,24 @@ install_prerequisites() {
6263
&& rm -rf /var/cache/apk/*
6364
}
6465

66+
setup_preupgrade_binary() {
67+
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv9.3.0/dydxprotocold-v9.3.0-linux-amd64.tar.gz'
68+
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
69+
mkdir -p /tmp/dydxprotocold
70+
curl -vL $tar_url -o $tar_path
71+
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
72+
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
73+
}
74+
75+
6576
setup_cosmovisor() {
6677
VAL_HOME_DIR="$HOME/chain/local_node"
6778
export DAEMON_NAME=dydxprotocold
6879
export DAEMON_HOME="$HOME/chain/local_node"
6980

70-
cosmovisor init /bin/dydxprotocold
81+
cosmovisor init $PREUPGRADE_BINARY_PATH
82+
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v9.4/bin/"
83+
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v9.4/bin/dydxprotocold"
7184
}
7285

7386
install_prerequisites
@@ -96,6 +109,7 @@ sed -i 's/min-retain-blocks = 0/min-retain-blocks = 2/' /dydxprotocol/chain/loca
96109
# Do not index tx_index.db
97110
sed -i 's/indexer = "kv"/indexer = "null"/' /dydxprotocol/chain/local_node/config/config.toml
98111

112+
setup_preupgrade_binary
99113
setup_cosmovisor
100114

101115
# TODO: add metrics around snapshot upload latency/frequency/success rate

protocol/testing/testnet-dev/dev.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ VAULT_NUMBERS=(
9797
4 # CRV clob pair ID
9898
)
9999

100+
PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"
101+
100102
# Define dependencies for this script.
101103
# `jq` and `dasel` are used to manipulate json and yaml files respectively.
102104
install_prerequisites() {
@@ -110,7 +112,7 @@ create_validators() {
110112
for i in "${!FULL_NODE_KEYS[@]}"; do
111113
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
112114
FULL_NODE_CONFIG_DIR="$FULL_NODE_HOME_DIR/config"
113-
dydxprotocold init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"
115+
$PREUPGRADE_BINARY_PATH init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"
114116

115117
# Note: `dydxprotocold init` non-deterministically creates `node_id.json` for each validator.
116118
# This is inconvenient for persistent peering during testing in Terraform configuration as the `node_id`
@@ -132,10 +134,10 @@ create_validators() {
132134
VAL_CONFIG_DIR="$VAL_HOME_DIR/config"
133135

134136
# Initialize the chain and validator files.
135-
dydxprotocold init "${MONIKERS[$i]}" -o --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
137+
$PREUPGRADE_BINARY_PATH init "${MONIKERS[$i]}" -o --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
136138

137139
# Overwrite the randomly generated `priv_validator_key.json` with a key generated deterministically from the mnemonic.
138-
dydxprotocold tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
140+
$PREUPGRADE_BINARY_PATH tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
139141

140142
# Note: `dydxprotocold init` non-deterministically creates `node_id.json` for each validator.
141143
# This is inconvenient for persistent peering during testing in Terraform configuration as the `node_id`
@@ -147,7 +149,7 @@ create_validators() {
147149

148150
edit_config "$VAL_CONFIG_DIR"
149151

150-
echo "${MNEMONICS[$i]}" | dydxprotocold keys add "${MONIKERS[$i]}" --recover --keyring-backend=test --home "$VAL_HOME_DIR"
152+
echo "${MNEMONICS[$i]}" | $PREUPGRADE_BINARY_PATH keys add "${MONIKERS[$i]}" --recover --keyring-backend=test --home "$VAL_HOME_DIR"
151153

152154
# Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..."
153155
# Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..."
@@ -157,10 +159,10 @@ create_validators() {
157159
update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "600"
158160

159161
for acct in "${TEST_ACCOUNTS[@]}"; do
160-
dydxprotocold add-genesis-account "$acct" 100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
162+
$PREUPGRADE_BINARY_PATH add-genesis-account "$acct" 100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
161163
done
162164
for acct in "${FAUCET_ACCOUNTS[@]}"; do
163-
dydxprotocold add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
165+
$PREUPGRADE_BINARY_PATH add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
164166
done
165167

166168
dydxprotocold gentx "${MONIKERS[$i]}" $TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNT$NATIVE_TOKEN --moniker="${MONIKERS[$i]}" --keyring-backend=test --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
@@ -178,7 +180,7 @@ create_validators() {
178180
cp -r /tmp/gentx "$FIRST_VAL_CONFIG_DIR"
179181

180182
# Build the final genesis.json file that all validators and the full-nodes will use.
181-
dydxprotocold collect-gentxs --home "$FIRST_VAL_HOME_DIR"
183+
$PREUPGRADE_BINARY_PATH collect-gentxs --home "$FIRST_VAL_HOME_DIR"
182184

183185
# Copy this genesis file to each of the other validators
184186
for i in "${!MONIKERS[@]}"; do
@@ -202,6 +204,15 @@ create_validators() {
202204
done
203205
}
204206

207+
setup_preupgrade_binary() {
208+
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv9.3.0/dydxprotocold-v9.3.0-linux-amd64.tar.gz'
209+
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
210+
mkdir -p /tmp/dydxprotocold
211+
curl -vL $tar_url -o $tar_path
212+
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
213+
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
214+
}
215+
205216
setup_cosmovisor() {
206217
for i in "${!FULL_NODE_KEYS[@]}"; do
207218
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
@@ -216,7 +227,9 @@ setup_cosmovisor() {
216227
export DAEMON_NAME=dydxprotocold
217228
export DAEMON_HOME="$HOME/chain/.${MONIKERS[$i]}"
218229

219-
cosmovisor init /bin/dydxprotocold
230+
cosmovisor init $PREUPGRADE_BINARY_PATH
231+
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v9.4/bin/"
232+
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v9.4/bin/dydxprotocold"
220233
done
221234
}
222235

protocol/testing/testnet-local/local.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ VAULT_NUMBERS=(
7575
1 # ETH clob pair ID
7676
)
7777

78+
PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"
79+
7880
# Define dependencies for this script.
7981
# `jq` and `dasel` are used to manipulate json and yaml files respectively.
8082
install_prerequisites() {
81-
apk add dasel jq
83+
apk add curl dasel jq
8284
}
8385

8486
# Create all validators for the chain including a full-node.
@@ -93,10 +95,10 @@ create_validators() {
9395
VAL_CONFIG_DIR="$VAL_HOME_DIR/config"
9496

9597
# Initialize the chain and validator files.
96-
dydxprotocold init "${MONIKERS[$i]}" -o --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
98+
$PREUPGRADE_BINARY_PATH init "${MONIKERS[$i]}" -o --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
9799

98100
# Overwrite the randomly generated `priv_validator_key.json` with a key generated deterministically from the mnemonic.
99-
dydxprotocold tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
101+
$PREUPGRADE_BINARY_PATH tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
100102

101103
# Note: `dydxprotocold init` non-deterministically creates `node_id.json` for each validator.
102104
# This is inconvenient for persistent peering during testing in Terraform configuration as the `node_id`
@@ -117,16 +119,16 @@ create_validators() {
117119
update_genesis_use_test_volatile_market "$VAL_CONFIG_DIR"
118120
update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "30"
119121

120-
echo "${MNEMONICS[$i]}" | dydxprotocold keys add "${MONIKERS[$i]}" --recover --keyring-backend=test --home "$VAL_HOME_DIR"
122+
echo "${MNEMONICS[$i]}" | $PREUPGRADE_BINARY_PATH keys add "${MONIKERS[$i]}" --recover --keyring-backend=test --home "$VAL_HOME_DIR"
121123

122124
for acct in "${TEST_ACCOUNTS[@]}"; do
123-
dydxprotocold add-genesis-account "$acct" 100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
125+
$PREUPGRADE_BINARY_PATH add-genesis-account "$acct" 100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
124126
done
125127
for acct in "${FAUCET_ACCOUNTS[@]}"; do
126-
dydxprotocold add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
128+
$PREUPGRADE_BINARY_PATH add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
127129
done
128130

129-
dydxprotocold gentx "${MONIKERS[$i]}" $TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNT$NATIVE_TOKEN --moniker="${MONIKERS[$i]}" --keyring-backend=test --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
131+
$PREUPGRADE_BINARY_PATH gentx "${MONIKERS[$i]}" $TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNT$NATIVE_TOKEN --moniker="${MONIKERS[$i]}" --keyring-backend=test --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
130132

131133
# Copy the gentx to a shared directory.
132134
cp -a "$VAL_CONFIG_DIR/gentx/." /tmp/gentx
@@ -157,13 +159,26 @@ create_validators() {
157159
done
158160
}
159161

162+
163+
setup_preupgrade_binary() {
164+
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv9.3.0/dydxprotocold-v9.3.0-linux-amd64.tar.gz'
165+
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
166+
mkdir -p /tmp/dydxprotocold
167+
curl -vL $tar_url -o $tar_path
168+
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
169+
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
170+
}
171+
172+
160173
setup_cosmovisor() {
161174
for i in "${!MONIKERS[@]}"; do
162175
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}"
163176
export DAEMON_NAME=dydxprotocold
164177
export DAEMON_HOME="$HOME/chain/.${MONIKERS[$i]}"
165178

166-
cosmovisor init /bin/dydxprotocold
179+
cosmovisor init $PREUPGRADE_BINARY_PATH
180+
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v9.4/bin/"
181+
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v9.4/bin/dydxprotocold"
167182
done
168183
}
169184

@@ -193,5 +208,6 @@ edit_config() {
193208
}
194209

195210
install_prerequisites
211+
setup_preupgrade_binary
196212
create_validators
197213
setup_cosmovisor

protocol/testing/testnet-staging/staging.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ VAULT_NUMBERS=(
151151
4 # CRV clob pair ID
152152
)
153153

154+
PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"
155+
154156
# Define dependencies for this script.
155157
# `jq` and `dasel` are used to manipulate json and yaml files respectively.
156158
install_prerequisites() {
@@ -164,7 +166,7 @@ create_validators() {
164166
for i in "${!FULL_NODE_KEYS[@]}"; do
165167
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
166168
FULL_NODE_CONFIG_DIR="$FULL_NODE_HOME_DIR/config"
167-
dydxprotocold init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"
169+
$PREUPGRADE_BINARY_PATH init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"
168170

169171
# Note: `dydxprotocold init` non-deterministically creates `node_id.json` for each validator.
170172
# This is inconvenient for persistent peering during testing in Terraform configuration as the `node_id`
@@ -186,10 +188,10 @@ create_validators() {
186188
VAL_CONFIG_DIR="$VAL_HOME_DIR/config"
187189

188190
# Initialize the chain and validator files.
189-
dydxprotocold init "${MONIKERS[$i]}" -o --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
191+
$PREUPGRADE_BINARY_PATH init "${MONIKERS[$i]}" -o --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
190192

191193
# Overwrite the randomly generated `priv_validator_key.json` with a key generated deterministically from the mnemonic.
192-
dydxprotocold tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
194+
$PREUPGRADE_BINARY_PATH tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
193195

194196
# Note: `dydxprotocold init` non-deterministically creates `node_id.json` for each validator.
195197
# This is inconvenient for persistent peering during testing in Terraform configuration as the `node_id`
@@ -201,7 +203,7 @@ create_validators() {
201203

202204
edit_config "$VAL_CONFIG_DIR"
203205

204-
echo "${MNEMONICS[$i]}" | dydxprotocold keys add "${MONIKERS[$i]}" --recover --keyring-backend=test --home "$VAL_HOME_DIR"
206+
echo "${MNEMONICS[$i]}" | $PREUPGRADE_BINARY_PATH keys add "${MONIKERS[$i]}" --recover --keyring-backend=test --home "$VAL_HOME_DIR"
205207

206208
# Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..."
207209
# Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..."
@@ -211,13 +213,13 @@ create_validators() {
211213
update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "600"
212214

213215
for acct in "${TEST_ACCOUNTS[@]}"; do
214-
dydxprotocold add-genesis-account "$acct" 100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
216+
$PREUPGRADE_BINARY_PATH add-genesis-account "$acct" 100000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
215217
done
216218
for acct in "${FAUCET_ACCOUNTS[@]}"; do
217-
dydxprotocold add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
219+
$PREUPGRADE_BINARY_PATH add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
218220
done
219221

220-
dydxprotocold gentx "${MONIKERS[$i]}" $TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNT$NATIVE_TOKEN --moniker="${MONIKERS[$i]}" --keyring-backend=test --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
222+
$PREUPGRADE_BINARY_PATH gentx "${MONIKERS[$i]}" $TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNT$NATIVE_TOKEN --moniker="${MONIKERS[$i]}" --keyring-backend=test --chain-id=$CHAIN_ID --home "$VAL_HOME_DIR"
221223

222224
# Copy the gentx to a shared directory.
223225
cp -a "$VAL_CONFIG_DIR/gentx/." /tmp/gentx
@@ -232,7 +234,7 @@ create_validators() {
232234
cp -r /tmp/gentx "$FIRST_VAL_CONFIG_DIR"
233235

234236
# Build the final genesis.json file that all validators and the full-nodes will use.
235-
dydxprotocold collect-gentxs --home "$FIRST_VAL_HOME_DIR"
237+
$PREUPGRADE_BINARY_PATH collect-gentxs --home "$FIRST_VAL_HOME_DIR"
236238

237239
# Copy this genesis file to each of the other validators
238240
for i in "${!MONIKERS[@]}"; do
@@ -256,6 +258,15 @@ create_validators() {
256258
done
257259
}
258260

261+
setup_preupgrade_binary() {
262+
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv9.3.0/dydxprotocold-v9.3.0-linux-amd64.tar.gz'
263+
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
264+
mkdir -p /tmp/dydxprotocold
265+
curl -vL $tar_url -o $tar_path
266+
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
267+
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
268+
}
269+
259270
setup_cosmovisor() {
260271
for i in "${!FULL_NODE_KEYS[@]}"; do
261272
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
@@ -270,7 +281,9 @@ setup_cosmovisor() {
270281
export DAEMON_NAME=dydxprotocold
271282
export DAEMON_HOME="$HOME/chain/.${MONIKERS[$i]}"
272283

273-
cosmovisor init /bin/dydxprotocold
284+
cosmovisor init $PREUPGRADE_BINARY_PATH
285+
mkdir -p "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v9.4/bin/"
286+
ln -s /bin/dydxprotocold "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v9.4/bin/dydxprotocold"
274287
done
275288
}
276289

@@ -289,5 +302,6 @@ edit_config() {
289302
}
290303

291304
install_prerequisites
305+
setup_preupgrade_binary
292306
create_validators
293307
setup_cosmovisor

0 commit comments

Comments
 (0)