Closed LaurentMontBlanc closed 4 months ago
My suggestion is to fork cosmovisor
(posmovisor, plmntvisor, ...?) and extend the functionality to check for $DAEMON_HOME/data/upgrade-infos.json
(with an extra s
) for the initial setup, but also to not destroy the default behavior. And from now on all breaking changes must implement proper x/upgrade
to take advantage of upgrade-info.json
and BeginBlocker
.
@LaurentMontBlanc @eckelj I found a solution to combine a shell script with cosmovisor for the initial mainnet sync (as discussed).
Note: the script won't run out of the box on your computer and it needs an empty ~/.planetmint-go/
directory.
$ cat cosmovisor.sh
#!/bin/bash
export DAEMON_NAME=planetmint-god
export DAEMON_HOME=$HOME/.planetmint-go
export DAEMON_ALLOW_DOWNLOAD_BINARIES=true
export DAEMON_DOWNLOAD_MUST_HAVE_CHECKSUM=true
export DAEMON_RESTART_AFTER_UPGRADE=false
planetmint-god config chain-id test
planetmint-god config keyring-backend test
planetmint-god config broadcast-mode sync
planetmint-god init test --chain-id test
planetmint-god keys add validator
planetmint-god add-genesis-account validator 1000000000stake --keyring-backend test
planetmint-god gentx validator 1000000stake --chain-id test
planetmint-god collect-gentxs
cosmovisor init /home/julian/go/bin/planetmint-god
cosmovisor run start --halt-height 5
# directory for upgrade-info.json
mkdir -p /home/julian/.planetmint-go/data/
cat <<EOF > /home/julian/.planetmint-go/data/upgrade-info.json
{"name":"v0.5.9","time":"0001-01-01T00:00:00Z","height":5,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/planetmint/planetmint-go/releases/download/v0.5.9/planetmint-god?checksum=sha256:6193b4600f99536b709a2980a8b815e72611d01361360c5055e46f57d1f9a5b7\"}}"}
EOF
cosmovisor run start
cat <<EOF > /home/julian/.planetmint-go/data/upgrade-info.json
{"name":"v0.5.10","time":"0001-01-01T00:00:00Z","height":10,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/planetmint/planetmint-go/releases/download/v0.5.10/planetmint-god?checksum=sha256:6e58802a41e70d70c52ce74cfc7d17dedcd8447795d22eadfdbb722bfae3061b\"}}"}
EOF
cosmovisor run start
Open points:
DAEMON_ALLOW_DOWNLOAD_BINARIES
, which is not recommended by cosmos: for security reasons, this is intended for full nodes rather than validators?UNSAFE_SKIP_BACKUP
?Awesome! And yes, let's use DAEMON_ALLOW_DOWNLOAD_BINARIES in conjunction with the checksum verification.
Yes, let's set UNSAFE_SKIP_BACKUP=True for the initial sync.
@eckelj I was able to do a full sync over the weekend. Please give it a try:
#!/bin/bash
PWD=$(pwd)
if [[ "$PWD" != "$HOME" ]]; then
echo "Please execute this script in your home directory at '$HOME'. Exiting..."
exit 1
fi
# set environments variables for cosmovisor
export DAEMON_NAME=planetmint-god
export DAEMON_HOME=$HOME/.planetmint-go
export DAEMON_ALLOW_DOWNLOAD_BINARIES=true
export DAEMON_DOWNLOAD_MUST_HAVE_CHECKSUM=true
export DAEMON_RESTART_AFTER_UPGRADE=true
export UNSAFE_SKIP_BACKUP=true
# set environments variables for planetmint
export CHAIN_ID=planetmint-mainnet-1
export MINIMUM_GAS_PRICES="0.000005plmnt"
export MINT_ADDRESS="plmnt1p498zlxe4yhz5wqllgvk22ucnezgje5f9zexwz"
export PLANETMINT_HOME="$HOME/.planetmint-go/"
# get binaries and sha256 sums
for FILE in cosmovisor planetmint-god SHA256SUMS SHA256SUMS.gpg; do
if [ ! -f "$FILE" ]; then
wget https://github.com/planetmint/planetmint-go/releases/download/v0.5.10/$FILE
if [ $FILE != *"SHA256SUMS"* ]; then
chmod +x $FILE
fi
fi
done
# verify sha256 sums' gpg signature
gpg --quiet --recv-keys D03D86ACB03B349F38083EDAE0A8F9AD733499A7
if ! gpg --verify SHA256SUMS.gpg SHA256SUMS 2>1 /dev/null; then
exit 2
fi
# verify sha256 sums
if [ $(sha256sum -c SHA256SUMS 2>&1 | grep OK | wc -l) -ne 2 ]; then
echo "SHA256 sums don't match. Please remove files and try again...'"
exit 3
fi
# initialize planetmint
if [ ! -d "$PLANETMINT_HOME" ]; then
# initialize chain
./planetmint-god config chain-id $CHAIN_ID
# initialize cosmovisor
./cosmovisor init ./planetmint-god
# set config values
sed -i "s/minimum-gas-prices = \"0stake\"/minimum-gas-prices = \"$MINIMUM_GAS_PRICES\"/g" $HOME/.planetmint-go/config/app.toml
sed -i "s/mint-address = \"default\"/mint-address = \"$MINT_ADDRESS\"/g" $HOME/.planetmint-go/config/app.toml
fi
# get genesis block
FILE=genesis.json
if [ ! -f "$FILE" ]; then
wget -O $FILE https://raw.githubusercontent.com/rddl-network/docs/main/basics/chains/$CHAIN_ID-$FILE
fi
if [ ! -f "$PLANETMINT_HOME/config/$FILE" ]; then
cp $FILE $PLANETMINT_HOME/config/$FILE
fi
./cosmovisor run start --halt-height 2498700 \
--p2p.persistent_peers "15e93138bcbeacdff07072930c10e090121f69c6@planetmint-go-mainnet-1.rddl.io:26656,1abe4dd5b63f4f53697b811110a8bdadb26c2fcc@planetmint-go-mainnet-2.rddl.io:26656,1d043989a1108e27e41e3cf76322533d1f5880ff@planetmint-go-mainnet-3.rddl.io:26656" \
--p2p.unconditional_peer_ids "15e93138bcbeacdff07072930c10e090121f69c6,1abe4dd5b63f4f53697b811110a8bdadb26c2fcc,1d043989a1108e27e41e3cf76322533d1f5880ff"
cat <<EOF > $PLANETMINT_HOME/data/upgrade-info.json
{"name":"v0.6.6","time":"0001-01-01T00:00:00Z","height":2498700,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/planetmint/planetmint-go/releases/download/v0.6.6/planetmint-god?checksum=sha256:05073a5124ca8c8de92015643d0333573e3745e0460c6848c78804413d00133b\"}}"}
EOF
./cosmovisor run start --halt-height 2498765
cat <<EOF > $PLANETMINT_HOME/data/upgrade-info.json
{"name":"v0.7.0","time":"0001-01-01T00:00:00Z","height":2498765,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/planetmint/planetmint-go/releases/download/v0.7.0/planetmint-god?checksum=sha256:21f83fd8fb454cbd616e183d4801cc60b309da07e078f5d9e27bacd26a199be5\"}}"}
EOF
./cosmovisor run start --halt-height 2501349
cat <<EOF > $PLANETMINT_HOME/data/upgrade-info.json
{"name":"v0.8.0","time":"0001-01-01T00:00:00Z","height":2501349,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/planetmint/planetmint-go/releases/download/v0.8.0/planetmint-god?checksum=sha256:6410f3a3da08b37488597d43e122caa97cdb1de0f967e343c63a5be101027d14\"}}"}
EOF
./cosmovisor run start --halt-height 2501999
cat <<EOF > $PLANETMINT_HOME/data/upgrade-info.json
{"name":"v0.9.6","time":"0001-01-01T00:00:00Z","height":2501999,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/planetmint/planetmint-go/releases/download/v0.9.6/planetmint-god?checksum=sha256:c178d96e160916597523b0a6f12767d8dbbb12470cbef3f555ea50cca70c3bdf\"}}"}
EOF
./cosmovisor run start --halt-height 2714149
cat <<EOF > $PLANETMINT_HOME/data/upgrade-info.json
{"name":"v0.10.0","time":"0001-01-01T00:00:00Z","height":2714149,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/planetmint/planetmint-go/releases/download/v0.10.0/planetmint-god?checksum=sha256:d6e1eabcfa3b9153783dbd682066125da38da846e76ce6582eff03b4c89fb7fb\"}}"}
EOF
./cosmovisor run start
it works! just verified it!
I did some initial investigations. here are some findings:
DAEMON_ALLOW_DOWNLOAD_BINARIES
andDAEMON_DOWNLOAD_MUST_HAVE_CHECKSUM
(daemon meaningplanetmint-god
in our case.)$DAEMON_HOME/data/upgrade-info.json
file for new upgrade instructions. The file is created by thex/upgrade
module in BeginBlocker when an upgrade is detected and the blockchain reaches the upgrade height.upgrade-info.json
can only consist of one object like this:I would have hoped that we can pass an array of upgrade-info.jsons