Skip to content

Commit

Permalink
[DO NOT MERGE] v6.0.4 -> v7.0 upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfraser committed Oct 15, 2024
1 parent 6433458 commit fa7c579
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 104 deletions.
1 change: 1 addition & 0 deletions .github/workflows/protocol-build-and-push-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy
- main
- 'release/protocol/v[0-9]+.[0-9]+.x' # e.g. release/protocol/v0.1.x
- 'release/protocol/v[0-9]+.x' # e.g. release/protocol/v1.x
- 'adam/upgrade_test_v7'

jobs:
build-and-push-snapshot-dev:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/protocol-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy
- main
- 'release/protocol/v[0-9]+.[0-9]+.x' # e.g. release/protocol/v0.1.x
- 'release/protocol/v[0-9]+.x' # e.g. release/protocol/v1.x
- 'adam/upgrade_test_v7'

jobs:
build-and-push-dev:
Expand Down
142 changes: 57 additions & 85 deletions protocol/testing/genesis.sh

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions protocol/testing/snapshotting/snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ now_date() {
echo -n $(TZ="UTC" date '+%Y-%m-%d_%H:%M:%S')
}

PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"

install_prerequisites() {
apk add dasel jq curl
apk add --no-cache \
Expand All @@ -62,12 +64,23 @@ install_prerequisites() {
&& rm -rf /var/cache/apk/*
}

setup_preupgrade_binary() {
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv6.0.4/dydxprotocold-v6.0.4-linux-amd64.tar.gz'
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
mkdir -p /tmp/dydxprotocold
curl -vL $tar_url -o $tar_path
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
}

setup_cosmovisor() {
VAL_HOME_DIR="$HOME/chain/local_node"
export DAEMON_NAME=dydxprotocold
export DAEMON_HOME="$HOME/chain/local_node"

cosmovisor init /bin/dydxprotocold
cosmovisor init $PREUPGRADE_BINARY_PATH
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/"
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/dydxprotocold"
}

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

setup_cosmovisor
setup_preupgrade_binary

# TODO: add metrics around snapshot upload latency/frequency/success rate
while true; do
Expand Down
30 changes: 24 additions & 6 deletions protocol/testing/testnet-dev/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ VAULT_NUMBERS=(
4 # CRV clob pair ID
)

PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"

# Define dependencies for this script.
# `jq` and `dasel` are used to manipulate json and yaml files respectively.
install_prerequisites() {
apk add dasel jq
apk add curl dasel jq
}

# Create all validators for the chain including a full-node.
Expand All @@ -110,7 +112,8 @@ create_validators() {
for i in "${!FULL_NODE_KEYS[@]}"; do
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
FULL_NODE_CONFIG_DIR="$FULL_NODE_HOME_DIR/config"
dydxprotocold init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"
$PREUPGRADE_BINARY_PATH init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"


# Note: `dydxprotocold init` non-deterministically creates `node_id.json` for each validator.
# This is inconvenient for persistent peering during testing in Terraform configuration as the `node_id`
Expand All @@ -132,7 +135,8 @@ create_validators() {
VAL_CONFIG_DIR="$VAL_HOME_DIR/config"

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


# Overwrite the randomly generated `priv_validator_key.json` with a key generated deterministically from the mnemonic.
dydxprotocold tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
Expand Down Expand Up @@ -163,7 +167,7 @@ create_validators() {
dydxprotocold add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
done

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"
$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"

# Copy the gentx to a shared directory.
cp -a "$VAL_CONFIG_DIR/gentx/." /tmp/gentx
Expand Down Expand Up @@ -202,21 +206,34 @@ create_validators() {
done
}

setup_preupgrade_binary() {
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv6.0.4/dydxprotocold-v6.0.4-linux-amd64.tar.gz'
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
mkdir -p /tmp/dydxprotocold
curl -vL $tar_url -o $tar_path
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
}

setup_cosmovisor() {
for i in "${!FULL_NODE_KEYS[@]}"; do
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
export DAEMON_NAME=dydxprotocold
export DAEMON_HOME="$HOME/chain/.full-node-$i"

cosmovisor init /bin/dydxprotocold
cosmovisor init $PREUPGRADE_BINARY_PATH
mkdir -p "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/"
ln -s /bin/dydxprotocold "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/dydxprotocold"
done

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

cosmovisor init /bin/dydxprotocold
cosmovisor init $PREUPGRADE_BINARY_PATH
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/"
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/dydxprotocold"
done
}

Expand All @@ -235,5 +252,6 @@ edit_config() {
}

install_prerequisites
setup_preupgrade_binary
create_validators
setup_cosmovisor
25 changes: 20 additions & 5 deletions protocol/testing/testnet-local/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ VAULT_NUMBERS=(
1 # ETH clob pair ID
)

PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"

# Define dependencies for this script.
# `jq` and `dasel` are used to manipulate json and yaml files respectively.
install_prerequisites() {
apk add dasel jq
apk add curl dasel jq
}

# Create all validators for the chain including a full-node.
Expand All @@ -93,7 +95,8 @@ create_validators() {
VAL_CONFIG_DIR="$VAL_HOME_DIR/config"

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


# Overwrite the randomly generated `priv_validator_key.json` with a key generated deterministically from the mnemonic.
dydxprotocold tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
Expand Down Expand Up @@ -126,7 +129,7 @@ create_validators() {
dydxprotocold add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
done

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"
$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"

# Copy the gentx to a shared directory.
cp -a "$VAL_CONFIG_DIR/gentx/." /tmp/gentx
Expand Down Expand Up @@ -157,13 +160,24 @@ create_validators() {
done
}

setup_preupgrade_binary() {
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv6.0.4/dydxprotocold-v6.0.4-linux-amd64.tar.gz'
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
mkdir -p /tmp/dydxprotocold
curl -vL $tar_url -o $tar_path
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
mv /tmp/dydxprotocold/$dydxprotocold_path $PREUPGRADE_BINARY_PATH
}

setup_cosmovisor() {
for i in "${!MONIKERS[@]}"; do
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}"
export DAEMON_NAME=dydxprotocold
export DAEMON_HOME="$HOME/chain/.${MONIKERS[$i]}"

cosmovisor init /bin/dydxprotocold
cosmovisor init $PREUPGRADE_BINARY_PATH
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/"
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/dydxprotocold"
done
}

Expand All @@ -183,7 +197,7 @@ edit_config() {
# Disable pex
dasel put -t bool -f "$CONFIG_FOLDER"/config.toml '.p2p.pex' -v 'false'

# Default `timeout_commit` is 999ms. For local testnet, use a larger value to make
# Default `timeout_commit` is 999ms. For local testnet, use a larger value to make
# block time longer for easier troubleshooting.
dasel put -t string -f "$CONFIG_FOLDER"/config.toml '.consensus.timeout_commit' -v '5s'

Expand All @@ -193,5 +207,6 @@ edit_config() {
}

install_prerequisites
setup_preupgrade_binary
create_validators
setup_cosmovisor
30 changes: 24 additions & 6 deletions protocol/testing/testnet-staging/staging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ VAULT_NUMBERS=(
4 # CRV clob pair ID
)

PREUPGRADE_BINARY_PATH="/bin/dydxprotocold_preupgrade"

# Define dependencies for this script.
# `jq` and `dasel` are used to manipulate json and yaml files respectively.
install_prerequisites() {
apk add dasel jq
apk add curl dasel jq
}

# Create all validators for the chain including a full-node.
Expand All @@ -164,7 +166,8 @@ create_validators() {
for i in "${!FULL_NODE_KEYS[@]}"; do
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
FULL_NODE_CONFIG_DIR="$FULL_NODE_HOME_DIR/config"
dydxprotocold init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"
$PREUPGRADE_BINARY_PATH init "full-node" -o --chain-id=$CHAIN_ID --home "$FULL_NODE_HOME_DIR"


# Note: `dydxprotocold init` non-deterministically creates `node_id.json` for each validator.
# This is inconvenient for persistent peering during testing in Terraform configuration as the `node_id`
Expand All @@ -186,7 +189,8 @@ create_validators() {
VAL_CONFIG_DIR="$VAL_HOME_DIR/config"

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


# Overwrite the randomly generated `priv_validator_key.json` with a key generated deterministically from the mnemonic.
dydxprotocold tendermint gen-priv-key --home "$VAL_HOME_DIR" --mnemonic "${MNEMONICS[$i]}"
Expand Down Expand Up @@ -217,7 +221,7 @@ create_validators() {
dydxprotocold add-genesis-account "$acct" 900000000000000000$USDC_DENOM,$TESTNET_VALIDATOR_NATIVE_TOKEN_BALANCE$NATIVE_TOKEN --home "$VAL_HOME_DIR"
done

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"
$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"

# Copy the gentx to a shared directory.
cp -a "$VAL_CONFIG_DIR/gentx/." /tmp/gentx
Expand Down Expand Up @@ -256,21 +260,34 @@ create_validators() {
done
}

setup_preupgrade_binary() {
tar_url='https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv6.0.4/dydxprotocold-v6.0.4-linux-amd64.tar.gz'
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz'
mkdir -p /tmp/dydxprotocold
curl -vL $tar_url -o $tar_path
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold)
mv /tmp/dydxprotocold/$dydxprotocold_path /bin/dydxprotocold_preupgrade
}

setup_cosmovisor() {
for i in "${!FULL_NODE_KEYS[@]}"; do
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
export DAEMON_NAME=dydxprotocold
export DAEMON_HOME="$HOME/chain/.full-node-$i"

cosmovisor init /bin/dydxprotocold
cosmovisor init $PREUPGRADE_BINARY_PATH
mkdir -p "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/"
ln -s /bin/dydxprotocold "$FULL_NODE_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/dydxprotocold"
done

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

cosmovisor init /bin/dydxprotocold
cosmovisor init $PREUPGRADE_BINARY_PATH
mkdir -p "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/"
ln -s /bin/dydxprotocold "$VAL_HOME_DIR/cosmovisor/upgrades/v7.0.0/bin/dydxprotocold"
done
}

Expand All @@ -289,5 +306,6 @@ edit_config() {
}

install_prerequisites
setup_preupgrade_binary
create_validators
setup_cosmovisor

0 comments on commit fa7c579

Please sign in to comment.