From 73d09d0654d756fb2065bfecb93ab415cddb2bbe Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 17:29:31 -0800 Subject: [PATCH 01/18] pick network --- tools/installer/full-node.sh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 0804bc278..b3cbaddf9 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -25,6 +25,22 @@ check_root() { # Function to get user input get_user_input() { + # Ask user which network to install + echo "Which network would you like to install?" + echo "1) testnet-alpha" + echo "2) testnet-beta" + echo "3) mainnet" + read -p "Enter your choice (1-3): " network_choice + + case $network_choice in + 1) NETWORK="testnet-alpha" ;; + 2) NETWORK="testnet-beta" ;; + 3) NETWORK="mainnet" ;; + *) print_color $RED "Invalid choice. Exiting."; exit 1 ;; + esac + + print_color $GREEN "You have chosen to install the $NETWORK network." + read -p "Enter the desired username to run poktrolld (default: poktroll): " POKTROLL_USER POKTROLL_USER=${POKTROLL_USER:-poktroll} @@ -34,8 +50,13 @@ get_user_input() { read -p "Enter the chain-id (default: poktroll): " CHAIN_ID CHAIN_ID=${CHAIN_ID:-"poktroll"} + # Set URLs based on the chosen network + BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/$NETWORK" + SEEDS_URL="$BASE_URL/seeds" + GENESIS_URL="$BASE_URL/genesis.json" + INIT_VERSION_URL="$BASE_URL/init-version" + # Fetch seeds from the provided URL - SEEDS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/alpha/testnet-validated.seeds" SEEDS=$(curl -s "$SEEDS_URL") if [ -z "$SEEDS" ]; then print_color $RED "Failed to fetch seeds from $SEEDS_URL. Please check your internet connection and try again." @@ -160,7 +181,6 @@ configure_poktrolld() { print_color $YELLOW "Configuring Poktrolld..." # Ask for confirmation to download the genesis file - GENESIS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/alpha/testnet-validated.json" print_color $YELLOW "The script will download the genesis file from:" print_color $YELLOW "$GENESIS_URL" read -p "Are you OK with downloading and using this genesis file? (y/N): " confirm_genesis @@ -235,7 +255,7 @@ main() { setup_poktrolld configure_poktrolld setup_systemd - print_color $GREEN "Poktroll Full Node installation completed successfully!" + print_color $GREEN "Poktroll Full Node installation for $NETWORK completed successfully!" print_color $YELLOW "You can check the status of your node with: sudo systemctl status cosmovisor.service" print_color $YELLOW "View logs with: sudo journalctl -u cosmovisor.service -f" } From 1054e190d8710cacce1eb1b1ae75f878e6004b87 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 17:37:27 -0800 Subject: [PATCH 02/18] use app_version instead of init version --- tools/installer/full-node.sh | 55 +++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index b3cbaddf9..4700ef6e4 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -23,6 +23,26 @@ check_root() { fi } +# Function to install jq if not installed +install_jq() { + if ! command -v jq &> /dev/null; then + print_color $YELLOW "Installing jq..." + if [ -f /etc/debian_version ]; then + apt-get update + apt-get install -y jq + elif [ -f /etc/redhat-release ]; then + yum update -y + yum install -y jq + else + print_color $RED "Unsupported distribution. Please install jq manually." + exit 1 + fi + print_color $GREEN "jq installed successfully." + else + print_color $YELLOW "jq is already installed." + fi +} + # Function to get user input get_user_input() { # Ask user which network to install @@ -54,7 +74,6 @@ get_user_input() { BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/$NETWORK" SEEDS_URL="$BASE_URL/seeds" GENESIS_URL="$BASE_URL/genesis.json" - INIT_VERSION_URL="$BASE_URL/init-version" # Fetch seeds from the provided URL SEEDS=$(curl -s "$SEEDS_URL") @@ -146,6 +165,7 @@ EOF print_color $GREEN "Cosmovisor set up successfully." } + # Function to download and set up Poktrolld setup_poktrolld() { print_color $YELLOW "Setting up Poktrolld..." @@ -159,9 +179,21 @@ setup_poktrolld() { exit 1 fi - # Get the version genesis started from. We can't just use `latest` as the new binary won't sync from genesis. - # We need to start syncing from scratch using the version that was used when the network started. - POKTROLLD_VERSION=$(curl -s https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/alpha/testnet-validated.init-version) + # Download genesis.json once and store it + GENESIS_FILE="/tmp/genesis.json" + curl -s -o "$GENESIS_FILE" "$GENESIS_URL" + if [ $? -ne 0 ]; then + print_color $RED "Failed to download genesis file. Please check your internet connection and try again." + exit 1 + fi + + # Extract the version from genesis.json using jq + POKTROLLD_VERSION=$(jq -r '.app_version' < "$GENESIS_FILE") + + if [ -z "$POKTROLLD_VERSION" ]; then + print_color $RED "Failed to extract version information from genesis file." + exit 1 + fi # Use the direct download link for the correct release RELEASE_URL="https://github.com/pokt-network/poktroll/releases/download/${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" @@ -180,12 +212,12 @@ EOF configure_poktrolld() { print_color $YELLOW "Configuring Poktrolld..." - # Ask for confirmation to download the genesis file - print_color $YELLOW "The script will download the genesis file from:" + # Ask for confirmation to use the downloaded genesis file + print_color $YELLOW "The script has downloaded the genesis file from:" print_color $YELLOW "$GENESIS_URL" - read -p "Are you OK with downloading and using this genesis file? (y/N): " confirm_genesis + read -p "Are you OK with using this genesis file? (y/N): " confirm_genesis if [[ ! $confirm_genesis =~ ^[Yy] ]]; then - print_color $RED "Genesis file download cancelled. Exiting." + print_color $RED "Genesis file usage cancelled. Exiting." exit 1 fi @@ -197,11 +229,7 @@ configure_poktrolld() { echo "Poktrolld version: \$POKTROLLD_VERSION" poktrolld init "$NODE_MONIKER" --chain-id="$CHAIN_ID" --home=\$HOME/.poktroll - curl -o \$HOME/.poktroll/config/genesis.json $GENESIS_URL - if [ \$? -ne 0 ]; then - echo "Failed to download genesis file. Please check your internet connection and try again." - exit 1 - fi + cp "$GENESIS_FILE" \$HOME/.poktroll/config/genesis.json sed -i -e "s|^seeds *=.*|seeds = \"$SEEDS\"|" \$HOME/.poktroll/config/config.toml EOF if [ $? -eq 0 ]; then @@ -247,6 +275,7 @@ EOF main() { print_color $GREEN "Welcome to the Poktroll Full Node Install Script!" check_root + install_jq get_user_input create_user install_dependencies From 54a0c46cdf896bd2ba3427b19a122350d8d1eb2e Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 18:06:04 -0800 Subject: [PATCH 03/18] use custom branch --- tools/installer/full-node.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 4700ef6e4..fc37ee6da 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -8,6 +8,9 @@ GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color +# Add the branch constant here +GENESIS_BRANCH="add-beta-seeds-rename-dirs" + # Function to print colored output print_color() { COLOR=$1 @@ -70,8 +73,8 @@ get_user_input() { read -p "Enter the chain-id (default: poktroll): " CHAIN_ID CHAIN_ID=${CHAIN_ID:-"poktroll"} - # Set URLs based on the chosen network - BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/$NETWORK" + # Update URLs to use the branch constant + BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/${GENESIS_BRANCH}/shannon/$NETWORK" SEEDS_URL="$BASE_URL/seeds" GENESIS_URL="$BASE_URL/genesis.json" From 1ac5ebd51861f360ae96fc538d61af71d1f46b87 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 19:14:54 -0800 Subject: [PATCH 04/18] use chain id from genesis --- tools/installer/full-node.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index fc37ee6da..6eb6010e7 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -70,14 +70,27 @@ get_user_input() { read -p "Enter the node moniker (default: $(hostname)): " NODE_MONIKER NODE_MONIKER=${NODE_MONIKER:-$(hostname)} - read -p "Enter the chain-id (default: poktroll): " CHAIN_ID - CHAIN_ID=${CHAIN_ID:-"poktroll"} - # Update URLs to use the branch constant BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/${GENESIS_BRANCH}/shannon/$NETWORK" SEEDS_URL="$BASE_URL/seeds" GENESIS_URL="$BASE_URL/genesis.json" + # Download genesis.json and store it + GENESIS_FILE="/tmp/genesis.json" + curl -s -o "$GENESIS_FILE" "$GENESIS_URL" + if [ $? -ne 0 ]; then + print_color $RED "Failed to download genesis file. Please check your internet connection and try again." + exit 1 + fi + + # Extract chain_id from genesis.json + CHAIN_ID=$(jq -r '.chain_id' < "$GENESIS_FILE") + if [ -z "$CHAIN_ID" ]; then + print_color $RED "Failed to extract chain_id from genesis file." + exit 1 + fi + print_color $GREEN "Using chain_id: $CHAIN_ID from genesis file" + # Fetch seeds from the provided URL SEEDS=$(curl -s "$SEEDS_URL") if [ -z "$SEEDS" ]; then @@ -182,14 +195,6 @@ setup_poktrolld() { exit 1 fi - # Download genesis.json once and store it - GENESIS_FILE="/tmp/genesis.json" - curl -s -o "$GENESIS_FILE" "$GENESIS_URL" - if [ $? -ne 0 ]; then - print_color $RED "Failed to download genesis file. Please check your internet connection and try again." - exit 1 - fi - # Extract the version from genesis.json using jq POKTROLLD_VERSION=$(jq -r '.app_version' < "$GENESIS_FILE") From 1cea3914603b6a15312d39e0737a6260b417ae39 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 19:17:17 -0800 Subject: [PATCH 05/18] should have version prefix --- tools/installer/full-node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 6eb6010e7..d749d2ace 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -204,7 +204,7 @@ setup_poktrolld() { fi # Use the direct download link for the correct release - RELEASE_URL="https://github.com/pokt-network/poktroll/releases/download/${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" + RELEASE_URL="https://github.com/pokt-network/poktroll/releases/download/v${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" sudo -u "$POKTROLL_USER" bash << EOF mkdir -p \$HOME/.poktroll/cosmovisor/genesis/bin From f5e7fa03d2946634905bf45fb4a2542cb611f85f Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 19:25:22 -0800 Subject: [PATCH 06/18] troubleshoot download --- tools/installer/full-node.sh | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index d749d2ace..bb6949dcf 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -197,23 +197,53 @@ setup_poktrolld() { # Extract the version from genesis.json using jq POKTROLLD_VERSION=$(jq -r '.app_version' < "$GENESIS_FILE") + print_color $YELLOW "Detected version from genesis: $POKTROLLD_VERSION" if [ -z "$POKTROLLD_VERSION" ]; then print_color $RED "Failed to extract version information from genesis file." exit 1 fi - # Use the direct download link for the correct release + # Construct the release URL with proper version format RELEASE_URL="https://github.com/pokt-network/poktroll/releases/download/v${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" + print_color $YELLOW "Attempting to download from: $RELEASE_URL" + # Create temporary directory for download + TMP_DIR=$(mktemp -d) + sudo -u "$POKTROLL_USER" bash << EOF mkdir -p \$HOME/.poktroll/cosmovisor/genesis/bin - curl -L "$RELEASE_URL" | tar -zxvf - -C \$HOME/.poktroll/cosmovisor/genesis/bin + + # Download with better error handling + if curl -L "$RELEASE_URL" -o "$TMP_DIR/poktroll.tar.gz"; then + print_color \$GREEN "Download successful" + + # Extract with error checking + if tar -xzvf "$TMP_DIR/poktroll.tar.gz" -C \$HOME/.poktroll/cosmovisor/genesis/bin; then + print_color \$GREEN "Extraction successful" + else + print_color \$RED "Failed to extract archive" + exit 1 + fi + else + print_color \$RED "Failed to download binary from $RELEASE_URL" + exit 1 + fi + chmod +x \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/bin/poktrolld source \$HOME/.profile EOF - print_color $GREEN "Poktrolld set up successfully." + + # Cleanup + rm -rf "$TMP_DIR" + + if [ $? -eq 0 ]; then + print_color $GREEN "Poktrolld set up successfully." + else + print_color $RED "Failed to set up Poktrolld." + exit 1 + fi } # Function to configure Poktrolld From 8e162d2647e8e1f9adf69e6f122177bdbd0269b4 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 19:27:36 -0800 Subject: [PATCH 07/18] set permissions --- tools/installer/full-node.sh | 44 +++++++++++++++++------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index bb6949dcf..5348bc6bd 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -208,42 +208,40 @@ setup_poktrolld() { RELEASE_URL="https://github.com/pokt-network/poktroll/releases/download/v${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" print_color $YELLOW "Attempting to download from: $RELEASE_URL" - # Create temporary directory for download + # Create temporary directory for download and set permissions TMP_DIR=$(mktemp -d) - + chown "$POKTROLL_USER:$POKTROLL_USER" "$TMP_DIR" + + # Download and extract as the POKTROLL_USER sudo -u "$POKTROLL_USER" bash << EOF mkdir -p \$HOME/.poktroll/cosmovisor/genesis/bin - # Download with better error handling - if curl -L "$RELEASE_URL" -o "$TMP_DIR/poktroll.tar.gz"; then - print_color \$GREEN "Download successful" - - # Extract with error checking - if tar -xzvf "$TMP_DIR/poktroll.tar.gz" -C \$HOME/.poktroll/cosmovisor/genesis/bin; then - print_color \$GREEN "Extraction successful" - else - print_color \$RED "Failed to extract archive" - exit 1 - fi - else - print_color \$RED "Failed to download binary from $RELEASE_URL" + echo "Downloading binary..." + if ! curl -L "$RELEASE_URL" -o "$TMP_DIR/poktroll.tar.gz"; then + echo "Failed to download binary" + exit 1 + fi + + echo "Extracting binary..." + if ! tar -xzvf "$TMP_DIR/poktroll.tar.gz" -C \$HOME/.poktroll/cosmovisor/genesis/bin; then + echo "Failed to extract binary" exit 1 fi chmod +x \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/bin/poktrolld - source \$HOME/.profile EOF - # Cleanup - rm -rf "$TMP_DIR" - - if [ $? -eq 0 ]; then - print_color $GREEN "Poktrolld set up successfully." - else - print_color $RED "Failed to set up Poktrolld." + # Check the result of the sudo command + if [ $? -ne 0 ]; then + print_color $RED "Failed to set up Poktrolld" + rm -rf "$TMP_DIR" exit 1 fi + + # Cleanup + rm -rf "$TMP_DIR" + print_color $GREEN "Poktrolld set up successfully." } # Function to configure Poktrolld From a0fba55c1d685ce7f52c740e4958a5ca1d4f04ba Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 19:38:43 -0800 Subject: [PATCH 08/18] pipe directrly --- tools/installer/full-node.sh | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 5348bc6bd..55fa38f9e 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -208,39 +208,24 @@ setup_poktrolld() { RELEASE_URL="https://github.com/pokt-network/poktroll/releases/download/v${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" print_color $YELLOW "Attempting to download from: $RELEASE_URL" - # Create temporary directory for download and set permissions - TMP_DIR=$(mktemp -d) - chown "$POKTROLL_USER:$POKTROLL_USER" "$TMP_DIR" - - # Download and extract as the POKTROLL_USER + # Download and extract directly as the POKTROLL_USER sudo -u "$POKTROLL_USER" bash << EOF mkdir -p \$HOME/.poktroll/cosmovisor/genesis/bin - - echo "Downloading binary..." - if ! curl -L "$RELEASE_URL" -o "$TMP_DIR/poktroll.tar.gz"; then - echo "Failed to download binary" + curl -L "$RELEASE_URL" | tar -zxvf - -C \$HOME/.poktroll/cosmovisor/genesis/bin + if [ \$? -ne 0 ]; then + echo "Failed to download or extract binary" exit 1 fi - - echo "Extracting binary..." - if ! tar -xzvf "$TMP_DIR/poktroll.tar.gz" -C \$HOME/.poktroll/cosmovisor/genesis/bin; then - echo "Failed to extract binary" - exit 1 - fi - chmod +x \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/bin/poktrolld + source \$HOME/.profile EOF - # Check the result of the sudo command if [ $? -ne 0 ]; then print_color $RED "Failed to set up Poktrolld" - rm -rf "$TMP_DIR" exit 1 fi - # Cleanup - rm -rf "$TMP_DIR" print_color $GREEN "Poktrolld set up successfully." } From e37bfa9ec6d132959cbc41299f0ba8f957aca18f Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 20:00:21 -0800 Subject: [PATCH 09/18] open port when ufw is installed --- tools/installer/full-node.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 55fa38f9e..8acdc4c99 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -292,6 +292,22 @@ EOF print_color $GREEN "Systemd service set up and started successfully." } +# Function to check if ufw is installed and open port 26656 +configure_ufw() { + if command -v ufw &> /dev/null; then + print_color $YELLOW "ufw is installed." + read -p "Do you want to open port 26656 for p2p communication? (Y/n): " open_port + if [[ $open_port =~ ^[Yy] ]]; then + ufw allow 26656 + print_color $GREEN "Port 26656 opened successfully." + else + print_color $YELLOW "Port 26656 not opened." + fi + else + print_color $YELLOW "ufw is not installed. Skipping port configuration." + fi +} + # Main function main() { print_color $GREEN "Welcome to the Poktroll Full Node Install Script!" @@ -305,6 +321,7 @@ main() { setup_poktrolld configure_poktrolld setup_systemd + configure_ufw print_color $GREEN "Poktroll Full Node installation for $NETWORK completed successfully!" print_color $YELLOW "You can check the status of your node with: sudo systemctl status cosmovisor.service" print_color $YELLOW "View logs with: sudo journalctl -u cosmovisor.service -f" From c8088781b5b7e787e22dad312b6a9e2eb172fd87 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Wed, 20 Nov 2024 20:40:02 -0800 Subject: [PATCH 10/18] set external address --- tools/installer/full-node.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 8acdc4c99..56a291621 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -242,6 +242,15 @@ configure_poktrolld() { exit 1 fi + # Detect external IP address + EXTERNAL_IP=$(curl -s https://api.ipify.org) + print_color $YELLOW "Detected external IP address: $EXTERNAL_IP" + read -p "Is this your correct external IP address? (Y/n): " confirm_ip + if [[ $confirm_ip =~ ^[Nn] ]]; then + read -p "Please enter your external IP address: " custom_ip + EXTERNAL_IP=${custom_ip:-$EXTERNAL_IP} + fi + sudo -u "$POKTROLL_USER" bash << EOF source \$HOME/.profile @@ -252,6 +261,7 @@ configure_poktrolld() { poktrolld init "$NODE_MONIKER" --chain-id="$CHAIN_ID" --home=\$HOME/.poktroll cp "$GENESIS_FILE" \$HOME/.poktroll/config/genesis.json sed -i -e "s|^seeds *=.*|seeds = \"$SEEDS\"|" \$HOME/.poktroll/config/config.toml + sed -i -e "s|^external_address *=.*|external_address = \"$EXTERNAL_IP:26656\"|" \$HOME/.poktroll/config/config.toml EOF if [ $? -eq 0 ]; then print_color $GREEN "Poktrolld configured successfully." From 13a69473e0be8aea453762106fbc3b46549d25fd Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Thu, 21 Nov 2024 12:15:19 -0800 Subject: [PATCH 11/18] use master branch by default --- tools/installer/full-node.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 56a291621..b46e5e127 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -8,8 +8,8 @@ GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color -# Add the branch constant here -GENESIS_BRANCH="add-beta-seeds-rename-dirs" +# Can change the branch from `pocket-network-genesis` repo to test before merging to master. +GENESIS_BRANCH="master" # Function to print colored output print_color() { From 25243bf94a4461840341d49a904103f6fa8c9862 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Thu, 21 Nov 2024 16:31:09 -0800 Subject: [PATCH 12/18] requested changes --- tools/installer/full-node.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index b46e5e127..446030c5f 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -8,7 +8,7 @@ GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color -# Can change the branch from `pocket-network-genesis` repo to test before merging to master. +# DEV_NOTE: For testing purposes, you can change the branch name before merging to master. GENESIS_BRANCH="master" # Function to print colored output @@ -302,7 +302,8 @@ EOF print_color $GREEN "Systemd service set up and started successfully." } -# Function to check if ufw is installed and open port 26656 +# Function to check if ufw is installed and open port 26656. We need to open the port to keep the network healthy. +# By default, at least on Debian vultr, this port is not open to the internet. configure_ufw() { if command -v ufw &> /dev/null; then print_color $YELLOW "ufw is installed." From bcc5f70e501e4f0dfcb467c748252b4a44db5994 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 25 Nov 2024 15:13:10 -0800 Subject: [PATCH 13/18] --wip-- [skip ci] --- .env.sample | 1 + .../docker_compose_debian_cheatsheet.md | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docusaurus/docs/operate/quickstart/docker_compose_debian_cheatsheet.md b/docusaurus/docs/operate/quickstart/docker_compose_debian_cheatsheet.md index 6493b012e..6bca9060d 100644 --- a/docusaurus/docs/operate/quickstart/docker_compose_debian_cheatsheet.md +++ b/docusaurus/docs/operate/quickstart/docker_compose_debian_cheatsheet.md @@ -73,7 +73,7 @@ sudo apt-get update if command -v ufw > /dev/null 2>&1; then sudo ufw allow from 172.16.0.0/12 sudo ufw allow from 192.168.0.0/16 - echo "UFW rules added for Docker networks" + echo "UFW rules added for Docker networks and validator endpoint" else echo "UFW is not installed, skipping firewall configuration" fi @@ -97,9 +97,18 @@ cd poktroll-docker-compose-example ## Update your environment +First, copy the sample environment file: ```bash cp .env.sample .env +``` + +By default, the `.env` file uses `testnet-beta`. If you want to use a different network, update the `NETWORK_NAME` in your `.env` file to one of: +- `testnet-alpha` - Unstable testnet +- `testnet-beta` - Stable testnet (default) +- `mainnet` - Production network +Then set your external IP and source the environment: +```bash EXTERNAL_IP=$(curl -4 ifconfig.me/ip) sed -i -e s/NODE_HOSTNAME=/NODE_HOSTNAME=$EXTERNAL_IP/g .env @@ -153,15 +162,19 @@ FINALLY, `source .env` to update the environment variables. ## Fund your accounts -Run the following: +Run the following to see your addresses: ```bash show_actor_addresses ``` -For each one, fund the accounts using the [faucet](https://faucet.testnet.pokt.network/) +Get the faucet URL for your network: + +```bash +show_faucet_url +``` -Next, run this helper (it's part of `helpers.sh`) to find each of them on the explorer: +Fund each address using the faucet URL shown above. Then run this helper to find each account on the explorer: ```bash show_explorer_urls From f90b6edf73c6f71a60912bca5739bac67aaddab1 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 25 Nov 2024 17:37:02 -0800 Subject: [PATCH 14/18] add docs --- .../quickstart/full_node_cheatsheet.md | 145 ++++++++++ .../quickstart/validator_cheatsheet.md | 14 - .../run_a_node/full_node_cosmovisor.md | 108 -------- .../run_a_node/full_node_walkthrough.md | 250 ++++++++++++++++++ .../run_a_node/validator_walkthrough.md | 8 - 5 files changed, 395 insertions(+), 130 deletions(-) create mode 100644 docusaurus/docs/operate/quickstart/full_node_cheatsheet.md delete mode 100644 docusaurus/docs/operate/quickstart/validator_cheatsheet.md delete mode 100644 docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md create mode 100644 docusaurus/docs/operate/run_a_node/full_node_walkthrough.md delete mode 100644 docusaurus/docs/operate/run_a_node/validator_walkthrough.md diff --git a/docusaurus/docs/operate/quickstart/full_node_cheatsheet.md b/docusaurus/docs/operate/quickstart/full_node_cheatsheet.md new file mode 100644 index 000000000..d2986bb30 --- /dev/null +++ b/docusaurus/docs/operate/quickstart/full_node_cheatsheet.md @@ -0,0 +1,145 @@ +--- +sidebar_position: 3 +title: Full Node Cheat Sheet +--- + +This cheat sheet provides quick instructions for installing a Full Node using an automated script. + +- [Pre-Requisites](#pre-requisites) +- [Install a Full Node using Cosmovisor](#install-a-full-node-using-cosmovisor) +- [What Gets Installed](#what-gets-installed) +- [Useful Commands](#useful-commands) + - [Check the status of your node](#check-the-status-of-your-node) + - [View the logs](#view-the-logs) + - [Stop the node](#stop-the-node) + - [Start the node](#start-the-node) + - [Restart the node](#restart-the-node) + - [Advanced Operations](#advanced-operations) +- [Automatic Upgrades](#automatic-upgrades) + +### Pre-Requisites + +1. **Linux-based System**: Ensure you have a Debian-based Linux distribution (other distributions may work but are not fully supported). +2. **Root or Sudo Access**: You need administrative privileges to run the installation script. +3. **Dedicated Server or Virtual Machine**: Any provider should work (Vultr and Hetzner have been tested). + +### Install a Full Node using Cosmovisor + +To install and set up a Full Node, follow these steps: + +1. **Download the Installation Script**: + + ```bash + curl -O https://raw.githubusercontent.com/pokt-network/poktroll/main/tools/installer/full-node.sh + ``` + +2. **Run the Script with Sudo Privileges**: + + ```bash + sudo bash full-node.sh + ``` + +3. **Follow the Prompts**: + + - **Choose the Network**: Select `testnet-alpha`, `testnet-beta`, or `mainnet`. + - **Set Username**: Input the desired username to run `poktrolld` (default: `poktroll`). + - **Set Node Moniker**: Input the node moniker (default: your hostname). + - **Confirm Seeds and Genesis File**: The script fetches seeds and the genesis file automatically. + - **External IP Address**: The script detects your external IP address. Confirm or input manually if incorrect. + +The script will handle the installation of dependencies, user creation, environment variable setup, and configuration of Cosmovisor and `poktrolld`. + +### What Gets Installed + +When you run the installation script, the following components are set up: + +1. **System User**: A dedicated user (default: `poktroll`) is created to run the node securely. + +2. **Cosmovisor**: A binary manager that handles chain upgrades automatically: + - Location: `/home/poktroll/bin/cosmovisor` + - Purpose: Manages different versions of `poktrolld` and handles chain upgrades + - Configuration: Set up to automatically download and switch to new binaries during upgrades + +3. **Poktrolld**: The core node software: + - Location: `/home/poktroll/.poktroll/cosmovisor/genesis/bin/poktrolld` + - Configuration: `/home/poktroll/.poktroll/config/` + - Data: `/home/poktroll/.poktroll/data/` + +4. **Systemd Service**: A service that manages the node: + - Name: `cosmovisor.service` + - Status: Enabled and started automatically + - Configured for automatic restarts and upgrades + +### Useful Commands + +After installation, you can manage your node using the following commands: + +#### Check the status of your node + +```bash +sudo systemctl status cosmovisor.service +``` + +#### View the logs + +```bash +sudo journalctl -u cosmovisor.service -f +``` + +#### Stop the node + +```bash +sudo systemctl stop cosmovisor.service +``` + +#### Start the node + +```bash +sudo systemctl start cosmovisor.service +``` + +#### Restart the node + +```bash +sudo systemctl restart cosmovisor.service +``` + +#### Advanced Operations + +Check the current version: +```bash +sudo -u poktroll poktrolld version +``` + +View the Cosmovisor directory structure: +```bash +ls -la /home/poktroll/.poktroll/cosmovisor/ +``` + +Check if an upgrade is available: +```bash +ls -la /home/poktroll/.poktroll/cosmovisor/upgrades/ +``` + +View node configuration: +```bash +cat /home/poktroll/.poktroll/config/config.toml +``` + +### Automatic Upgrades + +Your node is configured to handle chain upgrades automatically through Cosmovisor. When a chain upgrade is proposed and approved: + +1. Cosmovisor will download the new binary +2. The node will stop at the designated upgrade height +3. Cosmovisor will switch to the new binary +4. The node will restart automatically + +No manual intervention is required for standard upgrades. + + diff --git a/docusaurus/docs/operate/quickstart/validator_cheatsheet.md b/docusaurus/docs/operate/quickstart/validator_cheatsheet.md deleted file mode 100644 index d09097e4b..000000000 --- a/docusaurus/docs/operate/quickstart/validator_cheatsheet.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -sidebar_position: 3 -title: Validator Cheat Sheet ---- - -## Validator Cheat Sheet - -:::tip - -See the [Validator Walkthrough](./../run_a_node/validator_walkthrough.md) for an in-depth guide on setting up a Validator Node. - -::: - -TODO_BETA(@okdas): Finish this page. diff --git a/docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md b/docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md deleted file mode 100644 index e8bb2ee3b..000000000 --- a/docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: Full Node (Cosmovisor) -sidebar_position: 2 ---- - -## Run a Full Node using Cosmovisor - -This document provides instructions on using the official Cosmos SDK [Cosmosvisor](https://docs.cosmos.network/v0.45/run-node/cosmovisor.html) to run a full Pocket Network node. - -- [What is a Full Node](#what-is-a-full-node) -- [What is Cosmovisor](#what-is-cosmovisor) -- [Installation Instructions](#installation-instructions) - - [Prerequisites](#prerequisites) - - [Installation Steps](#installation-steps) -- [Useful Command Cheat Sheet](#useful-command-cheat-sheet) - - [Check the status of your node](#check-the-status-of-your-node) - - [View the logs](#view-the-logs) - - [Stop the node](#stop-the-node) - - [Start the node](#start-the-node) - - [Restart the node](#restart-the-node) - -### What is a Full Node - -In blockchain networks, a full node retains continuous synchs and updates the latest copy of the ledger. It may either be a pruned full node (the latest data only) or an archival full node (including complete and historical data). - -You can visit the [Cosmos SDK documentation](https://docs.cosmos.network/main/user/run-node/run-node) for more information on Full Nodes. - -### What is Cosmovisor - -[Cosmovisor](https://docs.cosmos.network/main/build/tooling/cosmovisor) is a tool that automates the version management for our blockchain. It allows operators to automatically upgrade their full nodes and validators without downtime and reduce maintenance overhead. - -### Installation Instructions - -To install and set up a Poktroll Full Node using Cosmovisor, we provide a comprehensive installation script. This script will handle all the necessary steps, including user creation, dependency installation, Cosmovisor and Poktrolld setup, and system configuration. - -#### Prerequisites - -- A Linux-based system (Debian-based distributions are fully supported, others may work as well) -- Root or sudo access -- A dedicated server or a virtual machine (any provider should work, Vultr and Hetzner have been tested) - -#### Installation Steps - -1. Download the installation script: - - ```bash - curl -O https://raw.githubusercontent.com/pokt-network/poktroll/main/tools/installer/full-node.sh - ``` - -2. Make the script executable: - - ```bash - chmod +x full-node.sh - ``` - -3. Run the script with sudo privileges: - - ```bash - sudo ./full-node.sh - ``` - -4. Follow the prompts to provide the necessary information: - - Desired username to run poktrolld (`default: poktroll`) - - Node moniker (`default: hostname`) - - Seeds (`default: fetched` [from the official source](https://github.com/pokt-network/pocket-network-genesis/tree/master/shannon/alpha)) - - Chain ID (`default: poktroll-testnet`) - -The script will then proceed with the installation and setup process. - -### Useful Command Cheat Sheet - -After the installation is complete, your Poktroll Full Node should be up and running. - -:::tip -Remember to keep your system updated and monitor your node regularly to ensure its proper functioning and security. -::: - -Here are some useful commands for managing your node: - -#### Check the status of your node - -```bash - sudo systemctl status cosmovisor.service -``` - -#### View the logs - -```bash -sudo journalctl -u cosmovisor.service -f -``` - -#### Stop the node - -```bash -sudo systemctl stop cosmovisor.service -``` - -#### Start the node - -```bash -sudo systemctl start cosmovisor.service -``` - -#### Restart the node - -```bash -sudo systemctl restart cosmovisor.service -``` diff --git a/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md b/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md new file mode 100644 index 000000000..f4a5cb96c --- /dev/null +++ b/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md @@ -0,0 +1,250 @@ +--- +title: Full Node (systemd) +sidebar_position: 2 +--- + +## Run a Validator + +This walkthrough provides step-by-step instructions to manually install and configure a Full Node from scratch. + +- [Introduction](#introduction) +- [Pre-Requisites](#pre-requisites) +- [Step 1: Create a New User](#step-1-create-a-new-user) +- [Step 2: Install Dependencies](#step-2-install-dependencies) +- [Step 3: Set Up Environment Variables](#step-3-set-up-environment-variables) +- [Step 4: Install Cosmovisor](#step-4-install-cosmovisor) +- [Step 5: Install `poktrolld`](#step-5-install-poktrolld) +- [Step 6: Configure `poktrolld`](#step-6-configure-poktrolld) +- [Step 7: Set Up `systemd` Service](#step-7-set-up-systemd-service) +- [Step 8: Open Firewall Ports](#step-8-open-firewall-ports) +- [Next Steps](#next-steps) + +### Introduction + +This guide will help you install a Full Node for Pocket Network manually, giving you control over each step of the process. Running a Full Node is the first step toward becoming a Validator. + +**TL;DR**: If you're comfortable using an automated script, check out the [Full Node Cheat Sheet](../quickstart/full_node_cheatsheet.md) for quick setup instructions. + +### Pre-Requisites + +- **Linux-based System**: Preferably Debian-based distributions. +- **Root or Sudo Access**: Administrative privileges are required. +- **Dedicated Server or Virtual Machine**: Any provider is acceptable. + +### Step 1: Create a New User + +Create a dedicated user to run `poktrolld`: + +```bash +sudo adduser poktroll +``` + +Set a password when prompted, and add the user to the sudo group: + +```bash +sudo usermod -aG sudo poktroll +``` + +### Step 2: Install Dependencies + +Update your package list and install necessary dependencies: + +```bash +sudo apt-get update +sudo apt-get install -y curl tar wget jq +``` + +### Step 3: Set Up Environment Variables + +Switch to the `poktroll` user and set environment variables required for Cosmovisor: + +```bash +sudo su - poktroll +``` + +Add the following to your `.profile`: + +```bash +echo "export DAEMON_NAME=poktrolld" >> ~/.profile +echo "export DAEMON_HOME=\$HOME/.poktroll" >> ~/.profile +echo "export DAEMON_RESTART_AFTER_UPGRADE=true" >> ~/.profile +echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=true" >> ~/.profile +echo "export UNSAFE_SKIP_BACKUP=false" >> ~/.profile +source ~/.profile +``` + +### Step 4: Install Cosmovisor + +Download and install Cosmovisor: + +:::info +Alternatively, you can follow the [official cosmovisor installation instructions](https://docs.cosmos.network/main/build/tooling/cosmovisor#installation). +::: + +```bash +mkdir -p $HOME/bin +COSMOVISOR_VERSION="v1.6.0" +ARCH=$(uname -m) +if [ "$ARCH" = "x86_64" ]; then + ARCH="amd64" +elif [ "$ARCH" = "aarch64" ]; then + ARCH="arm64" +fi + +curl -L "https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2F${COSMOVISOR_VERSION}/cosmovisor-${COSMOVISOR_VERSION}-linux-${ARCH}.tar.gz" | tar -zxvf - -C $HOME/bin +echo 'export PATH=$HOME/bin:$PATH' >> ~/.profile +source ~/.profile +``` + + +### Step 5: Install `poktrolld` + +Download and install `poktrolld`: + +1. **Extract Version and Set Architecture**: + + Different networks start with different versions. Let's extract the version from the genesis file and set the architecture. + + ```bash + # Extract version from genesis.json + POKTROLLD_VERSION=$(jq -r '.app_version' < $HOME/.poktroll/config/genesis.json) + ARCH=$(uname -m) + if [ "$ARCH" = "x86_64" ]; then ARCH="amd64" + elif [ "$ARCH" = "aarch64" ]; then ARCH="arm64" + fi + ``` + +2. **Download and Install the Binary**: + + Create the cosmovisor genesis directory and download the binary. + ```bash + mkdir -p $HOME/.poktroll/cosmovisor/genesis/bin + curl -L "https://github.com/pokt-network/poktroll/releases/download/v${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" | tar -zxvf - -C $HOME/.poktroll/cosmovisor/genesis/bin + chmod +x $HOME/.poktroll/cosmovisor/genesis/bin/poktrolld + ln -sf $HOME/.poktroll/cosmovisor/genesis/bin/poktrolld $HOME/bin/poktrolld + ``` + +### Step 6: Configure `poktrolld` + +Initialize configuration files and set up the node: + +1. **Select Network and Download Genesis**: + + ```bash + # Select network (testnet-alpha, testnet-beta, or mainnet) + NETWORK="testnet-beta" # Change this to your desired network + + # Download genesis file + GENESIS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/${NETWORK}/genesis.json" + curl -s -o $HOME/.poktroll/config/genesis.json "$GENESIS_URL" + + # Extract chain-id from genesis + CHAIN_ID=$(jq -r '.chain_id' < $HOME/.poktroll/config/genesis.json) + ``` + +2. **Initialize the Node**: + + ```bash + poktrolld init "YourNodeMoniker" --chain-id="$CHAIN_ID" --home=$HOME/.poktroll + ``` + +3. **Set Seeds**: + + ```bash + SEEDS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/${NETWORK}/seeds" + SEEDS=$(curl -s "$SEEDS_URL") + sed -i -e "s|^seeds *=.*|seeds = \"$SEEDS\"|" $HOME/.poktroll/config/config.toml + ``` + +4. **Set External Address**: + + ```bash + EXTERNAL_IP=\$(curl -s https://api.ipify.org) + sed -i -e "s|^external_address *=.*|external_address = \"\${EXTERNAL_IP}:26656\"|" \$HOME/.poktroll/config/config.toml + ``` + +### Step 7: Set Up `systemd` Service + +Create a `systemd` service file to manage the node: + +```bash +sudo tee /etc/systemd/system/cosmovisor.service > /dev/null < diff --git a/docusaurus/docs/operate/run_a_node/validator_walkthrough.md b/docusaurus/docs/operate/run_a_node/validator_walkthrough.md deleted file mode 100644 index 49fabfb3a..000000000 --- a/docusaurus/docs/operate/run_a_node/validator_walkthrough.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Validator Walkthrough -sidebar_position: 6 ---- - -# Run a Validator - -TODO_BETA(@okdas): Update this page with all the details. From 846e671d94157e5c1be511931c0d326c53429284 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 25 Nov 2024 17:48:16 -0800 Subject: [PATCH 15/18] requested changes --- tools/installer/full-node.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 446030c5f..1274933de 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -9,7 +9,7 @@ YELLOW='\033[1;33m' NC='\033[0m' # No Color # DEV_NOTE: For testing purposes, you can change the branch name before merging to master. -GENESIS_BRANCH="master" +POCKET_NETWORK_GENESIS_BRANCH="master" # Function to print colored output print_color() { @@ -59,10 +59,10 @@ get_user_input() { 1) NETWORK="testnet-alpha" ;; 2) NETWORK="testnet-beta" ;; 3) NETWORK="mainnet" ;; - *) print_color $RED "Invalid choice. Exiting."; exit 1 ;; + *) print_color $RED "Invalid network choice. Exiting."; exit 1 ;; esac - print_color $GREEN "You have chosen to install the $NETWORK network." + print_color $GREEN "Installing the $NETWORK network." read -p "Enter the desired username to run poktrolld (default: poktroll): " POKTROLL_USER POKTROLL_USER=${POKTROLL_USER:-poktroll} @@ -71,7 +71,7 @@ get_user_input() { NODE_MONIKER=${NODE_MONIKER:-$(hostname)} # Update URLs to use the branch constant - BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/${GENESIS_BRANCH}/shannon/$NETWORK" + BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/${POCKET_NETWORK_GENESIS_BRANCH}/shannon/$NETWORK" SEEDS_URL="$BASE_URL/seeds" GENESIS_URL="$BASE_URL/genesis.json" @@ -211,13 +211,14 @@ setup_poktrolld() { # Download and extract directly as the POKTROLL_USER sudo -u "$POKTROLL_USER" bash << EOF mkdir -p \$HOME/.poktroll/cosmovisor/genesis/bin + mkdir -p \$HOME/.local/bin curl -L "$RELEASE_URL" | tar -zxvf - -C \$HOME/.poktroll/cosmovisor/genesis/bin if [ \$? -ne 0 ]; then echo "Failed to download or extract binary" exit 1 fi chmod +x \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld - ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/bin/poktrolld + ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/.local/bin/poktrolld source \$HOME/.profile EOF @@ -307,15 +308,23 @@ EOF configure_ufw() { if command -v ufw &> /dev/null; then print_color $YELLOW "ufw is installed." + + # Check if rule already exists + if ufw status | grep -q "26656"; then + print_color $YELLOW "Port 26656 is already allowed in ufw rules." + return + fi + read -p "Do you want to open port 26656 for p2p communication? (Y/n): " open_port if [[ $open_port =~ ^[Yy] ]]; then ufw allow 26656 print_color $GREEN "Port 26656 opened successfully." + print_color $YELLOW "To remove this rule later, run: sudo ufw delete allow 26656" else - print_color $YELLOW "Port 26656 not opened." + print_color $YELLOW "No firewall rules modified." fi else - print_color $YELLOW "ufw is not installed. Skipping port configuration." + print_color $YELLOW "ufw is not installed. Skipping firewall configuration." fi } From cc420726879592573d8e7d46fcc64f695632dfd6 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 25 Nov 2024 18:09:23 -0800 Subject: [PATCH 16/18] remove dis --- .env.sample | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .env.sample diff --git a/.env.sample b/.env.sample deleted file mode 100644 index 0519ecba6..000000000 --- a/.env.sample +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 3bacc88884c9332e9637c49ad64013acb16febf7 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 25 Nov 2024 18:27:13 -0800 Subject: [PATCH 17/18] walkthrough and test --- .../run_a_node/full_node_walkthrough.md | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md b/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md index f4a5cb96c..d0adb768c 100644 --- a/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md +++ b/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md @@ -82,7 +82,7 @@ Alternatively, you can follow the [official cosmovisor installation instructions ::: ```bash -mkdir -p $HOME/bin +mkdir -p $HOME/.local/bin COSMOVISOR_VERSION="v1.6.0" ARCH=$(uname -m) if [ "$ARCH" = "x86_64" ]; then @@ -91,8 +91,8 @@ elif [ "$ARCH" = "aarch64" ]; then ARCH="arm64" fi -curl -L "https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2F${COSMOVISOR_VERSION}/cosmovisor-${COSMOVISOR_VERSION}-linux-${ARCH}.tar.gz" | tar -zxvf - -C $HOME/bin -echo 'export PATH=$HOME/bin:$PATH' >> ~/.profile +curl -L "https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2F${COSMOVISOR_VERSION}/cosmovisor-${COSMOVISOR_VERSION}-linux-${ARCH}.tar.gz" | tar -zxvf - -C $HOME/.local/bin +echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.profile source ~/.profile ``` @@ -101,12 +101,20 @@ source ~/.profile Download and install `poktrolld`: -1. **Extract Version and Set Architecture**: - - Different networks start with different versions. Let's extract the version from the genesis file and set the architecture. +1. **Download Genesis and Extract Version**: ```bash - # Extract version from genesis.json + # Select network (testnet-alpha, testnet-beta, or mainnet) + NETWORK="testnet-beta" # Change this to your desired network + + # Create config directory if it doesn't exist + mkdir -p $HOME/.poktroll/config + + # Download genesis file + GENESIS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/${NETWORK}/genesis.json" + curl -s -o $HOME/.poktroll/config/genesis.json "$GENESIS_URL" + + # Extract version and set architecture POKTROLLD_VERSION=$(jq -r '.app_version' < $HOME/.poktroll/config/genesis.json) ARCH=$(uname -m) if [ "$ARCH" = "x86_64" ]; then ARCH="amd64" @@ -121,34 +129,28 @@ Download and install `poktrolld`: mkdir -p $HOME/.poktroll/cosmovisor/genesis/bin curl -L "https://github.com/pokt-network/poktroll/releases/download/v${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" | tar -zxvf - -C $HOME/.poktroll/cosmovisor/genesis/bin chmod +x $HOME/.poktroll/cosmovisor/genesis/bin/poktrolld - ln -sf $HOME/.poktroll/cosmovisor/genesis/bin/poktrolld $HOME/bin/poktrolld + ln -sf $HOME/.poktroll/cosmovisor/genesis/bin/poktrolld $HOME/.local/bin/poktrolld ``` ### Step 6: Configure `poktrolld` Initialize configuration files and set up the node: -1. **Select Network and Download Genesis**: +1. **Extract Chain ID and Initialize Node**: ```bash - # Select network (testnet-alpha, testnet-beta, or mainnet) - NETWORK="testnet-beta" # Change this to your desired network - - # Download genesis file - GENESIS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/${NETWORK}/genesis.json" - curl -s -o $HOME/.poktroll/config/genesis.json "$GENESIS_URL" - - # Extract chain-id from genesis + # Extract chain-id from existing genesis CHAIN_ID=$(jq -r '.chain_id' < $HOME/.poktroll/config/genesis.json) - ``` - -2. **Initialize the Node**: - - ```bash + + # Initialize the node poktrolld init "YourNodeMoniker" --chain-id="$CHAIN_ID" --home=$HOME/.poktroll ``` -3. **Set Seeds**: + :::note + You may see a message saying `genesis.json file already exists`. This is expected since we downloaded the genesis file in Step 5. The initialization will still complete successfully and set up the required configuration files. + ::: + +2. **Set Seeds**: ```bash SEEDS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/${NETWORK}/seeds" @@ -156,11 +158,11 @@ Initialize configuration files and set up the node: sed -i -e "s|^seeds *=.*|seeds = \"$SEEDS\"|" $HOME/.poktroll/config/config.toml ``` -4. **Set External Address**: +3. **Set External Address**: ```bash - EXTERNAL_IP=\$(curl -s https://api.ipify.org) - sed -i -e "s|^external_address *=.*|external_address = \"\${EXTERNAL_IP}:26656\"|" \$HOME/.poktroll/config/config.toml + EXTERNAL_IP=$(curl -s https://api.ipify.org) + sed -i -e "s|^external_address *=.*|external_address = \"${EXTERNAL_IP}:26656\"|" $HOME/.poktroll/config/config.toml ``` ### Step 7: Set Up `systemd` Service @@ -175,7 +177,7 @@ After=network-online.target [Service] User=poktroll -ExecStart=/home/poktroll/bin/cosmovisor run start --home=/home/poktroll/.poktroll +ExecStart=/home/poktroll/.local/bin/cosmovisor run start --home=/home/poktroll/.poktroll Restart=always RestartSec=3 LimitNOFILE=infinity From 52e2ea5386e6d2b9097e62c348325233a71b910a Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Tue, 26 Nov 2024 15:25:23 -0800 Subject: [PATCH 18/18] fix docusarus build --- docusaurus/docs/protocol/upgrades/protocol_upgrades.md | 2 +- docusaurus/docs/protocol/upgrades/upgrade_procedure.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docusaurus/docs/protocol/upgrades/protocol_upgrades.md b/docusaurus/docs/protocol/upgrades/protocol_upgrades.md index 61b86e29e..684bc8e7a 100644 --- a/docusaurus/docs/protocol/upgrades/protocol_upgrades.md +++ b/docusaurus/docs/protocol/upgrades/protocol_upgrades.md @@ -5,7 +5,7 @@ sidebar_position: 1 # Protocol Upgrades -Pocket Network is continuously evolving through regular protocol upgrades. We implement software upgrades via a DAO process, allowing validator nodes to incorporate consensus-breaking changes. These upgrades can be automatically applied when using [Cosmovisor](../../operate/run_a_node/full_node_cosmovisor.md), or manually if not using `cosmovisor`. +Pocket Network is continuously evolving through regular protocol upgrades. We implement software upgrades via a DAO process, allowing validator nodes to incorporate consensus-breaking changes. These upgrades can be automatically applied when using [Cosmovisor](../../operate/run_a_node/full_node_walkthrough.md), or manually if not using `cosmovisor`. - [What is a Protocol Upgrade?](#what-is-a-protocol-upgrade) - [List of Upgrades](#list-of-upgrades) diff --git a/docusaurus/docs/protocol/upgrades/upgrade_procedure.md b/docusaurus/docs/protocol/upgrades/upgrade_procedure.md index b1098f509..2e0998251 100644 --- a/docusaurus/docs/protocol/upgrades/upgrade_procedure.md +++ b/docusaurus/docs/protocol/upgrades/upgrade_procedure.md @@ -27,7 +27,7 @@ When a consensus-breaking change is made to the protocol, we must carefully eval 2. **Implementation**: The proposed changes are implemented in the codebase. 3. **Testing**: Thorough testing of the proposed changes is conducted in devnet and testnet environments before mainnet deployment. 4. **Announcement**: Upon successful testing, we announce the upgrade through our social media channels and community forums. -5. **Deployment**: An upgrade transaction is sent to the network, allowing node operators using [Cosmovisor](../../operate/run_a_node/full_node_cosmovisor.md) to automatically upgrade their nodes at the specified block height. +5. **Deployment**: An upgrade transaction is sent to the network, allowing node operators using [Cosmovisor](../../operate/run_a_node/full_node_walkthrough.md) to automatically upgrade their nodes at the specified block height. 6. **Monitoring**: Post-deployment, we closely monitor the network to ensure everything functions as expected. ## When is an Upgrade Warranted? @@ -112,7 +112,7 @@ We use Kubernetes to manage software versions, including validators. Introducing ### TestNet -We currently deploy TestNet validators using Kubernetes with helm charts, which prevents us from managing the validator with `cosmovisor`. We do not control what other TestNet participants are running. However, if participants have deployed their nodes using the [cosmovisor guide](../../operate/run_a_node/full_node_cosmovisor.md), their nodes will upgrade automatically. +We currently deploy TestNet validators using Kubernetes with helm charts, which prevents us from managing the validator with `cosmovisor`. We do not control what other TestNet participants are running. However, if participants have deployed their nodes using the [cosmovisor guide](../../operate/run_a_node/full_node_walkthrough.md), their nodes will upgrade automatically. Until we transition to [cosmos-operator](https://github.com/strangelove-ventures/cosmos-operator), which supports scheduled upgrades (although not fully automatic like `cosmovisor`), we need to manually manage the process: