-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore building validator binary from source
- Loading branch information
1 parent
e9de63b
commit 766cebe
Showing
8 changed files
with
744 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
- name: set facts | ||
set_fact: | ||
tmp_install_path: /tmp/validator-build | ||
docker_builder_name: "validator-builder" | ||
docker_exec_command: "docker exec -i" | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: create download dir | ||
file: | ||
path: "{{ tmp_install_path }}" | ||
state: directory | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: install docker | ||
shell: "wget -qO- https://get.docker.com | bash" | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: enable and start docker service | ||
systemd: | ||
name: docker | ||
enabled: true | ||
state: started | ||
daemon_reload: true | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: check previously running rust container | ||
shell: "docker ps -a | grep {{ docker_builder_name }}" | ||
register: container_present | ||
failed_when: "container_present.rc not in [0,1]" | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: kill previously running rust container | ||
shell: "docker stop {{ docker_builder_name }};docker rm {{ docker_builder_name }}" | ||
become: yes | ||
when: container_present.stdout|length > 0 | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: run docker rust container for build validator binary | ||
shell: "docker run --name {{ docker_builder_name }} --rm --network host -d -v {{ tmp_install_path }}:{{ tmp_install_path }} -v {{ validator_bin_path }}:{{ validator_bin_path }} rust:bullseye sleep 99999999" | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: git load validator source | ||
shell: "{{ docker_exec_command }} {{ docker_builder_name }} bash -c 'cd {{ tmp_install_path }};git clone {{ github_source }} --recurse-submodules .;git checkout tags/{{ github_source_tag }};git submodule update --init --recursive'" | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: install dependencies for build binary | ||
shell: "{{ docker_exec_command }} {{ docker_builder_name }} bash -c 'rustup component add rustfmt;rustup update;apt update;apt install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler -y'" | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: build binary | ||
shell: "{{ docker_exec_command }} {{ docker_builder_name }} bash -c 'CI_COMMIT=$(git rev-parse HEAD) {{ tmp_install_path }}/scripts/cargo-install-all.sh --validator-only {{ validator_bin_path }}'" | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: stop and rm build container | ||
shell: "docker stop {{ docker_builder_name }}" | ||
become: yes | ||
tags: | ||
- cli.install | ||
- cli.make | ||
|
||
- name: clear tmp install dir | ||
file: | ||
path: "{{ tmp_install_path }}" | ||
state: absent | ||
tags: | ||
- cli.install | ||
- cli.make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
|
||
- name: set force install fact | ||
set_fact: | ||
force: "{{ force | default('false') }}" | ||
validator_bin_path: "{{ validator_app_path }}/releases/{{ solana_version }}-jito" | ||
tags: | ||
- cli | ||
- cli.install | ||
- cli.update | ||
- cli.make | ||
|
||
- name: Load config | ||
include_vars: | ||
file: "{{ sv_manager_config_path }}" | ||
become: yes | ||
|
||
- name: check validator bin installed | ||
stat: | ||
path: "{{ validator_bin_path }}/bin/{{ validator_binary }}" | ||
register: validator_bin | ||
tags: | ||
- cli | ||
- cli.install | ||
- cli.update | ||
- cli.make | ||
|
||
- name: build validator binary | ||
import_tasks: build.yaml | ||
tags: | ||
- cli | ||
- cli.install | ||
when: force or not validator_bin.stat.exists | ||
|
||
- name: install solana-snapshot-finder | ||
import_tasks: solana_snapshot_finder.yaml | ||
tags: | ||
- cli | ||
- cli.snapshot-finder | ||
when: with_snapshot_finder | ||
|
||
- name: change ownership of a directory | ||
file: | ||
path: "{{ validator_app_path }}" | ||
state: directory | ||
recurse: yes | ||
owner: "{{ validator_user }}" | ||
group: "{{ validator_user }}" | ||
tags: | ||
- cli | ||
- cli.install | ||
|
||
- name: remove old symbolic link | ||
file: | ||
path: "{{ validator_app_path }}/active_release" | ||
state: absent | ||
tags: | ||
- cli | ||
- cli.install | ||
|
||
- name: create new symbolic link | ||
file: | ||
src: "{{ validator_bin_path }}" | ||
dest: "{{ validator_app_path }}/active_release" | ||
owner: "{{ validator_user }}" | ||
group: "{{ validator_user }}" | ||
state: link | ||
tags: | ||
- cli | ||
- cli.install | ||
|
||
- name: Create validator path profile file | ||
template: | ||
src: validator.sh | ||
dest: /etc/profile.d/validator.sh | ||
mode: 0644 | ||
owner: root | ||
group: root | ||
tags: | ||
- cli | ||
- cli.binary-path.profile | ||
|
||
#- name: "Add {{ solana_bin_path }}/active_release/bin to PATH if does not exist" | ||
# lineinfile: | ||
# path: /etc/environment | ||
# line: 'PATH="$PATH:{{ solana_bin_path }}/active_release/bin"' | ||
# insertafter: EOF | ||
# when: lookup('file', '/etc/environment') is not search('^\s*PATH\s*=') | ||
# | ||
#- name: 'Add {{ solana_bin_path }}/active_release/bin to PATH' | ||
# lineinfile: | ||
# path: /etc/environment | ||
# regexp: 'PATH=(["])((?!.*?{{ solana_bin_path }}/active_release/bin).*?)(["])$' | ||
# line: 'PATH=\1\2:{{ solana_bin_path }}/active_release/bin\3' | ||
# backrefs: yes |
34 changes: 34 additions & 0 deletions
34
roles/validator_cli_build/tasks/solana_snapshot_finder.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
|
||
- name: cli | get solana snapshot finder | ||
copy: | ||
src: files/solana-snapshot-finder | ||
dest: "{{ solana_home }}/solana-snapshot-finder" | ||
owner: "{{ solana_user }}" | ||
group: "{{ solana_user }}" | ||
mode: 0755 | ||
tags: | ||
- cli | ||
- cli.snapshot-finder | ||
|
||
#- name: cli | add python env in solana-snapshot-finder file | ||
# lineinfile: | ||
# path: "{{ env_path }}/solana-snapshot-finder" | ||
# insertbefore: BOF | ||
# line: "#!/usr/bin/env python3" | ||
# tags: | ||
# - cli | ||
# - cli.snapshot-finder | ||
|
||
- name: cli | install requirements | ||
pip: | ||
name: | ||
- requests | ||
- tqdm | ||
executable: pip3 | ||
async: 360 | ||
poll: 5 | ||
tags: | ||
- cli | ||
- cli.snapshot-finder | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#https://github.com/jito-foundation/jito-solana/archive/refs/tags/v1.14.19-jito.tar.gz | ||
#- name: "Update solana jito to {{ solana_version }}" | ||
|
||
|
||
- name: "Update Solana to {% if solana_version is defined %}v{{ solana_version }}{% else %}stable{% endif %}" | ||
shell: "solana-install init -d {{ solana_app_path }} {% if solana_version is defined %}v{{ solana_version }}{% else %}stable{% endif %}" | ||
become: yes | ||
become_user: "{{ solana_user }}" | ||
environment: | ||
PATH: "{{ env_path }}" | ||
tags: | ||
- cli.update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
if [ -d "{{ validator_app_path }}/active_release/bin" ] ; then | ||
export PATH="$PATH:{{ validator_app_path }}/active_release/bin" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
validator_binary: agave-validator | ||
validator_install_binary: agave-install | ||
install_script_url: "https://release.anza.xyz/{% if validator_version is defined %}v{{ validator_version }}{% else %}stable{% endif %}/install" | ||
github_source_tag: "v{{ validator_version }}" | ||
github_source: "https://github.com/anza-xyz/agave.git" | ||
agave_validator: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
validator_binary: "{% if validator_version.split('.') | map('int') | list > '2.0.0'.split('.') | map('int') | list %}agave-validator{% else %}solana-validator{% endif %}" | ||
validator_install_binary: "{% if validator_version.split('.') | map('int') | list > '2.0.0'.split('.') | map('int') | list %}agave-install{% else %}solana-install{% endif %}" | ||
install_script_url: "https://raw.githubusercontent.com/jito-foundation/jito-solana/v{{ validator_version }}-jito/install/{% if validator_version.split('.') | map('int') | list > '2.0.0'.split('.') | map('int') | list %}agave-install-init.sh{% else %}solana-install-init.sh{% endif %}" | ||
github_source_tag: "v{{ validator_version }}-jito" | ||
github_source: "https://github.com/jito-foundation/jito-solana.git" | ||
jito_validator: true |