From 8f8b78e96dda8e8d717288b2f8c31405aa76a126 Mon Sep 17 00:00:00 2001 From: Rossignolskier Date: Fri, 12 Jul 2024 19:14:12 +0200 Subject: [PATCH] agave transition --- install/install_agave_validator.sh | 136 ++++++++++++++++++ .../group_vars/mainnet_validators.yaml | 4 +- .../group_vars/testnet_validators.yaml | 4 +- playbooks/pb_install_agave_validator.yaml | 12 ++ playbooks/pb_install_jito_validator.yaml | 12 ++ roles/agave_cli/tasks/install.yaml | 34 +++++ roles/agave_cli/tasks/main.yaml | 31 ++++ roles/agave_cli/tasks/update.yaml | 12 ++ roles/solana_cli/tasks/install.yaml | 17 +++ .../templates/solana-validator.service.j2 | 13 ++ .../tasks/wait_for_restart_window.yaml | 13 +- 11 files changed, 285 insertions(+), 3 deletions(-) create mode 100755 install/install_agave_validator.sh create mode 100644 playbooks/pb_install_agave_validator.yaml create mode 100644 playbooks/pb_install_jito_validator.yaml create mode 100644 roles/agave_cli/tasks/install.yaml create mode 100644 roles/agave_cli/tasks/main.yaml create mode 100644 roles/agave_cli/tasks/update.yaml diff --git a/install/install_agave_validator.sh b/install/install_agave_validator.sh new file mode 100755 index 0000000..fe79f71 --- /dev/null +++ b/install/install_agave_validator.sh @@ -0,0 +1,136 @@ +#!/bin/bash +#set -x -e + +echo "###################### WARNING!!! ######################" +echo "### This script will bootstrap a validator node ###" +echo "### for the Solana Testnet cluster, and connect ###" +echo "### it to the monitoring dashboard ###" +echo "### at solana.thevalidators.io ###" +echo "########################################################" + +install_validator () { + + echo "### Which type of validator you want to set up? ###" + select cluster in "mainnet-beta" "testnet"; do + case $cluster in + mainnet-beta ) inventory="mainnet.yaml"; break;; + testnet ) inventory="testnet.yaml"; break;; + esac + done + + echo "Please enter a name for your validator node: " + read VALIDATOR_NAME + read -e -p "Please enter the full path to your validator key pair file: " -i "/root/" PATH_TO_VALIDATOR_KEYS + + if [ ! -f "$PATH_TO_VALIDATOR_KEYS/validator-keypair.json" ] + then + echo "OOPS! Key $PATH_TO_VALIDATOR_KEYS/validator-keypair.json not found. Please verify and run the script again" + exit + fi + + if [ ! -f "$PATH_TO_VALIDATOR_KEYS/vote-account-keypair.json" ] ## && [ "$inventory" = "mainnet.yaml" ] + then + echo "OOPS! Key $PATH_TO_VALIDATOR_KEYS/vote-account-keypair.json not found. Please verify and run the script again. For security reasons we do not create any keys for mainnet." + exit + fi + + read -e -p "Enter new RAM drive size, GB (recommended size: 200GB):" -i "200" RAM_DISK_SIZE + read -e -p "Enter new server swap size, GB (recommended size: equal to server RAM): " -i "64" SWAP_SIZE + + rm -rf sv_manager/ + + if [[ $(which apt | wc -l) -gt 0 ]] + then + pkg_manager=apt + elif [[ $(which yum | wc -l) -gt 0 ]] + then + pkg_manager=yum + fi + + echo "Updating packages..." + $pkg_manager update + echo "Installing ansible, curl, unzip..." + $pkg_manager install ansible curl unzip --yes + + ansible-galaxy collection install ansible.posix + ansible-galaxy collection install community.general + + echo "Downloading Solana validator manager version $sv_manager_version" + cmd="https://github.com/mfactory-lab/sv-manager/archive/refs/tags/$sv_manager_version.zip" + echo "starting $cmd" + curl -fsSL "$cmd" --output sv_manager.zip + echo "Unpacking" + unzip ./sv_manager.zip -d . + + mv sv-manager* sv_manager + rm ./sv_manager.zip + cd ./sv_manager || exit + cp -r ./inventory_example ./inventory + + # shellcheck disable=SC2154 + #echo "pwd: $(pwd)" + #ls -lah ./ + + if [ ! -z $solana_version ] + then + SOLANA_VERSION="--extra-vars {\"agave_version\":\"$agave_version\"}" + fi + if [ ! -z $extra_vars ] + then + EXTRA_INSTALL_VARS="--extra-vars $extra_vars" + fi + if [ ! -z $tags ] + then + TAGS="--tags [$tags]" + fi + + if [ ! -z $skip_tags ] + then + SKIP_TAGS="--skip-tags $skip_tags" + fi + + ansible-playbook --connection=local --inventory ./inventory/$inventory --limit localhost playbooks/pb_config.yaml --extra-vars "{ \ + 'validator_name':'$VALIDATOR_NAME', \ + 'local_secrets_path': '$PATH_TO_VALIDATOR_KEYS', \ + 'swap_file_size_gb': $SWAP_SIZE, \ + 'ramdisk_size_gb': $RAM_DISK_SIZE, \ + }" $SOLANA_VERSION $EXTRA_INSTALL_VARS $TAGS $SKIP_TAGS + + ansible-playbook --connection=local --inventory ./inventory/$inventory --limit localhost playbooks/pb_install_agave_validator.yaml --extra-vars "@/etc/sv_manager/sv_manager.conf" $SOLANA_VERSION $EXTRA_INSTALL_VARS $TAGS $SKIP_TAGS + + echo "### 'Uninstall ansible ###" + + $pkg_manager remove ansible --yes + if [ "$inventory" = "mainnet.yaml" ] + then + echo "WARNING: solana is ready to go. But you must start it by the hand. Use \"systemctl start solana-validator\" command." + fi + + + echo "### Check your dashboard: https://solana.thevalidators.io/d/e-8yEOXMwerfwe/solana-monitoring?&var-server=$VALIDATOR_NAME" + +} + + +while [ $# -gt 0 ]; do + + if [[ $1 == *"--"* ]]; then + param="${1/--/}" + declare ${param}="$2" + # echo $1 $2 // Optional to see the parameter:value result + fi + + shift +done + +sv_manager_version=${sv_manager_version:-latest} + +echo "installing sv manager version $sv_manager_version" + +echo "This script will bootstrap a Solana validator node. Proceed?" +select yn in "Yes" "No"; do + case $yn in + Yes ) install_validator "$sv_manager_version" "$extra_vars" "$solana_version" "$tags" "$skip_tags"; break;; + No ) echo "Aborting install. No changes will be made."; exit;; + esac +done diff --git a/inventory_example/group_vars/mainnet_validators.yaml b/inventory_example/group_vars/mainnet_validators.yaml index 9b7420d..e5fe316 100644 --- a/inventory_example/group_vars/mainnet_validators.yaml +++ b/inventory_example/group_vars/mainnet_validators.yaml @@ -19,5 +19,7 @@ solana_metrics_url: 'https://metrics.solana.com:8086,db=mainnet-beta,u=mainnet-b expected_genesis_hash: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d' limit_ledger_size: 50000000 maximum_local_snapshot_age: 2000 -solana_version: 1.17.28 +solana_version: 1.18.18 +jito_version: 1.18.15 +agave_version: 2.0.2 extra_params: diff --git a/inventory_example/group_vars/testnet_validators.yaml b/inventory_example/group_vars/testnet_validators.yaml index 52f92e5..93dbf0f 100644 --- a/inventory_example/group_vars/testnet_validators.yaml +++ b/inventory_example/group_vars/testnet_validators.yaml @@ -17,5 +17,7 @@ solana_metrics_url: 'https://metrics.solana.com:8086,db=tds,u=testnet_write,p=c4 expected_genesis_hash: '4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY' limit_ledger_size: 50000000 maximum_local_snapshot_age: 1000 -solana_version: 1.18.9 +solana_version: 1.18.17 +jito_version: 1.18.17 +agave_version: 2.0.2 extra_params: diff --git a/playbooks/pb_install_agave_validator.yaml b/playbooks/pb_install_agave_validator.yaml new file mode 100644 index 0000000..4286cff --- /dev/null +++ b/playbooks/pb_install_agave_validator.yaml @@ -0,0 +1,12 @@ +--- +- name: install solana validator + hosts: all + become: yes + roles: + - check_node + - configure_ubuntu + - agave_cli + - solana_validator_bootstrap + - monitoring + vars: + - agave: yes diff --git a/playbooks/pb_install_jito_validator.yaml b/playbooks/pb_install_jito_validator.yaml new file mode 100644 index 0000000..0798724 --- /dev/null +++ b/playbooks/pb_install_jito_validator.yaml @@ -0,0 +1,12 @@ +--- +- name: install solana validator + hosts: all + become: yes + roles: + - check_node + - configure_ubuntu + - solana_cli + - solana_validator_bootstrap + - monitoring + vars: + - jito: yes diff --git a/roles/agave_cli/tasks/install.yaml b/roles/agave_cli/tasks/install.yaml new file mode 100644 index 0000000..c94fcee --- /dev/null +++ b/roles/agave_cli/tasks/install.yaml @@ -0,0 +1,34 @@ +--- +- name: create download dir + file: + path: /tmp/solana + state: directory + owner: "{{ solana_user }}" + group: "{{ solana_user }}" + tags: + - cli.install + +- name: install solana + block: + - name: download latest solana release installer + get_url: + url: "https://release.anza.xyz/v{{ agave_version | default('stable') }}/install" + dest: /tmp/solana/ + mode: 0755 + + - name: run solana installer + shell: /tmp/solana/install + become: yes + become_user: "{{ solana_user }}" + tags: + - cli.install + +- name: remove installer + file: + path: /tmp/solana + state: absent + tags: + - cli.install + + + diff --git a/roles/agave_cli/tasks/main.yaml b/roles/agave_cli/tasks/main.yaml new file mode 100644 index 0000000..08b4501 --- /dev/null +++ b/roles/agave_cli/tasks/main.yaml @@ -0,0 +1,31 @@ +--- +- name: set force install fact + set_fact: + force: "{{ force | default('false') }}" + tags: + - cli + - cli.install + - cli.update + +- name: check solana cli installed + stat: + path: /home/solana/.local/share/solana/install/active_release/bin/agave-install + register: solana_exists + tags: + - cli + - cli.install + - cli.update + +- name: install solana cli + import_tasks: install.yaml + tags: + - cli + - cli.install + when: force == 'true' or not solana_exists.stat.exists + +- name: update solana cli + import_tasks: update.yaml + tags: + - cli + - cli.update + when: force != 'true' and solana_exists.stat.exists diff --git a/roles/agave_cli/tasks/update.yaml b/roles/agave_cli/tasks/update.yaml new file mode 100644 index 0000000..5cff186 --- /dev/null +++ b/roles/agave_cli/tasks/update.yaml @@ -0,0 +1,12 @@ +- name: DEBUG + debug: + msg: "Updating Solana to {{ agave_version }}" + +- name: update solana (agave) + shell: "agave-install init {{ agave_version }}" + become: yes + become_user: "{{ solana_user }}" + environment: + PATH: "{{ solana_home }}/.local/share/solana/install/active_release/bin" + tags: + - cli.update diff --git a/roles/solana_cli/tasks/install.yaml b/roles/solana_cli/tasks/install.yaml index a54a407..39e1659 100644 --- a/roles/solana_cli/tasks/install.yaml +++ b/roles/solana_cli/tasks/install.yaml @@ -22,6 +22,23 @@ become_user: "{{ solana_user }}" tags: - cli.install + when: jito is not defined or not jito + +- name: install JITO solana + block: + - name: download latest jito release installer + get_url: + url: "https://release.jito.wtf/v{{ jito_version | default('stable') }}-jito/install" + dest: /tmp/solana/ + mode: 0755 + + - name: run jito installer + shell: /tmp/solana/install + become: yes + become_user: "{{ solana_user }}" + tags: + - cli.install + when: jito is defined and jito - name: remove installer file: diff --git a/roles/solana_validator_bootstrap/templates/solana-validator.service.j2 b/roles/solana_validator_bootstrap/templates/solana-validator.service.j2 index 08092ac..6bdbbe8 100644 --- a/roles/solana_validator_bootstrap/templates/solana-validator.service.j2 +++ b/roles/solana_validator_bootstrap/templates/solana-validator.service.j2 @@ -11,7 +11,11 @@ User={{ solana_user }} LimitNOFILE=1000000 Environment="PATH=/bin:/usr/bin:{{ env_path }}" Environment="SOLANA_METRICS_CONFIG=host={{ solana_metrics_url }}" +{% if agave is defined and agave %} +ExecStart={{ env_path }}/agave-validator \ +{% else %} ExecStart={{ env_path }}/solana-validator \ +{% endif %} --identity {{ secrets_path }}/validator-keypair.json \ {% if not rpc_node %} --vote-account {{ secrets_path }}/vote-account-keypair.json \ @@ -50,6 +54,15 @@ ExecStart={{ env_path }}/solana-validator \ --ledger {{ ledger_path }} \ --accounts {{ accounts_path }} \ --snapshots {{ snapshots_path }} \ +{% if jito is defined and jito %} +--relayer-url http://frankfurt.mainnet.relayer.jito.wtf:8100 \ +--block-engine-url https://frankfurt.mainnet.block-engine.jito.wtf \ +--shred-receiver-address 145.40.93.84:1002 \ +--tip-payment-program-pubkey T1pyyaTNZsKv2WcRAB8oVnk93mLJw2XzjtVYqCsaHqt \ +--tip-distribution-program-pubkey 4R3gSG8BpU4t19KYj8CfnbtRpnT8gtk4dvTHxVRwc2r7 \ +--merkle-root-upload-authority GZctHpWXmsZC1YHACTGGcHhYxjdRqQvTpYkb9LMvxDib \ +--commission-bps 800 \ +{% endif %} --dynamic-port-range {{ open_solana_ports_start }}-{{ open_solana_ports_end }} diff --git a/roles/solana_validator_restart/tasks/wait_for_restart_window.yaml b/roles/solana_validator_restart/tasks/wait_for_restart_window.yaml index bcc5720..a9afe84 100644 --- a/roles/solana_validator_restart/tasks/wait_for_restart_window.yaml +++ b/roles/solana_validator_restart/tasks/wait_for_restart_window.yaml @@ -7,6 +7,17 @@ environment: PATH: "{{ env_path }}" ignore_errors: True - when: wait_for_window + when: wait_for_window and agave is not defined tags: - validator.manage.restart.wait + +- name: wait for restarting window + become: yes + become_user: "{{ solana_user }}" + shell: agave-validator --ledger {{ ledger_path }} wait-for-restart-window --max-delinquent-stake {{ max_delinquent_stake }} + environment: + PATH: "{{ env_path }}" + ignore_errors: True + when: wait_for_window and agave is defined and agave + tags: + - validator.manage.restart.wait \ No newline at end of file