Skip to content

Commit

Permalink
fix: improve single-node.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Nov 20, 2024
1 parent 32236a2 commit d2f02b0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
res := app.manager.EndBlock(ctx, req)
currentVersion := app.AppVersion()
// For v1 only we upgrade using an agreed upon height known ahead of time
app.BaseApp.Logger().Debug(fmt.Sprintf("currentVersion %v", currentVersion))
if currentVersion == v1 {
// check that we are at the height before the upgrade
if req.Height == app.upgradeHeightV2-1 {
Expand All @@ -476,6 +477,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
} else if shouldUpgrade, newVersion := app.SignalKeeper.ShouldUpgrade(ctx); shouldUpgrade {
// Version changes must be increasing. Downgrades are not permitted
if newVersion > currentVersion {
app.BaseApp.Logger().Info(fmt.Sprintf("upgrading from app version %v to %v", currentVersion, newVersion))
app.SetAppVersion(ctx, newVersion)
app.SignalKeeper.ResetTally(ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/single-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ createGenesis() {
sed -i'.bak' 's#"604800s"#"60s"#g' "${CELESTIA_APP_HOME}"/config/genesis.json

# Override the genesis to use app version 1 and then upgrade to app version 2 later.
sed -i'.bak' 's#"app_version": "2"#"app_version": "1"#g' "${CELESTIA_APP_HOME}"/config/genesis.json
sed -i'.bak' 's/"app_version": *"[^"]*"/"app_version": "1"/' ${CELESTIA_APP_HOME}/config/genesis.json

trace_type="local"
sed -i.bak -e "s/^trace_type *=.*/trace_type = \"$trace_type\"/" ${CELESTIA_APP_HOME}/config/config.toml
Expand Down
55 changes: 55 additions & 0 deletions scripts/upgrade-to-v3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh

# Prerequisites: ensure ./single-node.sh is running in another terminal.
# Wait until block height is 3 for the node to upgrade from v1 -> v2.
# This script will upgrade the node from 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

CHAIN_ID="test"
KEY_NAME="validator"
KEYRING_BACKEND="test"
CELESTIA_APP_HOME="${HOME}/.celestia-app"
CELESTIA_APP_VERSION=$(celestia-appd version 2>&1)
FEES="500utia"
BROADCAST_MODE="block"

echo "celestia-app home: ${CELESTIA_APP_HOME}"
echo "celestia-app version: ${CELESTIA_APP_VERSION}"
echo ""


echo "Submitting signal for v3..."
celestia-appd tx signal signal 3 \
--keyring-backend=${KEYRING_BACKEND} \
--home ${CELESTIA_APP_HOME} \
--from ${KEY_NAME} \
--fees ${FEES} \
--chain-id ${CHAIN_ID} \
--broadcast-mode ${BROADCAST_MODE} \
--yes

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 ${CELESTIA_APP_HOME} \
--from ${KEY_NAME} \
--fees ${FEES} \
--chain-id ${CHAIN_ID} \
--broadcast-mode ${BROADCAST_MODE} \
--yes

echo "Querying for pending upgrade..."
celestia-appd query signal upgrade

0 comments on commit d2f02b0

Please sign in to comment.