Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

fix(4node): Fix 4 node testnet #1190

Merged
merged 2 commits into from
Oct 6, 2023
Merged

fix(4node): Fix 4 node testnet #1190

merged 2 commits into from
Oct 6, 2023

Conversation

itsdevbear
Copy link
Contributor

@itsdevbear itsdevbear commented Oct 6, 2023

Summary by CodeRabbit

  • New Feature: Added support for additional containers in the network initialization scripts, allowing for more complex network configurations.
  • Refactor: Updated the HOMEDIR variable across multiple scripts to improve consistency and flexibility in specifying the home directory path.
  • New Feature: Introduced a basic reverse proxy configuration in nginx.conf, enhancing load balancing capabilities.
  • Refactor: Enhanced several scripts with default values for environment variables, improving robustness and reducing potential errors due to unset variables.
  • Chore: Added readiness and liveness probe scripts, improving container health checks.
  • Refactor: Modified the reset script to use the HOMEDIR environment variable instead of a hardcoded directory path, increasing flexibility.
  • New Feature: Extended the polard genesis gentx command with additional parameters, providing more detailed genesis transaction information.

@coderabbitai
Copy link

coderabbitai bot commented Oct 6, 2023

Walkthrough

The changes primarily focus on enhancing the flexibility and robustness of the Polard blockchain network setup scripts. The home directory path (HOMEDIR) is now configurable, with a default value of "/.polard". Additional containers are initialized and started, and an HTTP reverse proxy configuration is introduced. Liveness and readiness probes are added to monitor the health of the services.

Changes

File(s) Summary
.../network-init-2.sh, .../network-init-4.sh Introduced additional containers in the network initialization scripts and made the home directory path configurable.
.../nginx.conf Added a basic reverse proxy configuration for an HTTP server.
.../init.sh, .../seed0-init-step1.sh, .../seed0-init-step2.sh, .../seed1-init-step1.sh, .../seed1-init-step2.sh Updated the network setup scripts to provide default values for environment variables and enhanced the genesis file configuration.
.../get-seed-address.sh, .../set-seed-address.sh Made the home directory path configurable in the seed address scripts.
.../liveness-probe.sh, .../readiness-probe.sh Added liveness and readiness probes to check the health of the services.
.../reset.sh Updated the script to delete a directory based on the configurable home directory path.
.../seed-start.sh Set default values for HOMEDIR and LOGLEVEL and enabled the API in the start command.
.../set-persistent-peers.sh Introduced a new variable HOMEDIR with a default value and updated the value of CONFIG_TOML based on HOMEDIR.
.../val0-init-step1.sh, .../val0-init-step2.sh, .../val0-init-step3.sh, .../val1-init-step1.sh, .../val1-init-step2.sh Updated the home directory path in the validator initialization scripts.

"In the land of code, where logic is king,
A rabbit hopped forth, changes to bring.
With a twinkle in his eye and a skip in his hop,
He refactored the scripts from bottom to top.
Now the network's robust, flexible, and spry,
Under the watchful gaze of the AI in the sky. 🐇💻🚀"


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

@itsdevbear itsdevbear requested a review from BrickBera October 6, 2023 17:13
@itsdevbear itsdevbear merged commit 5dcdec1 into main Oct 6, 2023
7 checks passed
@itsdevbear itsdevbear deleted the fix-network-devnet branch October 6, 2023 17:13
@itsdevbear itsdevbear requested a review from calbera October 6, 2023 17:15
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 6

Commits Files that changed from the base of the PR and between a64844c and d4c3558.
Files ignored due to filter (1)
  • e2e/testapp/docker/docker-compose.yml
Files selected for processing (20)
  • e2e/testapp/docker/network-init-2.sh (2 hunks)
  • e2e/testapp/docker/network-init-4.sh (1 hunks)
  • e2e/testapp/docker/nginx.conf (1 hunks)
  • e2e/testapp/docker/seed/init.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/get-seed-address.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/liveness-probe.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/readiness-probe.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/reset.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/seed-start.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/seed0-init-step1.sh (2 hunks)
  • e2e/testapp/docker/seed/scripts/seed0-init-step2.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/seed1-init-step1.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/seed1-init-step2.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/set-persistent-peers.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/set-seed-address.sh (1 hunks)
  • e2e/testapp/docker/validator/scripts/val0-init-step1.sh (1 hunks)
  • e2e/testapp/docker/validator/scripts/val0-init-step2.sh (1 hunks)
  • e2e/testapp/docker/validator/scripts/val0-init-step3.sh (1 hunks)
  • e2e/testapp/docker/validator/scripts/val1-init-step1.sh (1 hunks)
  • e2e/testapp/docker/validator/scripts/val1-init-step2.sh (1 hunks)
Files skipped from review due to trivial changes (8)
  • e2e/testapp/docker/network-init-4.sh
  • e2e/testapp/docker/seed/scripts/liveness-probe.sh
  • e2e/testapp/docker/seed/scripts/readiness-probe.sh
  • e2e/testapp/docker/seed/scripts/seed1-init-step1.sh
  • e2e/testapp/docker/seed/scripts/seed1-init-step2.sh
  • e2e/testapp/docker/seed/scripts/set-persistent-peers.sh
  • e2e/testapp/docker/seed/scripts/set-seed-address.sh
  • e2e/testapp/docker/validator/scripts/val1-init-step1.sh
Additional comments (Suppressed): 18
e2e/testapp/docker/seed/scripts/reset.sh (1)
  • 21-23: The script now checks if the HOMEDIR environment variable is set and assigns a default value if it's not. This adds flexibility in specifying the home directory path.
e2e/testapp/docker/nginx.conf (1)
  • 1-19: The new hunk introduces an upstream block with four server addresses, effectively setting up a basic reverse proxy configuration. This is part of the expansion from 2 nodes to 4 nodes in the testnet. Ensure that the ports 8545 are correctly open and accessible on all four servers (polard-node0, polard-node1, polard-node2, polard-node3). Also, verify that the load balancing strategy suits your needs; by default, Nginx uses a round-robin algorithm.
e2e/testapp/docker/seed/scripts/seed-start.sh (3)
  • 21-23: The home directory path has been changed from "/root/.polard" to "/.polard". Ensure that this new path is accessible and has the correct permissions set for the operations performed by the polard command.

  • 24-26: The default log level remains "info". This change allows the log level to be set via an environment variable, which can provide more flexibility in debugging and monitoring.

  • 28-28: The --api.enable flag has been added to the polard start command. Verify that this flag is supported in your version of polard and that enabling the API does not introduce any security concerns.

e2e/testapp/docker/seed/scripts/get-seed-address.sh (1)
  • 21-23: The change from a hardcoded HOMEDIR to a default value is a good practice. It allows for flexibility in setting the home directory path.
- HOMEDIR="/root/.polard"
+ if [ -z "$HOMEDIR" ]; then
+     HOMEDIR="/.polard"
+ fi

Please ensure that all scripts and services that depend on this script are updated to either provide the HOMEDIR environment variable or can work with the new default value.

e2e/testapp/docker/validator/scripts/val0-init-step2.sh (1)
  • 23-23: The home directory path has been changed from "/root/.polard" to "/.polard". Ensure that this new path is accessible and has the appropriate permissions for the operations performed by the polard command.
- HOMEDIR="/root/.polard"
+ HOMEDIR="/.polard"
e2e/testapp/docker/seed/scripts/seed0-init-step2.sh (1)
  • 21-29: Good use of checking if environment variables are set and assigning default values if they are not. This adds flexibility in specifying parameters like the home directory path, keyring, and key algorithm.
e2e/testapp/docker/validator/scripts/val1-init-step2.sh (1)
  • 21-23: The HOMEDIR variable has been changed from "/root/.polard" to "/.polard". Ensure that this new path is accessible and has the appropriate permissions for the operations performed by the polard command.
e2e/testapp/docker/validator/scripts/val0-init-step3.sh (1)
  • 23-23: The home directory path has been changed from "/root/.polard" to "/.polard". Ensure that this new path is accessible and has the appropriate permissions set for the operations performed by the script.
e2e/testapp/docker/validator/scripts/val0-init-step1.sh (2)
  • 23-26: The home directory for polard has been changed from /root/.polard to /.polard. Ensure that this new path is accessible and has the appropriate permissions set. Also, verify that all scripts and services that rely on this path have been updated accordingly.

  • 28-28: The polard init command now uses the updated HOMEDIR. Make sure that the polard tool can access and write to this directory.

e2e/testapp/docker/seed/scripts/seed0-init-step1.sh (4)
  • 21-35: The script now checks if certain environment variables are set and assigns default values if they are not. This is a good practice as it provides flexibility in specifying parameters like the home directory path, log level, keyring, and key algorithm.

  • 37-38: The value of KEY1 and MONIKER1 has been changed from "seed0" to "seed-0". Ensure that this change does not affect other parts of the system that might be using these values.

  • 46-56: Several new parameters have been added to the genesis.json file. Make sure these changes align with your blockchain's governance model and requirements.

  • 59-71: The commands for setting the client configuration, adding keys, adding a genesis account, and generating a genesis transaction have been updated with additional flags and parameters. Verify that these changes are correct and necessary.

e2e/testapp/docker/network-init-2.sh (2)
  • 20-44: The script has been updated to include two additional containers (CONTAINER2 and CONTAINER3). The home directory path (HOMEDIR) has been changed from "/root/.polard" to "/.polard". This change should be verified across all scripts and configurations to ensure consistency and avoid potential issues. The initialization step 1 now includes the new containers.

  • 47-93: The script now copies the genesis.json file from each container to the next one in a chain-like manner, including the new containers. It also copies the gentx files from all containers to CONTAINER0. The final genesis.json is copied from CONTAINER0 to all other containers. The start commands for the new containers are commented out, similar to the old hunk. If these lines are meant to be executed, they should be uncommented.

fi

rm -rf $HOMEDIR
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the HOMEDIR variable is always correctly set before this script is run, as it could lead to unintentional deletion of directories if misconfigured.

- rm -rf $HOMEDIR
+ [ -n "$HOMEDIR" ] && rm -rf $HOMEDIR

Comment on lines +32 to +35
if [ "$(ls -A $HOMEDIR)" ]; then
echo "$HOMEDIR is not empty"
polard start --pruning=nothing "$TRACE" --log_level $LOGLEVEL --api.enabled-unsafe-cors --api.enable --api.swagger --minimum-gas-prices=0.0001abera --home "$HOMEDIR"
else
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script assumes that if the $HOMEDIR directory is not empty, it contains a valid network configuration. This might not always be the case. Consider adding a more robust check for a valid network configuration.

Comment on lines +38 to +46
polard init $MONIKER -o --chain-id $CHAINID --home "$HOMEDIR"

jq '.app_state["staking"]["params"]["bond_denom"]="abera"' "$GENESIS" >"$TMP_GENESIS"
jq '.app_state["crisis"]["constant_fee"]["denom"]="abera"' "$GENESIS" >"$TMP_GENESIS"
jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="abera"' "$GENESIS" >"$TMP_GENESIS"
jq '.app_state["evm"]["params"]["evm_denom"]="abera"' "$GENESIS" >"$TMP_GENESIS"
jq '.app_state["mint"]["params"]["mint_denom"]="abera"' "$GENESIS" >"$TMP_GENESIS"
jq '.consensus["params"]["block"]["max_gas"]="30000000"' "$GENESIS" >"$TMP_GENESIS"
mv "$TMP_GENESIS" "$GENESIS"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script modifies the genesis file in-place, which could lead to data loss if the script fails or is interrupted. Consider creating a backup of the original genesis file before modifying it.

Comment on lines +63 to +64
polard start --pruning=nothing "$TRACE" --log_level $LOGLEVEL --api.enabled-unsafe-cors --api.enable --api.swagger --minimum-gas-prices=0.0001abera --home "$HOMEDIR"
polard start --pruning=nothing '' --log_level info --api.enabled-unsafe-cors --api.enable --api.swagger --minimum-gas-prices=0.0001abera --home data/.polard
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate command execution. The same polard start command is executed twice with slightly different parameters. If this is intentional, please clarify why. Otherwise, remove the duplicate line.

-    polard start --pruning=nothing "$TRACE" --log_level $LOGLEVEL --api.enabled-unsafe-cors --api.enable --api.swagger --minimum-gas-prices=0.0001abera --home "$HOMEDIR"
-    polard start --pruning=nothing '' --log_level info --api.enabled-unsafe-cors --api.enable --api.swagger --minimum-gas-prices=0.0001abera --home data/.polard
+    polard start --pruning=nothing "$TRACE" --log_level $LOGLEVEL --api.enabled-unsafe-cors --api.enable --api.swagger --minimum-gas-prices=0.0001abera --home "$HOMEDIR"

KEYALGO="eth_secp256k1"
fi

HOMEDIR="/.polard"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HOMEDIR variable is being reassigned here after potentially being set in lines 21-23. If this line is necessary, consider removing the conditional assignment above. If it's not, simply remove this line to avoid overwriting the HOMEDIR value.

- HOMEDIR="/.polard"

Comment on lines +37 to +44
# # faucet
# polard keys add faucet --keyring-backend $KEYRING --algo $KEYALGO --home "$HOMEDIR"
# polard genesis add-genesis-account faucet 1000000000000000000000000000abera,1000000000000000000000000000stgusdc --keyring-backend $KEYRING --home "$HOMEDIR"

# # # Test Account
# # absurd surge gather author blanket acquire proof struggle runway attract cereal quiz tattoo shed almost sudden survey boring film memory picnic favorite verb tank
# # 0xfffdbb37105441e14b0ee6330d855d8504ff39e705c3afa8f859ac9865f99306
# polard genesis add-genesis-account cosmos1yrene6g2zwjttemf0c65fscg8w8c55w58yh8rl 1000000000000000000000000000abera,1000000000000000000000000000stgusdc --keyring-backend $KEYRING --home "$HOMEDIR"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are commented out. If they're not needed, consider removing them to keep the codebase clean. If they're meant for future use or debugging, consider adding a comment explaining their purpose.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant