Skip to content

Commit 040c17f

Browse files
committed
[DO NOT MERGE] test upgrade from v9.2.1 to v9.3
1 parent df0f3a2 commit 040c17f

File tree

5 files changed

+67
-21
lines changed

5 files changed

+67
-21
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+
- 'tq/test-v9.2-to-v9.3-upgrade'
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+
- 'tq/test-v9.2-to-v9.3-upgrade'
910

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

protocol/testing/snapshotting/snapshot.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ 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"
39+
3840

3941
while [ $# -gt 0 ]; do
4042

@@ -62,12 +64,23 @@ install_prerequisites() {
6264
&& rm -rf /var/cache/apk/*
6365
}
6466

67+
setup_preupgrade_binary() {
68+
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv9.2.1/dydxprotocold-v9.2.1-linux-amd64.tar.gz'
69+
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
70+
mkdir -p /tmp/dydxprotocold
71+
curl -vL $tar_url -o $tar_path
72+
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
73+
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
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.3/bin/"
83+
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v9.3/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-local/local.sh

Lines changed: 23 additions & 9 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
@@ -141,7 +143,7 @@ create_validators() {
141143
cp -r /tmp/gentx "$FIRST_VAL_CONFIG_DIR"
142144

143145
# Build the final genesis.json file that all validators and the full-nodes will use.
144-
dydxprotocold collect-gentxs --home "$FIRST_VAL_HOME_DIR"
146+
$PREUPGRADE_BINARY_PATH collect-gentxs --home "$FIRST_VAL_HOME_DIR"
145147

146148
# Copy this genesis file to each of the other validators
147149
for i in "${!MONIKERS[@]}"; do
@@ -157,13 +159,24 @@ create_validators() {
157159
done
158160
}
159161

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

166-
cosmovisor init /bin/dydxprotocold
177+
cosmovisor init $PREUPGRADE_BINARY_PATH
178+
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v9.3/bin/"
179+
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v9.3/bin/dydxprotocold"
167180
done
168181
}
169182

@@ -193,5 +206,6 @@ edit_config() {
193206
}
194207

195208
install_prerequisites
209+
setup_preupgrade_binary
196210
create_validators
197211
setup_cosmovisor

protocol/testing/testnet-staging/staging.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,12 @@ 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() {
157-
apk add dasel jq
159+
apk add curl dasel jq
158160
}
159161

160162
# Create all validators for the chain including a full-node.
@@ -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,21 +258,34 @@ create_validators() {
256258
done
257259
}
258260

261+
setup_preupgrade_binary() {
262+
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv9.2.1/dydxprotocold-v9.2.1-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"
262273
export DAEMON_NAME=dydxprotocold
263274
export DAEMON_HOME="$HOME/chain/.full-node-$i"
264275

265-
cosmovisor init /bin/dydxprotocold
276+
cosmovisor init $PREUPGRADE_BINARY_PATH
277+
mkdir -p "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v9.3/bin/"
278+
ln -s /bin/dydxprotocold "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v9.3/bin/dydxprotocold"
266279
done
267280

268281
for i in "${!MONIKERS[@]}"; do
269282
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}"
270283
export DAEMON_NAME=dydxprotocold
271284
export DAEMON_HOME="$HOME/chain/.${MONIKERS[$i]}"
272285

273-
cosmovisor init /bin/dydxprotocold
286+
cosmovisor init $PREUPGRADE_BINARY_PATH
287+
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v9.3/bin/"
288+
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v9.3/bin/dydxprotocold"
274289
done
275290
}
276291

@@ -289,5 +304,6 @@ edit_config() {
289304
}
290305

291306
install_prerequisites
307+
setup_preupgrade_binary
292308
create_validators
293309
setup_cosmovisor

0 commit comments

Comments
 (0)