From b01b9c78f0efce6ca4bc2139175a186041681ad6 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Mon, 4 Sep 2023 14:43:00 +0200 Subject: [PATCH 01/29] --x-crisis-skip-assert-invariants flag in genesisd.service added --- genesisd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesisd.service b/genesisd.service index a8541f775d..dce100b552 100644 --- a/genesisd.service +++ b/genesisd.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=root WorkingDirectory=/root -ExecStart=/root/go/bin/genesisd start --log_level info +ExecStart=/root/go/bin/genesisd start --x-crisis-skip-assert-invariants --log_level info Restart=on-failure RestartSec=60 LimitNOFILE=50000 From 9ba04597211e12f2e7909dacb0bd393ec3cef79e Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Mon, 4 Sep 2023 21:22:30 +0200 Subject: [PATCH 02/29] Changed MemTotal and SwapTotal to MemAvailable and SwapFree --- genesisd.sh | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index b252eee924..7d2dd04c52 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -34,12 +34,8 @@ EOF moniker="" minimum_combined_gb=150 -repo_dir=$(cd "$(dirname "$0")" && pwd) -total_ram_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}') -total_swap_kb=$(grep SwapTotal /proc/meminfo | awk '{print $2}') -total_combined_gb=$((($total_ram_kb + $total_swap_kb) / 1024 / 1024)) -available_disk_gb=$(df -BG --output=avail / | awk 'NR==2 {print $1}' | tr -d 'G') disk_headroom_gb=50 +repo_dir=$(cd "$(dirname "$0")" && pwd) # Function to add a line to a file if it doesn't already exist (to prevent duplicates) # Usage: add_line_to_file "line" file [use_sudo] @@ -106,7 +102,29 @@ case "$1" in ;; esac +sleep 15s + +#PONYSAY +snap install ponysay +ponysay "Installing genesisd from source code with updated genesis_29-2 mainnet!" +sleep 5s +ponysay "WARNING: cosmosvisor, evmosd processes will be killed and genesis, genesisd, evmos, evmosd system services will be stopped with this script on the next step. If you have other blockchains running, you might want to delete those parts of the script!" +sleep 20s + +#STOPPING EVMOSD DAEMON AND COSMOVISOR IF IT WAS NOT STOPPED +pkill evmosd +pkill cosmovisor +service genesis stop +service genesisd stop +service evmos stop +service evmosd stop + # ADD ADDITIONAL SWAP (IF NECESSARY) +total_ram_kb=$(grep MemAvailable /proc/meminfo | awk '{print $2}') +total_swap_kb=$(grep SwapFree /proc/meminfo | awk '{print $2}') +total_combined_gb=$((($total_ram_kb + $total_swap_kb) / 1024 / 1024)) +available_disk_gb=$(df -BG --output=avail / | awk 'NR==2 {print $1}' | tr -d 'G') + if [ "$total_combined_gb" -lt "$minimum_combined_gb" ]; then # Calculate additional swap space needed in gigabytes additional_swap_gb=$((minimum_combined_gb - total_combined_gb + 1)) @@ -143,8 +161,6 @@ else echo "No additional swap space needed." fi -sleep 15s - # SYSTEM UPDATE, INSTALLATION OF THE FOLLOWING PACKAGES: jq git wget make gcc build-essential snapd wget ponysay, INSTALLATION OF GO 1.20 via snap sudo apt-get update -y @@ -161,21 +177,6 @@ add_line_to_file "root - nofile 50000" /etc/security/limits.conf false add_line_to_file "fs.file-max = 50000" /etc/sysctl.conf false ulimit -n 50000 -#PONYSAY -snap install ponysay -ponysay "Installing genesisd from source code with updated genesis_29-2 mainnet!" -sleep 5s -ponysay "WARNING: cosmosvisor, evmosd processes will be killed and genesis, genesisd, evmos, evmosd system services will be stopped with this script on the next step. If you have other blockchains running, you might want to delete those parts of the script!" -sleep 20s - -#STOPPING EVMOSD DAEMON AND COSMOVISOR IF IT WAS NOT STOPPED -pkill evmosd -pkill cosmovisor -service genesis stop -service genesisd stop -service evmos stop -service evmosd stop - # BACKUP genesis_29-2 (evmos version) .genesisd cd rsync -r --verbose --exclude 'data' ./.genesisd/ ./.genesisd_backup/ From 8ff32b1f42daf6c109866bd4d42f80f6e65a893f Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Mon, 4 Sep 2023 21:25:05 +0200 Subject: [PATCH 03/29] Had to get dependencies back on top else snap ponysay would fail --- genesisd.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index 7d2dd04c52..c3530f7c62 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -104,6 +104,16 @@ esac sleep 15s +# SYSTEM UPDATE, INSTALLATION OF THE FOLLOWING PACKAGES: jq git wget make gcc build-essential snapd wget ponysay, INSTALLATION OF GO 1.20 via snap + +sudo apt-get update -y +sudo apt-get install jq git wget make gcc build-essential snapd wget -y +snap install go --channel=1.20/stable --classic +snap refresh go --channel=1.20/stable --classic + +export PATH=$PATH:$(go env GOPATH)/bin +add_line_to_file 'export PATH=$PATH:$(go env GOPATH)/bin' ~/.bashrc false + #PONYSAY snap install ponysay ponysay "Installing genesisd from source code with updated genesis_29-2 mainnet!" @@ -161,16 +171,6 @@ else echo "No additional swap space needed." fi -# SYSTEM UPDATE, INSTALLATION OF THE FOLLOWING PACKAGES: jq git wget make gcc build-essential snapd wget ponysay, INSTALLATION OF GO 1.20 via snap - -sudo apt-get update -y -sudo apt-get install jq git wget make gcc build-essential snapd wget -y -snap install go --channel=1.20/stable --classic -snap refresh go --channel=1.20/stable --classic - -export PATH=$PATH:$(go env GOPATH)/bin -add_line_to_file 'export PATH=$PATH:$(go env GOPATH)/bin' ~/.bashrc false - # GLOBAL CHANGE OF OPEN FILE LIMITS add_line_to_file "* - nofile 50000" /etc/security/limits.conf false add_line_to_file "root - nofile 50000" /etc/security/limits.conf false From d0e36942441e4c03b72fd3bd29a4e5509766bcfc Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Mon, 4 Sep 2023 21:26:49 +0200 Subject: [PATCH 04/29] Forgot to move open file limits --- genesisd.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index c3530f7c62..f16cdffe34 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -114,6 +114,12 @@ snap refresh go --channel=1.20/stable --classic export PATH=$PATH:$(go env GOPATH)/bin add_line_to_file 'export PATH=$PATH:$(go env GOPATH)/bin' ~/.bashrc false +# GLOBAL CHANGE OF OPEN FILE LIMITS +add_line_to_file "* - nofile 50000" /etc/security/limits.conf false +add_line_to_file "root - nofile 50000" /etc/security/limits.conf false +add_line_to_file "fs.file-max = 50000" /etc/sysctl.conf false +ulimit -n 50000 + #PONYSAY snap install ponysay ponysay "Installing genesisd from source code with updated genesis_29-2 mainnet!" @@ -171,12 +177,6 @@ else echo "No additional swap space needed." fi -# GLOBAL CHANGE OF OPEN FILE LIMITS -add_line_to_file "* - nofile 50000" /etc/security/limits.conf false -add_line_to_file "root - nofile 50000" /etc/security/limits.conf false -add_line_to_file "fs.file-max = 50000" /etc/sysctl.conf false -ulimit -n 50000 - # BACKUP genesis_29-2 (evmos version) .genesisd cd rsync -r --verbose --exclude 'data' ./.genesisd/ ./.genesisd_backup/ From 432176cb73d3c4572de65f34594379b8c00540ca Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Mon, 4 Sep 2023 21:35:11 +0200 Subject: [PATCH 05/29] Separated the stopping of the genesis services in order to properly calculate swapfile --- genesisd.sh | 62 ++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index f16cdffe34..c7e3095330 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -102,38 +102,11 @@ case "$1" in ;; esac -sleep 15s +echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 10-second window to cancel this action." +sleep 10s -# SYSTEM UPDATE, INSTALLATION OF THE FOLLOWING PACKAGES: jq git wget make gcc build-essential snapd wget ponysay, INSTALLATION OF GO 1.20 via snap - -sudo apt-get update -y -sudo apt-get install jq git wget make gcc build-essential snapd wget -y -snap install go --channel=1.20/stable --classic -snap refresh go --channel=1.20/stable --classic - -export PATH=$PATH:$(go env GOPATH)/bin -add_line_to_file 'export PATH=$PATH:$(go env GOPATH)/bin' ~/.bashrc false - -# GLOBAL CHANGE OF OPEN FILE LIMITS -add_line_to_file "* - nofile 50000" /etc/security/limits.conf false -add_line_to_file "root - nofile 50000" /etc/security/limits.conf false -add_line_to_file "fs.file-max = 50000" /etc/sysctl.conf false -ulimit -n 50000 - -#PONYSAY -snap install ponysay -ponysay "Installing genesisd from source code with updated genesis_29-2 mainnet!" -sleep 5s -ponysay "WARNING: cosmosvisor, evmosd processes will be killed and genesis, genesisd, evmos, evmosd system services will be stopped with this script on the next step. If you have other blockchains running, you might want to delete those parts of the script!" -sleep 20s - -#STOPPING EVMOSD DAEMON AND COSMOVISOR IF IT WAS NOT STOPPED -pkill evmosd -pkill cosmovisor service genesis stop service genesisd stop -service evmos stop -service evmosd stop # ADD ADDITIONAL SWAP (IF NECESSARY) total_ram_kb=$(grep MemAvailable /proc/meminfo | awk '{print $2}') @@ -177,6 +150,37 @@ else echo "No additional swap space needed." fi +sleep 3s + +# SYSTEM UPDATE, INSTALLATION OF THE FOLLOWING PACKAGES: jq git wget make gcc build-essential snapd wget ponysay, INSTALLATION OF GO 1.20 via snap + +sudo apt-get update -y +sudo apt-get install jq git wget make gcc build-essential snapd wget -y +snap install go --channel=1.20/stable --classic +snap refresh go --channel=1.20/stable --classic + +export PATH=$PATH:$(go env GOPATH)/bin +add_line_to_file 'export PATH=$PATH:$(go env GOPATH)/bin' ~/.bashrc false + +# GLOBAL CHANGE OF OPEN FILE LIMITS +add_line_to_file "* - nofile 50000" /etc/security/limits.conf false +add_line_to_file "root - nofile 50000" /etc/security/limits.conf false +add_line_to_file "fs.file-max = 50000" /etc/sysctl.conf false +ulimit -n 50000 + +#PONYSAY +snap install ponysay +ponysay "Installing genesisd from source code with updated genesis_29-2 mainnet!" +sleep 5s +ponysay "WARNING: cosmosvisor, evmosd processes will be killed and evmos, evmosd system services will be stopped with this script on the next step. If you have other blockchains running, you might want to delete those parts of the script!" +sleep 20s + +#STOPPING EVMOSD DAEMON AND COSMOVISOR IF IT WAS NOT STOPPED +pkill evmosd +pkill cosmovisor +service evmos stop +service evmosd stop + # BACKUP genesis_29-2 (evmos version) .genesisd cd rsync -r --verbose --exclude 'data' ./.genesisd/ ./.genesisd_backup/ From 74bf910849f43b9eae56ffeca9fcde8b31e11b64 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Mon, 4 Sep 2023 21:41:19 +0200 Subject: [PATCH 06/29] Added a sleep command after stopping of services --- genesisd.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/genesisd.sh b/genesisd.sh index c7e3095330..8636f49cc8 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -108,6 +108,8 @@ sleep 10s service genesis stop service genesisd stop +sleep 3s + # ADD ADDITIONAL SWAP (IF NECESSARY) total_ram_kb=$(grep MemAvailable /proc/meminfo | awk '{print $2}') total_swap_kb=$(grep SwapFree /proc/meminfo | awk '{print $2}') From 576f0dab3b3f0c4aae7eb029dbe907c9bc090c98 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Mon, 4 Sep 2023 23:34:10 +0200 Subject: [PATCH 07/29] Added useful swap scripts to remove and create genesisd swapfiles --- genesisd_scripts/genesisd_swap_add.sh | 50 ++++++++++++++++++++ genesisd_scripts/genesisd_swap_remove.sh | 40 ++++++++++++++++ genesisd_scripts/genesisd_swap_remove_all.sh | 34 +++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 genesisd_scripts/genesisd_swap_add.sh create mode 100644 genesisd_scripts/genesisd_swap_remove.sh create mode 100644 genesisd_scripts/genesisd_swap_remove_all.sh diff --git a/genesisd_scripts/genesisd_swap_add.sh b/genesisd_scripts/genesisd_swap_add.sh new file mode 100644 index 0000000000..362c2e7b65 --- /dev/null +++ b/genesisd_scripts/genesisd_swap_add.sh @@ -0,0 +1,50 @@ +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + echo " should be the desired size of the swap file in gigabytes (GB)." + exit 1 +fi + +# Validate that the argument is a positive integer +if ! expr "$1" : '^[0-9]\+$' > /dev/null; then + echo "Error: must be a positive integer." + exit 1 +fi + +# ADD ADDITIONAL SWAP (IF NECESSARY) +available_disk_gb=$(df -BG --output=avail / | awk 'NR==2 {print $1}' | tr -d 'G') + +# Calculate additional swap space needed in gigabytes +swap_size_in_gb="$1" + +if [ "$available_disk_gb" -lt "$((swap_size_in_gb))" ]; then + echo "Sorry, you don't have enough space." + exit 1 +fi + +echo "Adding ${swap_size_in_gb}GB of swap space..." + +# Find a suitable name for the new swap file +index=2 +new_swapfile="/genesisd_swapfile" +while [ -e $new_swapfile ]; do + new_swapfile="/genesisd_swapfile_$index" + index=$((index + 1)) +done + +# Create new swap file +fallocate -l ${swap_size_in_gb}G $new_swapfile +chmod 600 $new_swapfile +mkswap $new_swapfile +swapon $new_swapfile + +echo "Additional ${swap_size_in_gb}GB of swap space added in $new_swapfile." + +# Add entry to /etc/fstab to make swapfile persistent +line="$new_swapfile none swap sw 0 0" +file=/etc/fstab +if ! grep -qF "$line" "$file"; then + echo "$line" | sudo tee -a "$file" > /dev/null + echo "Line '$line' added to $file." +else + echo "Line '$line' already exists in $file." +fi \ No newline at end of file diff --git a/genesisd_scripts/genesisd_swap_remove.sh b/genesisd_scripts/genesisd_swap_remove.sh new file mode 100644 index 0000000000..1294b8bcca --- /dev/null +++ b/genesisd_scripts/genesisd_swap_remove.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Check if an argument is provided +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + echo " is the full path to the swap file you wish to remove." + exit 1 +fi + +# Get the provided swap file as an argument +swapfile_to_remove="$1" + +# Check if the swap file starts with '/genesisd_swapfile' +if [ "$(echo "$swapfile_to_remove" | cut -c 1-18)" != "/genesisd_swapfile" ]; then + echo "Error: The specified swap file does not start with '/genesisd_swapfile'." + exit 1 +fi + +# Remove the corresponding entry from /etc/fstab +swapfile_name=$(basename "$swapfile_to_remove") +sed -i "/^\/$swapfile_name /d" /etc/fstab +echo "Removed entry for $swapfile_name from /etc/fstab" + +# Attempt to disable the swap file +swapoff -v "$swapfile_to_remove" + +# Check if the swap file is still listed as active +if swapon --show | grep -q "^$swapfile_to_remove "; then + echo "Swap file $swapfile_to_remove was not removed because it is still in use." +else + # Check if the provided swap file exists + if [ ! -f "$swapfile_to_remove" ]; then + echo "Error: The specified swap file does not exist." + exit 1 + fi + + # Remove the swap file + rm -f "$swapfile_to_remove" + echo "Removed swap file: $swapfile_to_remove" +fi \ No newline at end of file diff --git a/genesisd_scripts/genesisd_swap_remove_all.sh b/genesisd_scripts/genesisd_swap_remove_all.sh new file mode 100644 index 0000000000..78f136984c --- /dev/null +++ b/genesisd_scripts/genesisd_swap_remove_all.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# List all files in the root directory starting with "/genesisd_swapfile" +files_to_remove=$(find / -maxdepth 1 -type f -name 'genesisd_swapfile*') + +# Check if there are any files to remove +if [ -z "$files_to_remove" ]; then + echo "No swap files starting with '/genesisd_swapfile' found in the root directory." +else + # Iterate through each swap file, disable it, and then remove it + for file in $files_to_remove; do + # Attempt to disable the swap file + swapoff -v "$file" + + # Check if the swap file is still listed as active + if swapon --show | grep -q "^$file "; then + echo "Swap file $file was not removed because it is still in use." + else + # Remove the swap file + rm -f "$file" + echo "Removed swap file: $file" + fi + done +fi + + # Remove entries related to these swap files from /etc/fstab +for file in $files_to_remove; do + # Extract the swap file's name (e.g., genesisd_swapfile) + swapfile_name=$(basename "$file") + + # Remove the corresponding line from /etc/fstab + sed -i "/^\/$swapfile_name /d" /etc/fstab + echo "Removed entry for $swapfile_name from /etc/fstab" +done \ No newline at end of file From 49eef1983bbff93fa131f10877901f66656d0201 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Tue, 5 Sep 2023 00:04:58 +0200 Subject: [PATCH 08/29] Forgot to add /bin/bash in genesisd_swap_add.sh --- genesisd_scripts/genesisd_swap_add.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/genesisd_scripts/genesisd_swap_add.sh b/genesisd_scripts/genesisd_swap_add.sh index 362c2e7b65..58e0daa686 100644 --- a/genesisd_scripts/genesisd_swap_add.sh +++ b/genesisd_scripts/genesisd_swap_add.sh @@ -1,3 +1,5 @@ +#!/bin/bash + if [ "$#" -ne 1 ]; then echo "Usage: $0 " echo " should be the desired size of the swap file in gigabytes (GB)." From cb4874272b2b8019d4a1eafdbfc32721d2c517dd Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Tue, 5 Sep 2023 00:05:27 +0200 Subject: [PATCH 09/29] Renamed swap scripts --- genesisd_scripts/{genesisd_swap_add.sh => swap_add.sh} | 0 genesisd_scripts/{genesisd_swap_remove.sh => swap_remove.sh} | 0 .../{genesisd_swap_remove_all.sh => swap_remove_all.sh} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename genesisd_scripts/{genesisd_swap_add.sh => swap_add.sh} (100%) rename genesisd_scripts/{genesisd_swap_remove.sh => swap_remove.sh} (100%) rename genesisd_scripts/{genesisd_swap_remove_all.sh => swap_remove_all.sh} (100%) diff --git a/genesisd_scripts/genesisd_swap_add.sh b/genesisd_scripts/swap_add.sh similarity index 100% rename from genesisd_scripts/genesisd_swap_add.sh rename to genesisd_scripts/swap_add.sh diff --git a/genesisd_scripts/genesisd_swap_remove.sh b/genesisd_scripts/swap_remove.sh similarity index 100% rename from genesisd_scripts/genesisd_swap_remove.sh rename to genesisd_scripts/swap_remove.sh diff --git a/genesisd_scripts/genesisd_swap_remove_all.sh b/genesisd_scripts/swap_remove_all.sh similarity index 100% rename from genesisd_scripts/genesisd_swap_remove_all.sh rename to genesisd_scripts/swap_remove_all.sh From 34971e5a4393eb8dbfa02b5fe63c4cccf088fafb Mon Sep 17 00:00:00 2001 From: ZENODE Date: Tue, 5 Sep 2023 04:25:10 +0200 Subject: [PATCH 10/29] Update swap_add.sh Signed-off-by: ZENODE --- genesisd_scripts/swap_add.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/genesisd_scripts/swap_add.sh b/genesisd_scripts/swap_add.sh index 58e0daa686..ec0ee57ebf 100644 --- a/genesisd_scripts/swap_add.sh +++ b/genesisd_scripts/swap_add.sh @@ -6,18 +6,15 @@ if [ "$#" -ne 1 ]; then exit 1 fi +swap_size_in_gb="$1" + # Validate that the argument is a positive integer -if ! expr "$1" : '^[0-9]\+$' > /dev/null; then +if ! expr "$swap_size_in_gb" : '^[0-9]\+$' > /dev/null; then echo "Error: must be a positive integer." exit 1 fi -# ADD ADDITIONAL SWAP (IF NECESSARY) available_disk_gb=$(df -BG --output=avail / | awk 'NR==2 {print $1}' | tr -d 'G') - -# Calculate additional swap space needed in gigabytes -swap_size_in_gb="$1" - if [ "$available_disk_gb" -lt "$((swap_size_in_gb))" ]; then echo "Sorry, you don't have enough space." exit 1 @@ -49,4 +46,4 @@ if ! grep -qF "$line" "$file"; then echo "Line '$line' added to $file." else echo "Line '$line' already exists in $file." -fi \ No newline at end of file +fi From bb4eb5e9a83620a849d3d6e35c48c0741b8e5e73 Mon Sep 17 00:00:00 2001 From: ZENODE Date: Wed, 13 Sep 2023 16:43:32 +0200 Subject: [PATCH 11/29] Set DefaultPowerReduction in app.go Signed-off-by: ZENODE --- app/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.go b/app/app.go index 066eff94a4..2322af9e24 100644 --- a/app/app.go +++ b/app/app.go @@ -212,6 +212,7 @@ func init() { } DefaultNodeHome = filepath.Join(userHomeDir, "."+Name+"d") + sdk.DefaultPowerReduction = sdk.NewIntFromUint64(1000000000000000000) } // GenModuleBasics generate basic module manager according to experimental flag From e4d26c759e0160d0eb603b841880776e16925bd9 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:01:32 +0200 Subject: [PATCH 12/29] Script changes and flags added --- genesisd-crisis.service | 15 +++++++++ genesisd.service | 2 +- genesisd.sh | 68 +++++++++++++++++++++++++++++++++++------ 3 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 genesisd-crisis.service diff --git a/genesisd-crisis.service b/genesisd-crisis.service new file mode 100644 index 0000000000..dce100b552 --- /dev/null +++ b/genesisd-crisis.service @@ -0,0 +1,15 @@ +[Unit] +Description=genesisd daemon +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/root +ExecStart=/root/go/bin/genesisd start --x-crisis-skip-assert-invariants --log_level info +Restart=on-failure +RestartSec=60 +LimitNOFILE=50000 + +[Install] +WantedBy=multi-user.target diff --git a/genesisd.service b/genesisd.service index dce100b552..a8541f775d 100644 --- a/genesisd.service +++ b/genesisd.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=root WorkingDirectory=/root -ExecStart=/root/go/bin/genesisd start --x-crisis-skip-assert-invariants --log_level info +ExecStart=/root/go/bin/genesisd start --log_level info Restart=on-failure RestartSec=60 LimitNOFILE=50000 diff --git a/genesisd.sh b/genesisd.sh index 8636f49cc8..281f0326e5 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -62,15 +62,42 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi +# Initialize flags to false +crisis_skip=false +skip_state_download=false +reset_priv_val_state=false + +for arg in "$@"; do + case "$arg" in + --crisis-skip) + crisis_skip=true + ;; + --skip-state-download) + skip_state_download=true + ;; + --reset-priv-val-state) + reset_priv_val_state=true + ;; + *) + # Handle other arguments or flags here + ;; + esac +done + if [ "$#" -lt 1 ]; then echo "Usage: $0 [moniker]" echo " should be either 'upgrade' or 'init'" + echo "" + echo " Options:" + echo " --crisis-skip Makes sure that genesisd starts with the --x-crisis-skip-assert-invariants flag (default: false)" + echo " --skip-state-download Skips downloading the genesis.json file, only do this if you're certain to have the correct state file already (default: false)" + echo " --reset-priv-val-state Resets data/priv_val_state.json file [UNSAFE] (default: false)" exit 1 fi case "$1" in "upgrade") - if [ "$#" -eq 1 ]; then + if [ "$#" -eq 1 ] || ([ "$#" -ge 2 ] && [[ "$2" == --* ]]); then moniker=$(grep "moniker" ~/.genesisd/config/config.toml | cut -d'=' -f2 | tr -d '[:space:]"') if [ -z "$moniker" ]; then @@ -79,7 +106,7 @@ case "$1" in fi echo "Upgrade mode with moniker from previous configuration: $moniker" - elif [ "$#" -eq 2 ]; then + elif [ "$#" -ge 2 ]; then moniker="$2" echo "Upgrade mode with moniker: $moniker" else @@ -88,7 +115,12 @@ case "$1" in fi ;; "init") - if [ "$#" -eq 2 ]; then + if [ "$#" -ge 2 ]; then + if [[ "$2" == --* ]]; then + echo "Missing or invalid argument for 'init' mode. Usage: $0 init " + exit 1 + fi + moniker="$2" echo "Init mode with moniker: $moniker" else @@ -102,6 +134,10 @@ case "$1" in ;; esac +$crisis_skip && echo "o Will add the '--x-crisis-skip-assert-invariants'-flag to the genesisd.service (--crisis-skip: $crisis_skip)" +$skip_state_download && echo "o Will skip downloading the genesis.json file (--skip-state-download: $skip_state_download)" +$reset_priv_val_state && echo "o Will reset the data/priv_val_state.json file [UNSAFE] (--reset-priv-val-state: $reset_priv_val_state)" +echo "" echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 10-second window to cancel this action." sleep 10s @@ -186,6 +222,10 @@ service evmosd stop # BACKUP genesis_29-2 (evmos version) .genesisd cd rsync -r --verbose --exclude 'data' ./.genesisd/ ./.genesisd_backup/ +if ! $reset_priv_val_state; then + mkdir -p ./.genesisd_backup/data + cp ./.genesisd/data/priv_val_state.json ./.genesisd_backup/data/priv_val_state.json +fi # DELETING OF .genesisd FOLDER (PREVIOUS INSTALLATIONS) cd @@ -220,15 +260,21 @@ if [ "$1" = "init" ]; then fi #IMPORTING GENESIS STATE -cd -cd .genesisd/config -rm -r genesis.json -wget http://135.181.135.29/genesisd/genesis.json +if ! $skip_state_download; then + cd + cd .genesisd/config + rm -r genesis.json + wget http://135.181.135.29/genesisd/genesis.json +fi cd # RESET TO IMPORTED genesis.json genesisd tendermint unsafe-reset-all +if ! $reset_priv_val_state; then + cp ./.genesisd_backup/data/priv_val_state.json ./.genesisd/data/priv_val_state.json +fi + # CONFIG FILES cd ~/.genesisd/config @@ -241,10 +287,14 @@ sed -i "s/moniker = \"\"/moniker = \"$moniker\"/" config.toml echo "Moniker value set to: $moniker" # SETTING genesisd AS A SYSTEMD SERVICE -sudo cp "$repo_dir/genesisd.service" /etc/systemd/system/genesisd.service +if $crisis_skip; then + sudo cp "$repo_dir/genesisd-crisis.service" /etc/systemd/system/genesisd.service +else + sudo cp "$repo_dir/genesisd.service" /etc/systemd/system/genesisd.service +fi + systemctl daemon-reload systemctl enable genesisd -# echo "All set!" sleep 3s # STARTING NODE From 40775f5c82daa1d0afd6d406ef604e23dd11f2ad Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:07:48 +0200 Subject: [PATCH 13/29] Double brackets didn't work --- genesisd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesisd.sh b/genesisd.sh index 281f0326e5..46770b32e9 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -97,7 +97,7 @@ fi case "$1" in "upgrade") - if [ "$#" -eq 1 ] || ([ "$#" -ge 2 ] && [[ "$2" == --* ]]); then + if [ "$#" -eq 1 ] || ([ "$#" -ge 2 ] && [ "${2:0:2}" == "--" ]); then moniker=$(grep "moniker" ~/.genesisd/config/config.toml | cut -d'=' -f2 | tr -d '[:space:]"') if [ -z "$moniker" ]; then From 7321349f6f1203a3206ff9e23823b897cb4461e1 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:09:54 +0200 Subject: [PATCH 14/29] Syntax error --- genesisd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesisd.sh b/genesisd.sh index 46770b32e9..8907cc0c10 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -97,7 +97,7 @@ fi case "$1" in "upgrade") - if [ "$#" -eq 1 ] || ([ "$#" -ge 2 ] && [ "${2:0:2}" == "--" ]); then + if [ "$#" -eq 1 ] || { [ "$#" -ge 2 ] && [ "${2:0:2}" == "--" ]; }; then moniker=$(grep "moniker" ~/.genesisd/config/config.toml | cut -d'=' -f2 | tr -d '[:space:]"') if [ -z "$moniker" ]; then From f6144b8f172cfcd060d258ac1448a77acc056e67 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:24:45 +0200 Subject: [PATCH 15/29] Wasn't POSIX sh compatible --- genesisd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesisd.sh b/genesisd.sh index 8907cc0c10..304e9b2d9d 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -97,7 +97,7 @@ fi case "$1" in "upgrade") - if [ "$#" -eq 1 ] || { [ "$#" -ge 2 ] && [ "${2:0:2}" == "--" ]; }; then + if [ "$#" -eq 1 ] || { [ "$#" -ge 2 ] && [ "$(echo "$2" | cut -c 1-2)" = "--" ]; }; then moniker=$(grep "moniker" ~/.genesisd/config/config.toml | cut -d'=' -f2 | tr -d '[:space:]"') if [ -z "$moniker" ]; then From 354470480d34f9bdae3de3c90ff51ef26099d644 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:27:11 +0200 Subject: [PATCH 16/29] POSIX issue --- genesisd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesisd.sh b/genesisd.sh index 304e9b2d9d..a31fc0784b 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -116,7 +116,7 @@ case "$1" in ;; "init") if [ "$#" -ge 2 ]; then - if [[ "$2" == --* ]]; then + if [ "$(echo "$2" | cut -c 1-2)" = "--" ]; then echo "Missing or invalid argument for 'init' mode. Usage: $0 init " exit 1 fi From 131b0440498544d24a8a2aaf5ca8c1cd5b4e9b5b Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:29:54 +0200 Subject: [PATCH 17/29] Added extra info considering priv_val_state --- genesisd.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/genesisd.sh b/genesisd.sh index a31fc0784b..b6bf6dce14 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -137,6 +137,8 @@ esac $crisis_skip && echo "o Will add the '--x-crisis-skip-assert-invariants'-flag to the genesisd.service (--crisis-skip: $crisis_skip)" $skip_state_download && echo "o Will skip downloading the genesis.json file (--skip-state-download: $skip_state_download)" $reset_priv_val_state && echo "o Will reset the data/priv_val_state.json file [UNSAFE] (--reset-priv-val-state: $reset_priv_val_state)" +!$reset_priv_val_state && echo "o Will preserve the data/priv_val_state.json (--reset-priv-val-state: $reset_priv_val_state)" + echo "" echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 10-second window to cancel this action." sleep 10s From 0920a45307fd98496c08229695578820124549e3 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:31:32 +0200 Subject: [PATCH 18/29] Forgot space at negation --- genesisd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesisd.sh b/genesisd.sh index b6bf6dce14..d288f53383 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -137,7 +137,7 @@ esac $crisis_skip && echo "o Will add the '--x-crisis-skip-assert-invariants'-flag to the genesisd.service (--crisis-skip: $crisis_skip)" $skip_state_download && echo "o Will skip downloading the genesis.json file (--skip-state-download: $skip_state_download)" $reset_priv_val_state && echo "o Will reset the data/priv_val_state.json file [UNSAFE] (--reset-priv-val-state: $reset_priv_val_state)" -!$reset_priv_val_state && echo "o Will preserve the data/priv_val_state.json (--reset-priv-val-state: $reset_priv_val_state)" +! $reset_priv_val_state && echo "o Will preserve the data/priv_val_state.json (--reset-priv-val-state: $reset_priv_val_state)" echo "" echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 10-second window to cancel this action." From ee2bf9b43d556b16b31a0e3afd674c1c81c3a113 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 21:33:33 +0200 Subject: [PATCH 19/29] fixed priv_val_state.json to priv_validator_state.json --- genesisd.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index d288f53383..ce741f1092 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -91,7 +91,7 @@ if [ "$#" -lt 1 ]; then echo " Options:" echo " --crisis-skip Makes sure that genesisd starts with the --x-crisis-skip-assert-invariants flag (default: false)" echo " --skip-state-download Skips downloading the genesis.json file, only do this if you're certain to have the correct state file already (default: false)" - echo " --reset-priv-val-state Resets data/priv_val_state.json file [UNSAFE] (default: false)" + echo " --reset-priv-val-state Resets data/priv_validator_state.json file [UNSAFE] (default: false)" exit 1 fi @@ -136,8 +136,8 @@ esac $crisis_skip && echo "o Will add the '--x-crisis-skip-assert-invariants'-flag to the genesisd.service (--crisis-skip: $crisis_skip)" $skip_state_download && echo "o Will skip downloading the genesis.json file (--skip-state-download: $skip_state_download)" -$reset_priv_val_state && echo "o Will reset the data/priv_val_state.json file [UNSAFE] (--reset-priv-val-state: $reset_priv_val_state)" -! $reset_priv_val_state && echo "o Will preserve the data/priv_val_state.json (--reset-priv-val-state: $reset_priv_val_state)" +$reset_priv_val_state && echo "o Will reset the data/priv_validator_state.json file [UNSAFE] (--reset-priv-val-state: $reset_priv_val_state)" +! $reset_priv_val_state && echo "o Will preserve the data/priv_validator_state.json (--reset-priv-val-state: $reset_priv_val_state)" echo "" echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 10-second window to cancel this action." @@ -226,7 +226,7 @@ cd rsync -r --verbose --exclude 'data' ./.genesisd/ ./.genesisd_backup/ if ! $reset_priv_val_state; then mkdir -p ./.genesisd_backup/data - cp ./.genesisd/data/priv_val_state.json ./.genesisd_backup/data/priv_val_state.json + cp ./.genesisd/data/priv_validator_state.json ./.genesisd_backup/data/priv_validator_state.json fi # DELETING OF .genesisd FOLDER (PREVIOUS INSTALLATIONS) @@ -274,7 +274,7 @@ cd genesisd tendermint unsafe-reset-all if ! $reset_priv_val_state; then - cp ./.genesisd_backup/data/priv_val_state.json ./.genesisd/data/priv_val_state.json + cp ./.genesisd_backup/data/priv_validator_state.json ./.genesisd/data/priv_validator_state.json fi # CONFIG FILES From bb469cc06b05a6ba056d4186ae009413467900f0 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 22:00:29 +0200 Subject: [PATCH 20/29] Made backup dir name based on timestamp --- genesisd.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index ce741f1092..71a1c71aeb 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -36,6 +36,7 @@ moniker="" minimum_combined_gb=150 disk_headroom_gb=50 repo_dir=$(cd "$(dirname "$0")" && pwd) +backup_dir=".genesisd_backup_$(date +"%Y%m%d%H%M%S")" # Function to add a line to a file if it doesn't already exist (to prevent duplicates) # Usage: add_line_to_file "line" file [use_sudo] @@ -223,10 +224,10 @@ service evmosd stop # BACKUP genesis_29-2 (evmos version) .genesisd cd -rsync -r --verbose --exclude 'data' ./.genesisd/ ./.genesisd_backup/ +rsync -r --verbose --exclude 'data' ./.genesisd/ ./"$backup_dir"/ if ! $reset_priv_val_state; then - mkdir -p ./.genesisd_backup/data - cp ./.genesisd/data/priv_validator_state.json ./.genesisd_backup/data/priv_validator_state.json + mkdir -p ./"$backup_dir"/data + cp ./.genesisd/data/priv_validator_state.json ./"$backup_dir"/data/priv_validator_state.json fi # DELETING OF .genesisd FOLDER (PREVIOUS INSTALLATIONS) @@ -240,7 +241,7 @@ make install # COPY .genesisd_backup FOLDER to .genesisd FOLDER, EXCLUDE data cd -rsync -r --verbose --exclude 'data' ./.genesisd_backup/ ./.genesisd/ +rsync -r --verbose --exclude 'data' ./"$backup_dir"/ ./.genesisd/ # SETTING UP THE NEW chain-id in CONFIG genesisd config chain-id genesis_29-2 @@ -274,7 +275,7 @@ cd genesisd tendermint unsafe-reset-all if ! $reset_priv_val_state; then - cp ./.genesisd_backup/data/priv_validator_state.json ./.genesisd/data/priv_validator_state.json + cp ./"$backup_dir"/data/priv_validator_state.json ./.genesisd/data/priv_validator_state.json fi # CONFIG FILES From e9df678809b28c47ff133e145ea0e5518c5d4c65 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 22:15:53 +0200 Subject: [PATCH 21/29] Echo more info concerning priv_validator_state.json backup/restore --- genesisd.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index 71a1c71aeb..44634eb17d 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -227,7 +227,9 @@ cd rsync -r --verbose --exclude 'data' ./.genesisd/ ./"$backup_dir"/ if ! $reset_priv_val_state; then mkdir -p ./"$backup_dir"/data - cp ./.genesisd/data/priv_validator_state.json ./"$backup_dir"/data/priv_validator_state.json + if cp ./.genesisd/data/priv_validator_state.json ./"$backup_dir"/data/priv_validator_state.json; then + echo "Backed up priv_validator_state.json file" + fi fi # DELETING OF .genesisd FOLDER (PREVIOUS INSTALLATIONS) @@ -275,7 +277,9 @@ cd genesisd tendermint unsafe-reset-all if ! $reset_priv_val_state; then - cp ./"$backup_dir"/data/priv_validator_state.json ./.genesisd/data/priv_validator_state.json + if cp ./"$backup_folder"/data/priv_validator_state.json ./.genesisd/data/priv_validator_state.json; then + echo "Restored backed up priv_validator_state.json file" + fi fi # CONFIG FILES From 7c27a6ecb080a4555f39d8386c8fb6773e168784 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 22:27:31 +0200 Subject: [PATCH 22/29] Added no-service and no-start flags --- genesisd.sh | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index 44634eb17d..013c4cce8d 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -67,6 +67,8 @@ fi crisis_skip=false skip_state_download=false reset_priv_val_state=false +no_service=false +no_start=false for arg in "$@"; do case "$arg" in @@ -79,6 +81,12 @@ for arg in "$@"; do --reset-priv-val-state) reset_priv_val_state=true ;; + --no-service) + no_service=true + ;; + --no-start) + no_start=true + ;; *) # Handle other arguments or flags here ;; @@ -93,6 +101,8 @@ if [ "$#" -lt 1 ]; then echo " --crisis-skip Makes sure that genesisd starts with the --x-crisis-skip-assert-invariants flag (default: false)" echo " --skip-state-download Skips downloading the genesis.json file, only do this if you're certain to have the correct state file already (default: false)" echo " --reset-priv-val-state Resets data/priv_validator_state.json file [UNSAFE] (default: false)" + echo " --no-service This prevents the genesisd service from being made (default: false)" + echo " --no-start This prevents the genesisd service from starting at the end of the script (default: false)" exit 1 fi @@ -294,17 +304,19 @@ sed -i "s/moniker = \"\"/moniker = \"$moniker\"/" config.toml echo "Moniker value set to: $moniker" # SETTING genesisd AS A SYSTEMD SERVICE -if $crisis_skip; then - sudo cp "$repo_dir/genesisd-crisis.service" /etc/systemd/system/genesisd.service -else - sudo cp "$repo_dir/genesisd.service" /etc/systemd/system/genesisd.service -fi +if ! $no_service; then + if $crisis_skip; then + sudo cp "$repo_dir/genesisd-crisis.service" /etc/systemd/system/genesisd.service + else + sudo cp "$repo_dir/genesisd.service" /etc/systemd/system/genesisd.service + fi -systemctl daemon-reload -systemctl enable genesisd -sleep 3s + systemctl daemon-reload + systemctl enable genesisd + sleep 3s -# STARTING NODE + # STARTING NODE + if ! $no_start; then cat << "EOF" \\ \\_ @@ -313,8 +325,10 @@ cat << "EOF" Node start EOF -sleep 5s -systemctl start genesisd + sleep 5s + systemctl start genesisd + fi +fi # genesisd start ponysay "genesisd node service started, you may try *journalctl -fu genesisd -ocat* or *service genesisd status* command to see it! Welcome to GenesisL1 blockchain!" From 0b0290a97be6dfaa5519ff5e7d025068e7e372e0 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 22:32:02 +0200 Subject: [PATCH 23/29] Added info considering no_service and no_start --- genesisd.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/genesisd.sh b/genesisd.sh index 013c4cce8d..6b1c5e3bc8 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -149,6 +149,10 @@ $crisis_skip && echo "o Will add the '--x-crisis-skip-assert-invariants'-flag to $skip_state_download && echo "o Will skip downloading the genesis.json file (--skip-state-download: $skip_state_download)" $reset_priv_val_state && echo "o Will reset the data/priv_validator_state.json file [UNSAFE] (--reset-priv-val-state: $reset_priv_val_state)" ! $reset_priv_val_state && echo "o Will preserve the data/priv_validator_state.json (--reset-priv-val-state: $reset_priv_val_state)" +$no_service && echo "o Will skip installing genesisd as a service (--no-service: $no_service)" +if ! $no_service && $no_start; then + echo "o Will skip starting the genesisd service at the end of the script (--no-start: $no_start)" +fi echo "" echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 10-second window to cancel this action." From a3c615993719654b45852808aaab7370b1c3f4c0 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 22:40:50 +0200 Subject: [PATCH 24/29] Fixed ponysay's and bugfix --- genesisd.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index 6b1c5e3bc8..52102add9d 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -291,7 +291,7 @@ cd genesisd tendermint unsafe-reset-all if ! $reset_priv_val_state; then - if cp ./"$backup_folder"/data/priv_validator_state.json ./.genesisd/data/priv_validator_state.json; then + if cp ./"$backup_dir"/data/priv_validator_state.json ./.genesisd/data/priv_validator_state.json; then echo "Restored backed up priv_validator_state.json file" fi fi @@ -331,8 +331,10 @@ EOF sleep 5s systemctl start genesisd + ponysay "genesisd node service started, you may try *journalctl -fu genesisd -ocat* or *service genesisd status* command to see it! Welcome to GenesisL1 blockchain!" fi -fi -# genesisd start -ponysay "genesisd node service started, you may try *journalctl -fu genesisd -ocat* or *service genesisd status* command to see it! Welcome to GenesisL1 blockchain!" + ponysay "genesisd node service installed, use *service genesisd start* to start it! Welcome to GenesisL1 blockchain!" +else + ponysay "genesisd node is ready, use *service genesisd start* to start it! Welcome to GenesisL1 blockchain!" +fi \ No newline at end of file From 452fb020eab23208b160e6c64009300a622e03e1 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 23:07:36 +0200 Subject: [PATCH 25/29] Made sure that priv_validator_state.json is always backed up, but restoring is based on flag --- genesisd.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index 52102add9d..dd426942b6 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -239,11 +239,9 @@ service evmosd stop # BACKUP genesis_29-2 (evmos version) .genesisd cd rsync -r --verbose --exclude 'data' ./.genesisd/ ./"$backup_dir"/ -if ! $reset_priv_val_state; then - mkdir -p ./"$backup_dir"/data - if cp ./.genesisd/data/priv_validator_state.json ./"$backup_dir"/data/priv_validator_state.json; then - echo "Backed up priv_validator_state.json file" - fi +mkdir -p ./"$backup_dir"/data +if cp ./.genesisd/data/priv_validator_state.json ./"$backup_dir"/data/priv_validator_state.json; then + echo "Backed up priv_validator_state.json file" fi # DELETING OF .genesisd FOLDER (PREVIOUS INSTALLATIONS) From 3aed0aa254acb6ccb880b246dcae3ad887394bae Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 23:14:37 +0200 Subject: [PATCH 26/29] Misplaced ponysay message --- genesisd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index dd426942b6..962b9fdd80 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -330,9 +330,9 @@ EOF sleep 5s systemctl start genesisd ponysay "genesisd node service started, you may try *journalctl -fu genesisd -ocat* or *service genesisd status* command to see it! Welcome to GenesisL1 blockchain!" + else + ponysay "genesisd node service installed, use *service genesisd start* to start it! Welcome to GenesisL1 blockchain!" fi - - ponysay "genesisd node service installed, use *service genesisd start* to start it! Welcome to GenesisL1 blockchain!" else ponysay "genesisd node is ready, use *service genesisd start* to start it! Welcome to GenesisL1 blockchain!" fi \ No newline at end of file From 76651abe80e515dd6bb62d6573fdbae60165caf1 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 23:30:52 +0200 Subject: [PATCH 27/29] Refactoring --- genesisd.sh | 104 ++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index 962b9fdd80..c24f5e48aa 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -32,66 +32,24 @@ THIS IS AN UPGRADE TO COSMOS SDK V0.46.15 BASED ON CRONOS RELEASE SOURCE CODE, T EOF -moniker="" +# User-configurable variables minimum_combined_gb=150 disk_headroom_gb=50 repo_dir=$(cd "$(dirname "$0")" && pwd) backup_dir=".genesisd_backup_$(date +"%Y%m%d%H%M%S")" -# Function to add a line to a file if it doesn't already exist (to prevent duplicates) -# Usage: add_line_to_file "line" file [use_sudo] -add_line_to_file() { - local line="$1" - local file="$2" - local use_sudo="$3" - - if ! grep -qF "$line" "$file"; then - if $use_sudo; then - echo "$line" | sudo tee -a "$file" > /dev/null - else - echo "$line" >> "$file" - fi - - echo "Line '$line' added to $file." - else - echo "Line '$line' already exists in $file." - fi -} - -if [ "$(id -u)" -ne 0 ]; then - echo "This script must be run as the root user." - exit 1 -fi - -# Initialize flags to false +# Fixed/default variables (do not modify) +moniker="" crisis_skip=false skip_state_download=false reset_priv_val_state=false no_service=false no_start=false -for arg in "$@"; do - case "$arg" in - --crisis-skip) - crisis_skip=true - ;; - --skip-state-download) - skip_state_download=true - ;; - --reset-priv-val-state) - reset_priv_val_state=true - ;; - --no-service) - no_service=true - ;; - --no-start) - no_start=true - ;; - *) - # Handle other arguments or flags here - ;; - esac -done +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as the root user." + exit 1 +fi if [ "$#" -lt 1 ]; then echo "Usage: $0 [moniker]" @@ -145,6 +103,30 @@ case "$1" in ;; esac +# Process command-line arguments and set corresponding flags +for arg in "$@"; do + case "$arg" in + --crisis-skip) + crisis_skip=true + ;; + --skip-state-download) + skip_state_download=true + ;; + --reset-priv-val-state) + reset_priv_val_state=true + ;; + --no-service) + no_service=true + ;; + --no-start) + no_start=true + ;; + *) + # Handle other arguments or flags here + ;; + esac +done + $crisis_skip && echo "o Will add the '--x-crisis-skip-assert-invariants'-flag to the genesisd.service (--crisis-skip: $crisis_skip)" $skip_state_download && echo "o Will skip downloading the genesis.json file (--skip-state-download: $skip_state_download)" $reset_priv_val_state && echo "o Will reset the data/priv_validator_state.json file [UNSAFE] (--reset-priv-val-state: $reset_priv_val_state)" @@ -155,14 +137,34 @@ if ! $no_service && $no_start; then fi echo "" -echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 10-second window to cancel this action." -sleep 10s +echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 20-second window to cancel this action." +sleep 20s service genesis stop service genesisd stop sleep 3s +# Function to add a line to a file if it doesn't already exist (to prevent duplicates) +# Usage: add_line_to_file "line" file [use_sudo] +add_line_to_file() { + local line="$1" + local file="$2" + local use_sudo="$3" + + if ! grep -qF "$line" "$file"; then + if $use_sudo; then + echo "$line" | sudo tee -a "$file" > /dev/null + else + echo "$line" >> "$file" + fi + + echo "Line '$line' added to $file." + else + echo "Line '$line' already exists in $file." + fi +} + # ADD ADDITIONAL SWAP (IF NECESSARY) total_ram_kb=$(grep MemAvailable /proc/meminfo | awk '{print $2}') total_swap_kb=$(grep SwapFree /proc/meminfo | awk '{print $2}') From 31baf66e8abb204557f1e6be85e63ae9642cbd0c Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 23:38:01 +0200 Subject: [PATCH 28/29] Refactoring --- genesisd.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/genesisd.sh b/genesisd.sh index c24f5e48aa..986e5625cf 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -137,7 +137,7 @@ if ! $no_service && $no_start; then fi echo "" -echo "Please note that the Genesis Daemon will be halted before proceeding. You will have a 20-second window to cancel this action." +echo "Please note that the Genesis daemon will be halted before proceeding. You will have a 20-second window to cancel this action." sleep 20s service genesis stop @@ -145,8 +145,7 @@ service genesisd stop sleep 3s -# Function to add a line to a file if it doesn't already exist (to prevent duplicates) -# Usage: add_line_to_file "line" file [use_sudo] +# Function: adds a line to a file if it doesn't already exist (to prevent duplicates) add_line_to_file() { local line="$1" local file="$2" From bc181c5833142eebcc0f1f89335394338af584c6 Mon Sep 17 00:00:00 2001 From: zenodeapp Date: Wed, 13 Sep 2023 23:38:52 +0200 Subject: [PATCH 29/29] Moved repo dir to fixed variables --- genesisd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genesisd.sh b/genesisd.sh index 986e5625cf..278ae73a58 100644 --- a/genesisd.sh +++ b/genesisd.sh @@ -35,11 +35,11 @@ EOF # User-configurable variables minimum_combined_gb=150 disk_headroom_gb=50 -repo_dir=$(cd "$(dirname "$0")" && pwd) backup_dir=".genesisd_backup_$(date +"%Y%m%d%H%M%S")" # Fixed/default variables (do not modify) moniker="" +repo_dir=$(cd "$(dirname "$0")" && pwd) crisis_skip=false skip_state_download=false reset_priv_val_state=false