-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build testnet validator images #2049
Conversation
WalkthroughThis update introduces a comprehensive setup for testing the DYDX protocol on a testnet. Key changes include a new GitHub Actions workflow for automated Docker image builds and deployments, along with several scripts for managing blockchain nodes. These scripts enhance the efficiency of initializing, operating, and snapshotting nodes, streamlining the testing process in a cloud environment. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant GitHub Actions
participant AWS ECR
participant Docker
participant Testnet Scripts
User->>GitHub Actions: Trigger workflow on push or PR
GitHub Actions->>Docker: Build Docker image
Docker->>GitHub Actions: Image built successfully
GitHub Actions->>AWS ECR: Push Docker image
AWS ECR->>GitHub Actions: Image pushed
GitHub Actions->>Testnet Scripts: Execute setup scripts
Testnet Scripts->>User: Testnet environment ready
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
3a621cd
to
a1cec37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- .github/workflows/protocol-build-and-push-testnet.yml (1 hunks)
- protocol/testing/testnet/Dockerfile (1 hunks)
- protocol/testing/testnet/snapshot.sh (1 hunks)
- protocol/testing/testnet/start.sh (1 hunks)
- protocol/testing/testnet/testnet.sh (1 hunks)
- protocol/testing/testnet/vars.sh (1 hunks)
Additional context used
Shellcheck
protocol/testing/testnet/vars.sh
[warning] 4-4: CURRENT_VERSION_DIR appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 7-7: LAST_FULL_NODE_INDEX appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 11-11: MONIKERS appears unused. Verify use (or export if used externally).
(SC2034)
protocol/testing/testnet/snapshot.sh
[warning] 54-54: RPC_ADDRESS appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 85-85: p2p_seeds is referenced but not assigned.
(SC2154)
[warning] 85-85: dd_agent_host is referenced but not assigned.
(SC2154)
[warning] 87-87: upload_period is referenced but not assigned.
(SC2154)
[warning] 88-88: Quote this to prevent word splitting.
(SC2046)
[warning] 92-92: s3_snapshot_bucket is referenced but not assigned.
(SC2154)
[warning] 93-93: Use "${var:?}" to ensure this never expands to / .
(SC2115)
Additional comments not posted (25)
protocol/testing/testnet/Dockerfile (7)
1-1
: LGTM! Base image usage is appropriate.The base image
dydxprotocol-base
is appropriate for this context.
3-3
: LGTM! Package installations are necessary.The packages
bash
,jq
, andaws-cli
are necessary for the script operations.
4-4
: LGTM!cosmovisor
installation command is correct.The command
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0
is correct for installingcosmovisor
.
6-6
: LGTM! Copy command is correct and necessary.The command
COPY ./testing/testnet/. /dydxprotocol/
is correct for copying necessary files.
8-9
: LGTM! Environment variable and working directory setup are correct.The environment variable
HOME
and working directory$HOME
are set correctly.
11-11
: LGTM! Script execution is necessary.The command
RUN /dydxprotocol/testnet.sh
is necessary for setting up the testnet.
13-13
: LGTM! Entry point setup is correct.The entry point
ENTRYPOINT ["/dydxprotocol/start.sh"]
is correctly set.protocol/testing/testnet/vars.sh (4)
1-2
: LGTM! Shebang and error handling setup are correct.The shebang
#!/bin/bash
andset -eo pipefail
are correctly set.
4-4
: Verify the usage ofCURRENT_VERSION_DIR
.The variable
CURRENT_VERSION_DIR
is defined but not used in this file. Verify its usage in the codebase.Verification successful
The variable
CURRENT_VERSION_DIR
is used in the codebase.The variable
CURRENT_VERSION_DIR
defined inprotocol/testing/testnet/vars.sh
is utilized in the following files:
protocol/testing/testnet/testnet.sh
protocol/testing/mainnet/mainnet.sh
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `CURRENT_VERSION_DIR` in the codebase. # Test: Search for the variable usage. Expect: Occurrences of `CURRENT_VERSION_DIR`. rg --type shell -A 5 $'CURRENT_VERSION_DIR'Length of output: 72
Script:
#!/bin/bash # Description: Verify the usage of `CURRENT_VERSION_DIR` in the codebase. # Test: Search for the variable usage. Expect: Occurrences of `CURRENT_VERSION_DIR`. rg -A 5 $'CURRENT_VERSION_DIR'Length of output: 1528
Tools
Shellcheck
[warning] 4-4: CURRENT_VERSION_DIR appears unused. Verify use (or export if used externally).
(SC2034)
7-7
: Verify the usage ofLAST_FULL_NODE_INDEX
.The variable
LAST_FULL_NODE_INDEX
is defined but not used in this file. Verify its usage in the codebase.Verification successful
Verified usage of
LAST_FULL_NODE_INDEX
.The variable
LAST_FULL_NODE_INDEX
is used in multiple shell scripts within the codebase, confirming its necessity.
protocol/testing/testnet/testnet.sh
protocol/testing/testnet/start.sh
protocol/testing/testnet/vars.sh
protocol/testing/mainnet/start.sh
protocol/testing/mainnet/vars.sh
protocol/testing/testnet/snapshot.sh
protocol/testing/mainnet/mainnet.sh
protocol/testing/mainnet/snapshot.sh
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `LAST_FULL_NODE_INDEX` in the codebase. # Test: Search for the variable usage. Expect: Occurrences of `LAST_FULL_NODE_INDEX`. rg --type shell -A 5 $'LAST_FULL_NODE_INDEX'Length of output: 73
Script:
#!/bin/bash # Description: Verify the usage of `LAST_FULL_NODE_INDEX` in the codebase. # Test: Search for the variable usage in all shell script files. Expect: Occurrences of `LAST_FULL_NODE_INDEX`. rg 'LAST_FULL_NODE_INDEX' --glob '*.sh' -A 5Length of output: 4713
Tools
Shellcheck
[warning] 7-7: LAST_FULL_NODE_INDEX appears unused. Verify use (or export if used externally).
(SC2034)
11-14
: Verify the usage ofMONIKERS
.The array
MONIKERS
is defined but not used in this file. Verify its usage in the codebase.Verification successful
The
MONIKERS
array is correctly defined and used extensively across multiple scripts in the codebase.
protocol/testing/testnet/testnet.sh
protocol/testing/testnet/start.sh
protocol/testing/testnet-staging/staging.sh
protocol/testing/testnet-local/local.sh
protocol/testing/testnet-external/pregenesis.sh
protocol/testing/testnet-dev/dev.sh
protocol/testing/e2etest-local/local.sh
protocol/testing/containertest/containertest.sh
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `MONIKERS` in the codebase. # Test: Search for the array usage. Expect: Occurrences of `MONIKERS`. rg --type shell -A 5 $'MONIKERS'Length of output: 61
Script:
#!/bin/bash # Description: Verify the usage of `MONIKERS` in the codebase. # Test: Search for the array usage. Expect: Occurrences of `MONIKERS`. rg MONIKERSLength of output: 7931
Tools
Shellcheck
[warning] 11-11: MONIKERS appears unused. Verify use (or export if used externally).
(SC2034)
protocol/testing/testnet/start.sh (6)
1-2
: LGTM! Shebang and error handling setup are correct.The shebang
#!/bin/bash
andset -eo pipefail
are correctly set.
4-7
: LGTM! Comments are clear and accurate.The comments explaining the script's purpose and usage are clear and accurate.
9-9
: LGTM! Source command is correct and necessary.The command
source "./vars.sh"
is correct for sourcing the necessary variables.
11-17
: LGTM!CosmosVisor
setup for validators is correct.The commands for setting up
CosmosVisor
for validators are correct and necessary.
19-25
: LGTM!CosmosVisor
setup for full-nodes is correct.The commands for setting up
CosmosVisor
for full-nodes are correct and necessary.
27-27
: LGTM! Command execution is correct and necessary.The command
cosmovisor "$@"
is correct for runningcosmovisor
with the provided arguments..github/workflows/protocol-build-and-push-testnet.yml (4)
1-11
: Workflow name and trigger conditions look good.The workflow name is clear and the branch patterns are correctly defined to match release branches.
13-19
: Job definition and environment setup look good.The job is appropriately defined to run on
ubuntu-latest
with the correct working directory.
20-30
: Steps for checking out the code and configuring AWS credentials look good.The steps are correctly defined and use the appropriate actions.
32-49
: Steps for logging into Amazon ECR and handling the Docker image look good.The steps are correctly defined and use the appropriate actions and commands.
protocol/testing/testnet/snapshot.sh (2)
1-23
: Script header and usage information look good.The script header and usage information are clear and informative.
25-46
: Verify the presence of thevars.sh
file.The script assumes the presence of the
vars.sh
file in the same directory. Ensure that this file exists and is correctly configured.protocol/testing/testnet/testnet.sh (2)
1-19
: Script header and prerequisites installation look good.The script header and prerequisites installation are clear and correctly defined.
124-131
: Function for configuring seed nodes looks good.The function is correctly defined to enable seed mode for a seed node.
# local path to temporary snapshots. snapshots are deleted after uploading to S3. | ||
SNAP_PATH="/dydxprotocol/chain/.full-node-0/snapshots/dydxprotocol/" | ||
# logfile containing snapshot timestamps | ||
LOG_PATH="/dydxprotocol/chain/.full-node-0/snapshots/dydxprotocol/dydxprotocol_log.txt" | ||
# data directory to snapshot. this contains the blockchain state. | ||
DATA_PATH="/dydxprotocol/chain/.full-node-0/data/" | ||
RPC_ADDRESS="http://127.0.0.1:26657" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused RPC_ADDRESS
variable.
The RPC_ADDRESS
variable is declared but not used in the script.
- RPC_ADDRESS="http://127.0.0.1:26657"
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# local path to temporary snapshots. snapshots are deleted after uploading to S3. | |
SNAP_PATH="/dydxprotocol/chain/.full-node-0/snapshots/dydxprotocol/" | |
# logfile containing snapshot timestamps | |
LOG_PATH="/dydxprotocol/chain/.full-node-0/snapshots/dydxprotocol/dydxprotocol_log.txt" | |
# data directory to snapshot. this contains the blockchain state. | |
DATA_PATH="/dydxprotocol/chain/.full-node-0/data/" | |
RPC_ADDRESS="http://127.0.0.1:26657" | |
# local path to temporary snapshots. snapshots are deleted after uploading to S3. | |
SNAP_PATH="/dydxprotocol/chain/.full-node-0/snapshots/dydxprotocol/" | |
# logfile containing snapshot timestamps | |
LOG_PATH="/dydxprotocol/chain/.full-node-0/snapshots/dydxprotocol/dydxprotocol_log.txt" | |
# data directory to snapshot. this contains the blockchain state. | |
DATA_PATH="/dydxprotocol/chain/.full-node-0/data/" |
Tools
Shellcheck
[warning] 54-54: RPC_ADDRESS appears unused. Verify use (or export if used externally).
(SC2034)
while [ $# -gt 0 ]; do | ||
|
||
if [[ $1 == *"--"* ]]; then | ||
v="${1/--/}" | ||
export $v="$2" | ||
fi | ||
|
||
shift | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add validation for required arguments.
The script does not handle cases where required arguments are missing. Add validation to ensure that all required arguments are provided.
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
v="${1/--/}"
export $v="$2"
fi
shift
done
# Validate required arguments
if [ -z "$genesis_file_rpc_address" ] || [ -z "$p2p_seeds" ] || [ -z "$upload_period" ] || [ -z "$s3_snapshot_bucket" ]; then
echo "Error: Missing required arguments."
display_usage
exit 1
fi
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
while [ $# -gt 0 ]; do | |
if [[ $1 == *"--"* ]]; then | |
v="${1/--/}" | |
export $v="$2" | |
fi | |
shift | |
done | |
while [ $# -gt 0 ]; do | |
if [[ $1 == *"--"* ]]; then | |
v="${1/--/}" | |
export $v="$2" | |
fi | |
shift | |
done | |
# Validate required arguments | |
if [ -z "$genesis_file_rpc_address" ] || [ -z "$p2p_seeds" ] || [ -z "$upload_period" ] || [ -z "$s3_snapshot_bucket" ]; then | |
echo "Error: Missing required arguments." | |
display_usage | |
exit 1 | |
fi |
# TODO: add metrics around snapshot upload latency/frequency/success rate | ||
while true; do | ||
# p2p.seeds taken from --p2p.persistent_peers flag of full node | ||
cosmovisor run start --log_level info --home /dydxprotocol/chain/.full-node-0 --p2p.seeds "${p2p_seeds}" --non-validating-full-node=true --dd-agent-host=${dd_agent_host} & | ||
|
||
sleep ${upload_period} | ||
kill -TERM $(pidof cosmovisor) | ||
|
||
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz") | ||
tar cvzf ${SNAP_PATH}/${SNAP_NAME} ${DATA_PATH} | ||
aws s3 cp ${SNAP_PATH}/${SNAP_NAME} s3://${s3_snapshot_bucket}/ --region ap-northeast-1 --debug || true | ||
rm -rf ${SNAP_PATH}/${SNAP_NAME} | ||
|
||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix unassigned variables and improve command safety.
The cosmovisor
command uses unassigned variables, the kill
command should quote the process ID to prevent word splitting, and the rm
command should ensure it never expands to /
.
- cosmovisor run start --log_level info --home /dydxprotocol/chain/.full-node-0 --p2p.seeds "${p2p_seeds}" --non-validating-full-node=true --dd-agent-host=${dd_agent_host} &
+ cosmovisor run start --log_level info --home /dydxprotocol/chain/.full-node-0 --p2p.seeds "${p2p_seeds:?}" --non-validating-full-node=true --dd-agent-host=${dd_agent_host:?} &
sleep ${upload_period}
- kill -TERM $(pidof cosmovisor)
+ kill -TERM "$(pidof cosmovisor)"
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz")
tar cvzf ${SNAP_PATH}/${SNAP_NAME} ${DATA_PATH}
- aws s3 cp ${SNAP_PATH}/${SNAP_NAME} s3://${s3_snapshot_bucket}/ --region ap-northeast-1 --debug || true
- rm -rf ${SNAP_PATH}/${SNAP_NAME}
+ aws s3 cp ${SNAP_PATH}/${SNAP_NAME:?} s3://${s3_snapshot_bucket:?}/ --region ap-northeast-1 --debug || true
+ rm -rf ${SNAP_PATH:?}/${SNAP_NAME:?}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# TODO: add metrics around snapshot upload latency/frequency/success rate | |
while true; do | |
# p2p.seeds taken from --p2p.persistent_peers flag of full node | |
cosmovisor run start --log_level info --home /dydxprotocol/chain/.full-node-0 --p2p.seeds "${p2p_seeds}" --non-validating-full-node=true --dd-agent-host=${dd_agent_host} & | |
sleep ${upload_period} | |
kill -TERM $(pidof cosmovisor) | |
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz") | |
tar cvzf ${SNAP_PATH}/${SNAP_NAME} ${DATA_PATH} | |
aws s3 cp ${SNAP_PATH}/${SNAP_NAME} s3://${s3_snapshot_bucket}/ --region ap-northeast-1 --debug || true | |
rm -rf ${SNAP_PATH}/${SNAP_NAME} | |
done | |
# TODO: add metrics around snapshot upload latency/frequency/success rate | |
while true; do | |
# p2p.seeds taken from --p2p.persistent_peers flag of full node | |
cosmovisor run start --log_level info --home /dydxprotocol/chain/.full-node-0 --p2p.seeds "${p2p_seeds:?}" --non-validating-full-node=true --dd-agent-host=${dd_agent_host:?} & | |
sleep ${upload_period} | |
kill -TERM "$(pidof cosmovisor)" | |
SNAP_NAME=$(echo "${CHAIN_ID}_$(date '+%Y-%m-%d-%H-%M').tar.gz") | |
tar cvzf ${SNAP_PATH}/${SNAP_NAME} ${DATA_PATH} | |
aws s3 cp ${SNAP_PATH}/${SNAP_NAME:?} s3://${s3_snapshot_bucket:?}/ --region ap-northeast-1 --debug || true | |
rm -rf ${SNAP_PATH:?}/${SNAP_NAME:?} | |
done |
Tools
Shellcheck
[warning] 85-85: p2p_seeds is referenced but not assigned.
(SC2154)
[warning] 85-85: dd_agent_host is referenced but not assigned.
(SC2154)
[warning] 87-87: upload_period is referenced but not assigned.
(SC2154)
[warning] 88-88: Quote this to prevent word splitting.
(SC2046)
[warning] 92-92: s3_snapshot_bucket is referenced but not assigned.
(SC2154)
[warning] 93-93: Use "${var:?}" to ensure this never expands to / .
(SC2115)
create_validators() { | ||
# Create directories for full-nodes to use. | ||
for i in $(seq 0 $LAST_FULL_NODE_INDEX); 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" | ||
|
||
if [[ "$i" == 0 ]]; then | ||
# First full-node config is for the Indexer, don't enable seed mode. | ||
continue | ||
fi | ||
|
||
# All other full-nodes should be seed nodes. | ||
configure_seed "$FULL_NODE_CONFIG_DIR" | ||
done | ||
|
||
# Iterate over all validators and set up their home directories. | ||
for i in "${!MONIKERS[@]}"; do | ||
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}" | ||
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" | ||
done | ||
|
||
# Copy this genesis file to each of the other validators | ||
for i in "${!MONIKERS[@]}"; do | ||
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}" | ||
VAL_CONFIG_DIR="$VAL_HOME_DIR/config" | ||
rm -rf "$VAL_CONFIG_DIR/genesis.json" | ||
cp "$HOME/genesis.json" "$VAL_CONFIG_DIR/genesis.json" | ||
done | ||
|
||
# Set up CosmosVisor. | ||
for i in "${!MONIKERS[@]}"; do | ||
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}" | ||
# DAEMON_NAME is the name of the binary. | ||
export DAEMON_NAME=dydxprotocold | ||
|
||
# DAEMON_HOME is the location where the cosmovisor/ directory is kept | ||
# that contains the genesis binary, the upgrade binaries, and any additional | ||
# auxiliary files associated with each binary | ||
export DAEMON_HOME="$HOME/chain/.${MONIKERS[$i]}" | ||
|
||
# Create the folder structure required for using cosmovisor. | ||
cosmovisor init /bin/dydxprotocold | ||
|
||
cp -r "$HOME/cosmovisor" "$VAL_HOME_DIR/" | ||
done | ||
|
||
# Copy the genesis file to the full-node directories. | ||
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" | ||
|
||
cp "$HOME/genesis.json" "$FULL_NODE_CONFIG_DIR/genesis.json" | ||
done | ||
|
||
# Set up CosmosVisor for full-nodes. | ||
for i in "${!FULL_NODE_KEYS[@]}"; do | ||
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i" | ||
# DAEMON_NAME is the name of the binary. | ||
export DAEMON_NAME=dydxprotocold | ||
|
||
# DAEMON_HOME is the location where the cosmovisor/ directory is kept | ||
# that contains the genesis binary, the upgrade binaries, and any additional | ||
# auxiliary files associated with each binary | ||
export DAEMON_HOME="$HOME/chain/.full-node-$i" | ||
|
||
# Create the folder structure required for using cosmovisor. | ||
cosmovisor init /bin/dydxprotocold | ||
|
||
cp -r "$HOME/cosmovisor" "$FULL_NODE_HOME_DIR/" | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify the presence of required environment variables and directories.
The function assumes the presence of certain environment variables and directories. Add checks to verify their presence before proceeding.
create_validators() {
# Create directories for full-nodes to use.
for i in $(seq 0 $LAST_FULL_NODE_INDEX); 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"
if [[ "$i" == 0 ]]; then
# First full-node config is for the Indexer, don't enable seed mode.
continue
fi
# All other full-nodes should be seed nodes.
configure_seed "$FULL_NODE_CONFIG_DIR"
done
# Iterate over all validators and set up their home directories.
for i in "${!MONIKERS[@]}"; do
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}"
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"
done
# Copy this genesis file to each of the other validators
for i in "${!MONIKERS[@]}"; do
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}"
VAL_CONFIG_DIR="$VAL_HOME_DIR/config"
rm -rf "$VAL_CONFIG_DIR/genesis.json"
cp "$HOME/genesis.json" "$VAL_CONFIG_DIR/genesis.json"
done
# Set up CosmosVisor.
for i in "${!MONIKERS[@]}"; do
VAL_HOME_DIR="$HOME/chain/.${MONIKERS[$i]}"
# DAEMON_NAME is the name of the binary.
export DAEMON_NAME=dydxprotocold
# DAEMON_HOME is the location where the cosmovisor/ directory is kept
# that contains the genesis binary, the upgrade binaries, and any additional
# auxiliary files associated with each binary
export DAEMON_HOME="$HOME/chain/.${MONIKERS[$i]}"
# Create the folder structure required for using cosmovisor.
cosmovisor init /bin/dydxprotocold
cp -r "$HOME/cosmovisor" "$VAL_HOME_DIR/"
done
# Copy the genesis file to the full-node directories.
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"
cp "$HOME/genesis.json" "$FULL_NODE_CONFIG_DIR/genesis.json"
done
# Set up CosmosVisor for full-nodes.
for i in "${!FULL_NODE_KEYS[@]}"; do
FULL_NODE_HOME_DIR="$HOME/chain/.full-node-$i"
# DAEMON_NAME is the name of the binary.
export DAEMON_NAME=dydxprotocold
# DAEMON_HOME is the location where the cosmovisor/ directory is kept
# that contains the genesis binary, the upgrade binaries, and any additional
# auxiliary files associated with each binary
export DAEMON_HOME="$HOME/chain/.full-node-$i"
# Create the folder structure required for using cosmovisor.
cosmovisor init /bin/dydxprotocold
cp -r "$HOME/cosmovisor" "$FULL_NODE_HOME_DIR/"
done
}
Committable suggestion was skipped due to low confidence.
set_cosmovisor_binary_permissions() { | ||
# The genesis binary should always exist. | ||
for f in $HOME/cosmovisor/genesis/bin/* ; do | ||
chmod 755 $f | ||
done | ||
# Set up upgrade binaries. | ||
for version in "${!version_to_url[@]}"; do | ||
echo "Setting up version ${version}..." | ||
version_dir="$HOME/cosmovisor/upgrades/$version" | ||
mkdir -p "$version_dir/bin" | ||
url=${version_to_url[$version]} | ||
tar_file=$(basename $url) | ||
|
||
echo "Downloading tar file from ${url}..." | ||
wget -O $tar_file $url | ||
tar -xzf $tar_file -C "$version_dir" | ||
rm $tar_file | ||
binary_file="${tar_file%.tar.gz}" | ||
mv "$version_dir/build/$binary_file" "$version_dir/bin/dydxprotocold" | ||
chmod 755 "$version_dir/bin/dydxprotocold" | ||
echo "Successfully set up $version_dir/bin/dydxprotocold" | ||
done | ||
current_version_path="$HOME/cosmovisor/upgrades/$CURRENT_VERSION_DIR/bin" | ||
mkdir -p $current_version_path | ||
cp /bin/dydxprotocold $current_version_path | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify the presence of binaries before setting permissions.
The function assumes the presence of binaries in specific directories. Add checks to verify the presence of the binaries before setting permissions.
set_cosmovisor_binary_permissions() {
# The genesis binary should always exist.
for f in $HOME/cosmovisor/genesis/bin/* ; do
if [ -f "$f" ]; then
chmod 755 $f
else
echo "Warning: Genesis binary $f not found."
fi
done
# Set up upgrade binaries.
for version in "${!version_to_url[@]}"; do
echo "Setting up version ${version}..."
version_dir="$HOME/cosmovisor/upgrades/$version"
mkdir -p "$version_dir/bin"
url=${version_to_url[$version]}
tar_file=$(basename $url)
echo "Downloading tar file from ${url}..."
wget -O $tar_file $url
tar -xzf $tar_file -C "$version_dir"
rm $tar_file
binary_file="${tar_file%.tar.gz}"
if [ -f "$version_dir/build/$binary_file" ]; then
mv "$version_dir/build/$binary_file" "$version_dir/bin/dydxprotocold"
chmod 755 "$version_dir/bin/dydxprotocold"
echo "Successfully set up $version_dir/bin/dydxprotocold"
else
echo "Warning: Upgrade binary $version_dir/build/$binary_file not found."
fi
done
current_version_path="$HOME/cosmovisor/upgrades/$CURRENT_VERSION_DIR/bin"
mkdir -p $current_version_path
cp /bin/dydxprotocold $current_version_path
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
set_cosmovisor_binary_permissions() { | |
# The genesis binary should always exist. | |
for f in $HOME/cosmovisor/genesis/bin/* ; do | |
chmod 755 $f | |
done | |
# Set up upgrade binaries. | |
for version in "${!version_to_url[@]}"; do | |
echo "Setting up version ${version}..." | |
version_dir="$HOME/cosmovisor/upgrades/$version" | |
mkdir -p "$version_dir/bin" | |
url=${version_to_url[$version]} | |
tar_file=$(basename $url) | |
echo "Downloading tar file from ${url}..." | |
wget -O $tar_file $url | |
tar -xzf $tar_file -C "$version_dir" | |
rm $tar_file | |
binary_file="${tar_file%.tar.gz}" | |
mv "$version_dir/build/$binary_file" "$version_dir/bin/dydxprotocold" | |
chmod 755 "$version_dir/bin/dydxprotocold" | |
echo "Successfully set up $version_dir/bin/dydxprotocold" | |
done | |
current_version_path="$HOME/cosmovisor/upgrades/$CURRENT_VERSION_DIR/bin" | |
mkdir -p $current_version_path | |
cp /bin/dydxprotocold $current_version_path | |
} | |
set_cosmovisor_binary_permissions() { | |
# The genesis binary should always exist. | |
for f in $HOME/cosmovisor/genesis/bin/* ; do | |
if [ -f "$f" ]; then | |
chmod 755 $f | |
else | |
echo "Warning: Genesis binary $f not found." | |
fi | |
done | |
# Set up upgrade binaries. | |
for version in "${!version_to_url[@]}"; do | |
echo "Setting up version ${version}..." | |
version_dir="$HOME/cosmovisor/upgrades/$version" | |
mkdir -p "$version_dir/bin" | |
url=${version_to_url[$version]} | |
tar_file=$(basename $url) | |
echo "Downloading tar file from ${url}..." | |
wget -O $tar_file $url | |
tar -xzf $tar_file -C "$version_dir" | |
rm $tar_file | |
binary_file="${tar_file%.tar.gz}" | |
if [ -f "$version_dir/build/$binary_file" ]; then | |
mv "$version_dir/build/$binary_file" "$version_dir/bin/dydxprotocold" | |
chmod 755 "$version_dir/bin/dydxprotocold" | |
echo "Successfully set up $version_dir/bin/dydxprotocold" | |
else | |
echo "Warning: Upgrade binary $version_dir/build/$binary_file not found." | |
fi | |
done | |
current_version_path="$HOME/cosmovisor/upgrades/$CURRENT_VERSION_DIR/bin" | |
mkdir -p $current_version_path | |
cp /bin/dydxprotocold $current_version_path | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which version is this for my understanding? v5.2.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
genesis (v1.0.0)
|
||
# Define the mapping from version to URL | ||
declare -A version_to_url | ||
version_to_url["v5.1.0"]="https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2Fv5.1.1/dydxprotocold-v5.1.1-linux-amd64.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add v5.2.0
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should specify previous version. This is getting backported to v5.2.0 branch first though. Will follow up with a PR to set everything for v6.0.0
done | ||
|
||
# Set up CosmosVisor for full-nodes. | ||
for i in $(seq 0 $LAST_FULL_NODE_INDEX); do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this 0 through 2? I thought there are only 2 full nodes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No harm in initializing more home directories
@Mergifyio backport release/protocol/v5.2.x |
✅ Backports have been created
|
(cherry picked from commit 84eed16)
https://github.com/Mergifyio backport release/protocol/v6.x |
✅ Backports have been created
|
(cherry picked from commit 84eed16)
Changelist
Build testnet validator images on push and PR to release branches. Makes testnet deploys easier.
Test Plan
Built and tried image on on release branch.
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
Bug Fixes
Documentation