-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve single-node.sh (#4041)
Closes #3975 Fixes a few issues I discovered with single-node.sh 1. `single-node.sh` previously created a genesis file with `appVersion: 3` so even though it attempted to upgrade from v1 -> v2, that step doesn't make any sense because the node was already on v3. This PR fixes the issue by removing the `--v2-upgrade-height` flag from the script 2. Add a few more logs 3. Add a new script: `single-node-upgrades.sh` that can be invoked to start a single node on v1 and upgrade it: v1 -> v2 -> v3. After running the command, the user will see ``` An upgrade is pending to app version 3 at height 50406. ``` ## FLUPs 1. Modify single-node.sh to override the upgrade height delay and instead upgrade from v2 -> v3 instantly: #4053 --------- Co-authored-by: CHAMI Rachid <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e52234f
commit a1c4cf7
Showing
3 changed files
with
188 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
#!/bin/sh | ||
|
||
# This script starts a single node testnet on app version 1. Then it upgrades | ||
# from v1 -> v2 -> v3. | ||
|
||
# Stop script execution if an error is encountered | ||
set -o errexit | ||
# Stop script execution if an undefined variable is used | ||
set -o nounset | ||
|
||
if ! [ -x "$(command -v celestia-appd)" ] | ||
then | ||
echo "celestia-appd could not be found. Please install the celestia-appd binary using 'make install' and make sure the PATH contains the directory where the binary exists. By default, go will install the binary under '~/go/bin'" | ||
exit 1 | ||
fi | ||
|
||
# Constants | ||
CHAIN_ID="test" | ||
KEY_NAME="validator" | ||
KEYRING_BACKEND="test" | ||
FEES="500utia" | ||
BROADCAST_MODE="block" | ||
|
||
VERSION=$(celestia-appd version 2>&1) | ||
APP_HOME="${HOME}/.celestia-app" | ||
GENESIS_FILE="${APP_HOME}/config/genesis.json" | ||
|
||
echo "celestia-app version: ${VERSION}" | ||
echo "celestia-app home: ${APP_HOME}" | ||
echo "celestia-app genesis file: ${GENESIS_FILE}" | ||
echo "" | ||
|
||
createGenesis() { | ||
echo "Initializing validator and node config files..." | ||
celestia-appd init ${CHAIN_ID} \ | ||
--chain-id ${CHAIN_ID} \ | ||
--home "${APP_HOME}" \ | ||
> /dev/null 2>&1 # Hide output to reduce terminal noise | ||
|
||
echo "Adding a new key to the keyring..." | ||
celestia-appd keys add ${KEY_NAME} \ | ||
--keyring-backend=${KEYRING_BACKEND} \ | ||
--home "${APP_HOME}" \ | ||
> /dev/null 2>&1 # Hide output to reduce terminal noise | ||
|
||
echo "Adding genesis account..." | ||
celestia-appd add-genesis-account \ | ||
"$(celestia-appd keys show ${KEY_NAME} -a --keyring-backend=${KEYRING_BACKEND} --home "${APP_HOME}")" \ | ||
"1000000000000000utia" \ | ||
--home "${APP_HOME}" | ||
|
||
echo "Creating a genesis tx..." | ||
celestia-appd gentx ${KEY_NAME} 5000000000utia \ | ||
--fees ${FEES} \ | ||
--keyring-backend=${KEYRING_BACKEND} \ | ||
--chain-id ${CHAIN_ID} \ | ||
--home "${APP_HOME}" \ | ||
> /dev/null 2>&1 # Hide output to reduce terminal noise | ||
|
||
echo "Collecting genesis txs..." | ||
celestia-appd collect-gentxs \ | ||
--home "${APP_HOME}" \ | ||
> /dev/null 2>&1 # Hide output to reduce terminal noise | ||
|
||
# If you encounter: `sed: -I or -i may not be used with stdin` on MacOS you can mitigate by installing gnu-sed | ||
# https://gist.github.com/andre3k1/e3a1a7133fded5de5a9ee99c87c6fa0d?permalink_comment_id=3082272#gistcomment-3082272 | ||
|
||
# Override the default RPC server listening address | ||
sed -i'.bak' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' "${APP_HOME}"/config/config.toml | ||
|
||
# Enable transaction indexing | ||
sed -i'.bak' 's#"null"#"kv"#g' "${APP_HOME}"/config/config.toml | ||
|
||
# Persist ABCI responses | ||
sed -i'.bak' 's#discard_abci_responses = true#discard_abci_responses = false#g' "${APP_HOME}"/config/config.toml | ||
|
||
# Override the genesis to use app version 1 and then upgrade to app version 2 later. | ||
sed -i'.bak' 's/"app_version": *"[^"]*"/"app_version": "1"/' ${APP_HOME}/config/genesis.json | ||
|
||
# Override the log level to debug | ||
# sed -i'.bak' 's#log_level = "info"#log_level = "debug"#g' "${APP_HOME}"/config/config.toml | ||
|
||
# Override the VotingPeriod from 1 week to 1 minute | ||
sed -i'.bak' 's#"604800s"#"60s"#g' "${APP_HOME}"/config/genesis.json | ||
|
||
trace_type="local" | ||
sed -i.bak -e "s/^trace_type *=.*/trace_type = \"$trace_type\"/" ${APP_HOME}/config/config.toml | ||
|
||
trace_pull_address=":26661" | ||
sed -i.bak -e "s/^trace_pull_address *=.*/trace_pull_address = \"$trace_pull_address\"/" ${APP_HOME}/config/config.toml | ||
|
||
trace_push_batch_size=1000 | ||
sed -i.bak -e "s/^trace_push_batch_size *=.*/trace_push_batch_size = \"$trace_push_batch_size\"/" ${APP_HOME}/config/config.toml | ||
|
||
echo "Tracing is set up with the ability to pull traced data from the node on the address http://127.0.0.1${trace_pull_address}" | ||
} | ||
|
||
deleteCelestiaAppHome() { | ||
echo "Deleting $APP_HOME..." | ||
rm -r "$APP_HOME" | ||
} | ||
|
||
startCelestiaApp() { | ||
echo "Starting celestia-app..." | ||
celestia-appd start \ | ||
--home "${APP_HOME}" \ | ||
--api.enable \ | ||
--grpc.enable \ | ||
--grpc-web.enable \ | ||
--v2-upgrade-height 3 \ | ||
--force-no-bbr # no need to require BBR usage on a local node. | ||
} | ||
|
||
upgradeToV3() { | ||
sleep 45 | ||
echo "Submitting signal for v3..." | ||
celestia-appd tx signal signal 3 \ | ||
--keyring-backend=${KEYRING_BACKEND} \ | ||
--home ${APP_HOME} \ | ||
--from ${KEY_NAME} \ | ||
--fees ${FEES} \ | ||
--chain-id ${CHAIN_ID} \ | ||
--broadcast-mode ${BROADCAST_MODE} \ | ||
--yes \ | ||
> /dev/null 2>&1 # Hide output to reduce terminal noise | ||
|
||
echo "Querying the tally for v3..." | ||
celestia-appd query signal tally 3 | ||
|
||
echo "Submitting msg try upgrade..." | ||
celestia-appd tx signal try-upgrade \ | ||
--keyring-backend=${KEYRING_BACKEND} \ | ||
--home ${APP_HOME} \ | ||
--from ${KEY_NAME} \ | ||
--fees ${FEES} \ | ||
--chain-id ${CHAIN_ID} \ | ||
--broadcast-mode ${BROADCAST_MODE} \ | ||
--yes \ | ||
> /dev/null 2>&1 # Hide output to reduce terminal noise | ||
|
||
echo "Querying for pending upgrade..." | ||
celestia-appd query signal upgrade | ||
} | ||
|
||
if [ -f $GENESIS_FILE ]; then | ||
echo "Do you want to delete existing ${APP_HOME} and start a new local testnet? [y/n]" | ||
read -r response | ||
if [ "$response" = "y" ]; then | ||
deleteCelestiaAppHome | ||
createGenesis | ||
fi | ||
else | ||
createGenesis | ||
fi | ||
|
||
upgradeToV3 & # Start the upgrade process from v2 -> v3 in the background. | ||
startCelestiaApp # Start celestia-app in the foreground. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters