-
Notifications
You must be signed in to change notification settings - Fork 292
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
fix: improve single-node.sh #4041
base: main
Are you sure you want to change the base?
Changes from all commits
d2f02b0
b6470c7
7df6ccb
03d8410
8e9dd1f
586e7f7
434f6ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,55 @@ | ||||||||||||||||||||||
#!/bin/sh | ||||||||||||||||||||||
|
||||||||||||||||||||||
# This script will upgrade the node from v2 -> v3. | ||||||||||||||||||||||
# Prerequisites: ensure ./single-node.sh is running in another terminal. | ||||||||||||||||||||||
# Wait until block height is 3 for the node to upgrade from v1 -> v2. | ||||||||||||||||||||||
|
||||||||||||||||||||||
# 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 | ||||||||||||||||||||||
Comment on lines
+31
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling between upgrade steps The upgrade commands are executed sequentially without verifying the success of each step. This could lead to incomplete upgrades. Consider adding verification between steps: 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
+
+# Verify signal submission success
+sleep 5 # Wait for transaction to be processed
+SIGNAL_COUNT=$(celestia-appd query signal tally 3 -o json | jq '.count')
+if [ "$SIGNAL_COUNT" -eq "0" ]; then
+ echo "Error: Signal submission failed"
+ exit 1
+fi
|
||||||||||||||||||||||
|
||||||||||||||||||||||
echo "Querying for pending upgrade..." | ||||||||||||||||||||||
celestia-appd query signal upgrade | ||||||||||||||||||||||
Comment on lines
+54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Verify upgrade status The script queries for pending upgrade but doesn't verify the result or provide clear success/failure indication. Add verification of the upgrade status: echo "Querying for pending upgrade..."
-celestia-appd query signal upgrade
+UPGRADE_STATUS=$(celestia-appd query signal upgrade -o json)
+if echo "$UPGRADE_STATUS" | jq -e '.upgrade.plan.height' > /dev/null; then
+ echo "Success: Upgrade to v3 is pending at height $(echo "$UPGRADE_STATUS" | jq -r '.upgrade.plan.height')"
+else
+ echo "Error: No pending upgrade found"
+ exit 1
+fi 📝 Committable suggestion
Suggested change
|
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.
🛠️ Refactor suggestion
Make environment variables configurable
The script uses hardcoded values which could limit its reusability across different environments.
Consider making these values configurable:
📝 Committable suggestion