Skip to content

Commit

Permalink
agave transition
Browse files Browse the repository at this point in the history
  • Loading branch information
Rossignolskier committed Jul 12, 2024
1 parent 77aa761 commit 8f8b78e
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 3 deletions.
136 changes: 136 additions & 0 deletions install/install_agave_validator.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion inventory_example/group_vars/mainnet_validators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
4 changes: 3 additions & 1 deletion inventory_example/group_vars/testnet_validators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
12 changes: 12 additions & 0 deletions playbooks/pb_install_agave_validator.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions playbooks/pb_install_jito_validator.yaml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions roles/agave_cli/tasks/install.yaml
Original file line number Diff line number Diff line change
@@ -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



31 changes: 31 additions & 0 deletions roles/agave_cli/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions roles/agave_cli/tasks/update.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions roles/solana_cli/tasks/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 }}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8f8b78e

Please sign in to comment.