diff --git a/bitsong-2b/upgrades/README.md b/bitsong-2b/upgrades/README.md index f20922c..55596ab 100644 --- a/bitsong-2b/upgrades/README.md +++ b/bitsong-2b/upgrades/README.md @@ -1,11 +1,8 @@ -# Network Upgrades +# Network Upgrades ## Upgrades -| Version | | | | | -|---|---|---|---|---| -| [v0.20.0](v0.20.0/guide.md) | v020 | | | | -| [v0.21.0](v0.21.0/guide.md) | v021 | | | | -| [manual](manual-upgrades/README.md) | | | | | - - +| Current Version | | | | | +|---|---|---|---|---| +| [v0.24.0](v0.24.0/guide.md) | v024 | | | | + diff --git a/bitsong-2b/upgrades/postmortems/v0.21.0.md b/bitsong-2b/upgrades/postmortems/v0.21.0.md index 2927010..7bd93c5 100644 --- a/bitsong-2b/upgrades/postmortems/v0.21.0.md +++ b/bitsong-2b/upgrades/postmortems/v0.21.0.md @@ -1,4 +1,4 @@ -## After The Upgrade Report +## After The Upgrade Report: v0.20.4 ## What Happened? diff --git a/bitsong-2b/upgrades/postmortems/v0.21.4.md b/bitsong-2b/upgrades/postmortems/v0.21.4.md new file mode 100644 index 0000000..e38d899 --- /dev/null +++ b/bitsong-2b/upgrades/postmortems/v0.21.4.md @@ -0,0 +1,15 @@ +## After The Upgrade Report: v0.21.4 + +## What Happened? + +## Immediate Consensus Afer Graceful Halt + +Upon reaching the halt height, any node that did not gracefully halt to apply the patch as instructed through the upgrade guide began the consensus rounds prevotes,as normally expected. +Due to this upgrade not actually containing any consensus breaking logic (not regarding moving the wasm data path), once nodes that did gracefully halt, applied the wasm data path correction, and upgraded to the latest version of go-bitsong, +consensus was able to be met essentially immediately after reaching the halt height. + + +## App Hash Triggered By Cosmwasm Execution + +Once consensus was resumed, it was confirmed that the bug present with cosmwasm stateful queries was resolved, and a transaction calling a cosmwasm contract was submitted by the core team, +resulting in an app-hash difference between nodes that did not perform all of the patch steps as necessary, and those that did. Nodes that did not have the correct final app hash were required to use a snapshot prior to the halt height, and reapply the coordinated patch as expected to end up with the correct app hash. This took some time for the majority of nodes to agree on the finalized app hash, & upon reaching 2/3 majority consensus, the block was committed and we resumed block creation as epected. \ No newline at end of file diff --git a/bitsong-2b/upgrades/v0.22.0/cosmovisor.json b/bitsong-2b/upgrades/v0.22.0/cosmovisor.json new file mode 100644 index 0000000..939512b --- /dev/null +++ b/bitsong-2b/upgrades/v0.22.0/cosmovisor.json @@ -0,0 +1,6 @@ +{ + "binaries": { + "linux/arm64": "https://github.com/permissionlessweb/go-bitsong/releases/download/v0.22.0/bitsongd-linux-arm64?checksum=sha256:734366c046657a13cfe1c8b953048e22015bfa4a5e97101d94eb094ff44fc4a8", + "linux/amd64": "https://github.com/permissionlessweb/go-bitsong/releases/download/v0.22.0/bitsongd-linux-amd64?checksum=sha256:4c259679283b6e0caae9adc9000fb2cc3fc5fc167dbf760de34ac3d4984459b0" + } +} \ No newline at end of file diff --git a/bitsong-2b/upgrades/v0.22.0/guide.md b/bitsong-2b/upgrades/v0.22.0/guide.md new file mode 100644 index 0000000..16661a2 --- /dev/null +++ b/bitsong-2b/upgrades/v0.22.0/guide.md @@ -0,0 +1,86 @@ +# Go-Bitsong v0.22.0 - Nina +| | | +|-----------------|--------------------------------------------------------------| +| Chain-id | `bitsong-2b` | +| Upgrade Version | `v0.22.0` | +| Upgrade Height | `22412000` | + + +The target block for this upgrade is `22412000`, which is expected to arrive at `May 19th 2025, 15:38:25 UTC` [Mintscan Countdown](https://www.mintscan.io/bitsong/block/22412000) + +## Building Manually: + +### 1. Verify that you are currently running the correct version (v0.21.6) of `bitsongd`: + +```sh +bitsongd version --long +# name: go-bitsong +# server_name: bitsongd +# client_name: bitsongcli +# version: 0.21.6 +# commit: fbdc84594b0a65d2bbe1da4381f71932efa7efed +# build_tags: netgo,ledger +``` + +### 2. Make sure your chain halts at the right block: `22412000` +```sh +perl -i -pe 's/^halt-height =.*/halt-height = 22412000/' ~/.bitsongd/config/app.toml +``` +then restart your node `systemctl restart bitsongd` + +### 3. After the chain has halted, make a backup of your `.bitsongd` directory +```sh +cp -Rf ~/.bitsongd ./bitsongd_backup +``` + +**NOTE**: It is recommended for validators and operators to take a full data snapshot at the export height before proceeding in case the upgrade does not go as planned or if not enough voting power comes online in a sufficient and agreed upon amount of time. In such a case, the chain will fallback to continue operating `bitsong-2b`. +~z + +### Option A: Install Go-Bitsong binary +```sh +git clone https://github.com/permissionlessweb/go-bitsong +cd go-bitsong && git pull && git checkout v0.22.0 +make install +``` + +### 5. Verify you are currently running the correct version (v0.20.2) of the `go-bitsong`: +```sh +bitsongd version --long | grep "cosmos_sdk_veresion/|commit\|version:" +# commit: 424ccd2affd7274a6befcdb99079d1f05fab6e86 +# cosmos_sdk_version: v0.53.0 +# version: 0.22.0 +``` + +### Option B: Downloading Verified Build: +```sh +# set target platform +export PLATFORM_TARGET=amd64 #arm64 + # delete if exists +rm -rf bitsongd_linux_$PLATFORM_TARGET.tar.gz +# download +curl -L -o ~/bitsongd-linux-$PLATFORM_TARGET.tar.gz https://github.com/bitsongofficial/go-bitsong/releases/download/v0.22.0/bitsongd-linux-$PLATFORM_TARGET.tar.gz +# verify sha256sum +sha256sum bitsongd-linux-$PLATFORM_TARGET.tar.gz +# Output: 810188661f98a75941de3a0d3671a7ec40e19824b93ab1f9204ac585300537de bitsongd-linux-amd64.tar.gz +# Output: 4dcf0f96d83613620e3e2ea6e037de0400c732ee4ce6a176b517e42b8a4f2721 bitsongd-linux-arm64.tar.gz + +# decompress +tar -xvzf bitsongd-linux-$PLATFORM_TARGET.tar.gz + +## move binary to go bin path +sudo mv build/bitsongd-linux-$PLATFORM_TARGET $HOME/go/bin/bitsongd + +## change file ownership, if nessesary +sudo chmod +x $HOME/go/bin/bitsongd + +## confirm binary executable works +bitsongd version --long + +# build_tags: netgo,ledger +# commit: 424ccd2affd7274a6befcdb99079d1f05fab6e86 +# server_name: bitsongd +# version:0.22.0 +``` + +### Option C: Cosmovisor + diff --git a/bitsong-2b/upgrades/v0.23.0/cosmovisor.json b/bitsong-2b/upgrades/v0.23.0/cosmovisor.json new file mode 100644 index 0000000..ba57158 --- /dev/null +++ b/bitsong-2b/upgrades/v0.23.0/cosmovisor.json @@ -0,0 +1,6 @@ +{ + "binaries": { + "linux/arm64": "https://github.com/permissionlessweb/go-bitsong/releases/download/v0.23.0/bitsongd-linux-arm64?checksum=sha256:137d515f0799d7089803170256a79a7d77bf987de6d6a78eaa895a95d3e8e20b", + "linux/amd64": "https://github.com/permissionlessweb/go-bitsong/releases/download/v0.23.0/bitsongd-linux-amd64?checksum=sha256:81fa596c6deeb635c4c16d84bc1e6b990982fed6ab10cf0a0e377841f778e094" + } +} \ No newline at end of file diff --git a/bitsong-2b/upgrades/v0.23.0/guide.md b/bitsong-2b/upgrades/v0.23.0/guide.md new file mode 100644 index 0000000..3158dbf --- /dev/null +++ b/bitsong-2b/upgrades/v0.23.0/guide.md @@ -0,0 +1,85 @@ +# Go-Bitsong v0.23.0 - Gauss +| | | +|-----------------|--------------------------------------------------------------| +| Chain-id | `bitsong-2b` | +| Upgrade Version | `v0.23.0` | +| Upgrade Height | `22990737` | + + +The target block for this upgrade is `22990737`, which is expected to arrive at `Thursday June 26th 2025, 15:00:00 UTC` [Chainroot Countdown](https://explorer.chainroot.io/bitsong/blocks/22990737) + +## Building Manually: + +### 1. Verify that you are currently running the correct version (v0.22.0) of `bitsongd`: + +```sh +bitsongd version --long +# name: go-bitsong +# server_name: bitsongd +# version: 0.22.0 +# commit: +# build_tags: netgo,ledger +``` + +### 2. Make sure your chain halts at the right block: `22990737` +```sh +perl -i -pe 's/^halt-height =.*/halt-height = 22990737/' ~/.bitsongd/config/app.toml +``` +then restart your node `systemctl restart bitsongd` + +### 3. After the chain has halted, make a backup of your `.bitsongd` directory +```sh +cp -Rf ~/.bitsongd ./bitsongd_backup +``` + +**NOTE**: It is recommended for validators and operators to take a full data snapshot at the export height before proceeding in case the upgrade does not go as planned or if not enough voting power comes online in a sufficient and agreed upon amount of time. In such a case, the chain will fallback to continue operating `bitsong-2b`. +~z + +### Option A: Install Go-Bitsong binary +```sh +git clone https://github.com/permissionlessweb/go-bitsong +cd go-bitsong && git pull && git checkout v0.23.0 +make install +``` + +### 5. Verify you are currently running the correct version (v0.23.0) of the `go-bitsong`: +```sh +bitsongd version --long | grep "cosmos_sdk_veresion/|commit\|version:" +# commit: 831d0ee582d651e1dbc27715c740e38ad01225bc +# cosmos_sdk_version: v0.53.0 +# version: v0.23.0 +``` + +### Option B: Downloading Verified Build: +```sh +# set target platform +export PLATFORM_TARGET=amd64 #arm64 + # delete if exists +rm -rf bitsongd_linux_$PLATFORM_TARGET.tar.gz +# download +curl -L -o ~/bitsongd-linux-$PLATFORM_TARGET.tar.gz https://github.com/bitsongofficial/go-bitsong/releases/download/v0.23.0/bitsongd-linux-$PLATFORM_TARGET.tar.gz +# verify sha256sum +sha256sum bitsongd-linux-$PLATFORM_TARGET.tar.gz +# Output: 1f2338fbb93af915985293044d647b19b83b4c7da66f90b034f9c681b89d4fe9 bitsongd-linux-amd64.tar.gz +# Output: 80a7081968bc71b00c906518954776fea0c716e11c3149439bd85069f115172e bitsongd-linux-arm64.tar.gz + +# decompress +tar -xvzf bitsongd-linux-$PLATFORM_TARGET.tar.gz + +## move binary to go bin path +sudo mv build/bitsongd-linux-$PLATFORM_TARGET $HOME/go/bin/bitsongd + +## change file ownership, if nessesary +sudo chmod +x $HOME/go/bin/bitsongd + +## confirm binary executable works +bitsongd version --long + +# build_tags: netgo,ledger +# commit: 831d0ee582d651e1dbc27715c740e38ad01225bc +# server_name: bitsongd +# version: v0.23.0 +``` + +### Option C: Cosmovisor + diff --git a/bitsong-2b/upgrades/v0.24.0/cosmovisor.json b/bitsong-2b/upgrades/v0.24.0/cosmovisor.json new file mode 100644 index 0000000..1ea59ee --- /dev/null +++ b/bitsong-2b/upgrades/v0.24.0/cosmovisor.json @@ -0,0 +1,7 @@ +{ + "binaries": { + "linux/arm64": "https://github.com/permissionlessweb/go-bitsong/releases/download/v0.24.0/bitsongd-linux-arm64?checksum=sha256:da09272cbdb6ab379edca3507bd4dba875e56ec1c8cdc09d4d26c624dec097cb", + "linux/amd64": "https://github.com/permissionlessweb/go-bitsong/releases/download/v0.24.0/bitsongd-linux-amd64?checksum=sha256:a839eb5c7eda761e4f7e80948ebaa9a3bfcc05f616846cd07ad1d53f50868163" + }, + "pre_upgrade_script": "https://raw.githubusercontent.com/permissionlessweb/networks/refs/heads/master/bitsong-2b/upgrades/v0.24.0/preUpgradeScript.sh?checksum=sha256:f4e88c199864094ae025e0ce3b8bd9ff0b5e648bfe00acd80e4062ef6d3d5d0b" +} \ No newline at end of file diff --git a/bitsong-2b/upgrades/v0.24.0/guide.md b/bitsong-2b/upgrades/v0.24.0/guide.md new file mode 100644 index 0000000..9fd530d --- /dev/null +++ b/bitsong-2b/upgrades/v0.24.0/guide.md @@ -0,0 +1,213 @@ +# Go-Bitsong v0.24.0 - Jimi + +| | | +|-----------------|--------------------------------------------------------------| +| Chain-id | `bitsong-2b` | +| Upgrade Version | [`v0.24.0`](https://github.com/bitsongofficial/go-bitsong/pull/292) | +| Upgrade Height | [`24784361`](https://explorer.chainroot.io/bitsong/blocks/24784361) | + +The target block for this upgrade is `24784361`, which is expected to arrive at `Mon, Oct 20 2025` [Go Playground](https://go.dev/play/p/c3Y6Cy_BrIc) + +## PRE-UPGRADE-SCRIPT + +> VALIDATORS MUST MODIFY THEIR `CONFIG.TOML` CONSENSUS PARAMETERS **AFTER** REACHING THE COORDINATED HALT HEIGHT, & BEFORE **INSTALLING** THE NEWEST VERSION OF GO-BITSONG + +This can be done 1 of 3 ways: + +1. **Manually**: Nodes not using cosmovisor will **wait until the network halts**, then **manually apply `config.toml` changes** before installing the v5.0.0 binary and restarting. +2. **With Default Cosmovisor**: Node operators must download the pre-upgrade script and set environment variables BEFORE reaching our coordinated halt height. Cosmovisor will automatically execute the script and upgrade when the halt height is reached. +3. **With Custom Cosmovisor**: A modified cosmovisor that automatically downloads and executes pre-upgrade scripts. Operators must install the custom cosmovisor binary BEFORE reaching the coordinated halt height - no manual script download required. + +### A. WITHOUT COSMOVISOR: Manual Update to `config.toml` + +Upon reaching the coordinated halt height, apply the changes needed to your config files BEFORE installing the latest version: + +```sh +# define your nodes config file location +export CONFIG_PATH=$HOME/.bitsongd/config/config.toml +# apply updates to the consensus params +sed -i.bak "/^\[consensus\]/,/^\[/ s/^[[:space:]]*timeout_commit[[:space:]]*=.*/timeout_commit = \"2400ms\"/" "$CONFIG_PATH" +sed -i.bak "/^\[consensus\]/,/^\[/ s/^[[:space:]]*timeout_propose[[:space:]]*=.*/timeout_propose = \"2400ms\"/" "$CONFIG_PATH" +# confirm updates were applied +grep -E "timeout_commit|timeout_propose" "$CONFIG_PATH" +# should see: +# timeout_propose = "2400ms" +# # How much timeout_propose increases with each round +# timeout_propose_delta = "500ms" +# timeout_commit = "2400ms" +# skip_timeout_commit = false +``` + +### B. WITH COSMOVISOR: Semi-Automatic Upgrade Via Cosmovisor + +Cosmovisor support the execution of a pre-upgrade script, if one exists in the expected location within cosmovisors home directory. You can prepare your cosmovisor to execute the pre-upgrade-script via the following steps: + +```sh +systemctl stop bitsongd.service +# download & verify the sh script, place in the correct location for cosmovisor +wget https://raw.githubusercontent.com/permissionlessweb/networks/refs/heads/master/bitsong-2b/upgrades/v0.24.0/preUpgradeScript.sh $DAEMON_HOME/cosmovisor/preUpgradeScript.sh +# confirm checksums match +sha256sum preUpgradeScript.sh $DAEMON_HOME/cosmovisor/preUpgradeScript.sh +# output should be: +# f4e88c199864094ae025e0ce3b8bd9ff0b5e648bfe00acd80e4062ef6d3d5d0b preUpgradeScript.sh +# set the environment variable for cosmovisor (preferably in systemd file) +sudo sed -i '' 's/Environment="DAEMON_RESTART_AFTER_UPGRADE=true"/&\'$'\n''Environment="COSMOVISOR_CUSTOM_PREUPGRADE=preUpgradeScript.sh"/' /etc/systemd/system/bitsongd.service +# reload the daemon-process +sudo -S systemctl daemon-reload +sudo systemctl start bitsongd +``` + +Cosmovisor will now perform the pre-upgrade scripts once reaching the coordinated halt height & prior to installing and resuming with the latest go-btisong version. + +### C. WITH CUSTOM COSMOVISOR: Fully-Automatic Upgrade Via Custom Cosmovisor +> +> If you would like to completely automate the pre-upgrade script, **we have released a version of cosmovisor** that will download any preUpgradeScript defined in the UpgradeInfo embedded in our upgrade proposal. You can review the [modifications made here](https://github.com/cosmos/cosmos-sdk/compare/main...permissionlessweb:cosmos-sdk:feat/cosmovisor-preupgradescript). + +**If you ARE already running cosmovisor**, before reaching the coordinated upgrade height, you will need to install our custom version: + +```sh +# kill existing cosmovisor process +systemctl stop bitsongd.service +# build/install custom cosmovisor +git clone -b feat/cosmovisor-preupgradescript https://github.com/permissionlessweb/cosmos-sdk cv-cosmos-sdk +cd cv-cosmos-sdk/tools/cosmovisor || exit +make cosmovisor +# move new build into go binaries path (requires sudo) +sudo mv cosmovisor /usr/local/bin/ +# resume cosmovisor process +sudo -S systemctl daemon-reload +sudo systemctl start bitsongd +``` + +**If you ARE NOT running cosmovisor**, berfore reaching the coordinated upgrade height: + +```sh +# kill any bitsongd process +systemctl stop bitsongd.service +# install custom cosmovisor version +git clone -b feat/cosmovisor-preupgradescript https://github.com/permissionlessweb/cosmos-sdk cv-cosmos-sdk +# traverse into cosmovisor root +cd cv-cosmos-sdk/tools/cosmovisor || exit +# build cosmovisor image manually +make cosmovisor +# move binary into system-wide user binary directory +mv cosmovisor /usr/local/bin/ +# cleanup workspace +cd ../../../ && rm -rf cv-cosmos-sdk +# initialize and configure +# +# define environment variables +export DAEMON_NAME=bitsongd +export DAEMON_HOME=$HOME/.bitsongd +# move existing binary into path cosmovisor accesses +cosmovisor init $HOME/go/bin/bitsongd +# setup systemd process +sudo bash -c 'cat > /etc/systemd/system/bitsongd.service << EOF +[Unit] +Description=Bitsongd Daemon (cosmovisor) +After=network-online.target + +[Service] +User='$USER' +ExecStart=/home/'$USER'/go/bin/cosmovisor run start +Restart=always +RestartSec=3 +LimitNOFILE=4096 +Environment=DAEMON_NAME='bitsongd' +Environment=DAEMON_HOME='$HOME/.bitsongd' +Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=true" +Environment="DAEMON_RESTART_AFTER_UPGRADE=true" + +[Install] +WantedBy=multi-user.target +EOF' + +# reload systemctl +sudo -S systemctl daemon-reload +sudo -S systemctl enable bitsongd +# enable +sudo systemctl start bitsongd +``` + +Now, when cosmovisor recieves an upgrade plan, it will download & prepare the pre-upgrade script, if it exists, automatically. + +> We have full e2e test for each method, located in the latest release. Its recommended to test the upgrade workflow you choose manually before voting on the proposal: + +## Building Manually + +### 1. Verify that you are currently running the correct version (v0.23.0) of `bitsongd` + +```sh +bitsongd version --long +# name: go-bitsong +# server_name: bitsongd +# version: 0.23.0 +# commit: +# build_tags: netgo,ledger +``` + +### 2. Make sure your chain halts at the right block: `24784361` + +```sh +perl -i -pe 's/^halt-height =.*/halt-height = 24784361/' ~/.bitsongd/config/app.toml +``` + +then restart your node `systemctl restart bitsongd` + +### 3. After the chain has halted, make a backup of your `.bitsongd` directory + +```sh +cp -Rf ~/.bitsongd ./bitsongd_backup +``` + +**NOTE**: It is recommended for validators and operators to take a full data snapshot at the export height before proceeding in case the upgrade does not go as planned or if not enough voting power comes online in a sufficient and agreed upon amount of time. In such a case, the chain will fallback to continue operating `bitsong-2b`. +~z + +### Option A: Install Go-Bitsong binary + +```sh +git clone https://github.com/permissionlessweb/go-bitsong +cd go-bitsong && git pull && git checkout v0.24.0 +make install +``` + +### 5. Verify you are currently running the correct version (v0.24.0) of the `go-bitsong` + +```sh +bitsongd version --long | grep -E "cosmos_sdk_version|commit:|version:" +# commit: 920cf3531727e23c4a45fba80dbec49b7bc70db9 +# cosmos_sdk_version: v0.53.4 +# version: 0.24.0 +``` + +### Option B: Downloading Verified Build + +```sh +# set target platform +export PLATFORM_TARGET=amd64 #arm64 + # delete if exists +rm -rf bitsongd_linux_$PLATFORM_TARGET.tar.gz +# download +curl -L -o ~/bitsongd-linux-$PLATFORM_TARGET.tar.gz https://github.com/bitsongofficial/go-bitsong/releases/download/v0.24.0/bitsongd-linux-$PLATFORM_TARGET.tar.gz +# verify sha256sum +sha256sum bitsongd-linux-$PLATFORM_TARGET.tar.gz +# Output: c7fb19fc3cc45549b32c5e2b6b6b36c185ea4d12ed9ec6ce92089ce3a056abfe bitsongd-linux-amd64.tar.gz +# Output: 9f7a872e394788f460709a491bf253a092aa3c60f8ddd06848ae20266bbeb00c bitsongd-linux-arm64.tar.gz + +# decompress +tar -xvzf bitsongd-linux-$PLATFORM_TARGET.tar.gz + +## move binary to go bin path +sudo mv build/bitsongd-linux-$PLATFORM_TARGET $HOME/go/bin/bitsongd + +## change file ownership, if nessesary +sudo chmod +x $HOME/go/bin/bitsongd + +## confirm binary executable works +bitsongd version --long + +# build_tags: netgo,ledger +# commit: 920cf3531727e23c4a45fba80dbec49b7bc70db9 +# server_name: bitsongd +# version: v0.24.0 +``` diff --git a/bitsong-2b/upgrades/v0.24.0/install-cosmovisor.sh b/bitsong-2b/upgrades/v0.24.0/install-cosmovisor.sh new file mode 100644 index 0000000..ccf0340 --- /dev/null +++ b/bitsong-2b/upgrades/v0.24.0/install-cosmovisor.sh @@ -0,0 +1,11 @@ +#!/bin/sh +git clone -b feat/cosmovisor-preupgradescript https://github.com/permissionlessweb/cosmos-sdk cv-cosmos-sdk +# traverse into cosmovisor root +cd cv-cosmos-sdk/tools/cosmovisor || exit +# build cosmovisor image manually +make cosmovisor +# move binary into system-wide user binary directory +mv cosmovisor /usr/local/bin/ +# cleanup workspace +cd ../../../ && rm -rf cv-cosmos-sdk + diff --git a/bitsong-2b/upgrades/v0.24.0/preUpgradeScript.sh b/bitsong-2b/upgrades/v0.24.0/preUpgradeScript.sh new file mode 100644 index 0000000..1fd2249 --- /dev/null +++ b/bitsong-2b/upgrades/v0.24.0/preUpgradeScript.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# preUpgradeScript.sh - Called by cosmovisor to tweak config.toml before upgrade +# Purpose: Reduce block times by adjusting consensus timeouts for faster blocks + +# Ensure DAEMON_HOME is set (set by cosmovisor) +if [ -z "$DAEMON_HOME" ]; then + echo "ERROR: DAEMON_HOME is not set. This script must be run by cosmovisor." >&2 + exit 1 +fi + +CONFIG_PATH="$DAEMON_HOME/config/config.toml" + +# Check if config file exists +if [ ! -f "$CONFIG_PATH" ]; then + echo "ERROR: config.toml not found at $CONFIG_PATH" >&2 + exit 1 +fi + +# Backup original config (atomic, safe) +cp "$CONFIG_PATH" "$CONFIG_PATH.bak" +echo "Backup created: $CONFIG_PATH.bak" + +# Update timeout_commit if it exists in [consensus] section +sed -i.bak "/^\[consensus\]/,/^\[/ s/^[[:space:]]*timeout_commit[[:space:]]*=.*/timeout_commit = \"2400ms\"/" "$CONFIG_PATH" + +# Update timeout_propose if it exists in [consensus] section +sed -i.bak "/^\[consensus\]/,/^\[/ s/^[[:space:]]*timeout_propose[[:space:]]*=.*/timeout_propose = \"2400ms\"/" "$CONFIG_PATH" + +# Remove the extra .bak files created by sed -i.bak (we only need one backup) +rm -f "$CONFIG_PATH.bak.bak" + +echo "✅ Successfully updated consensus timeouts in $CONFIG_PATH" +echo " timeout_commit = 2400ms" +echo " timeout_propose = 2400ms" \ No newline at end of file