Skip to content

Commit

Permalink
feat: improve penumbra playbooks & fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Catopish committed Dec 24, 2024
1 parent 0fb7eb1 commit 8b0a2e6
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 24 deletions.
14 changes: 8 additions & 6 deletions group_vars/cumulus.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
default_base_path: /opt/cumulus
default_chain_spec_dl_url: https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/cumulus/parachains/chain-specs/{{
default_chain_spec_dl_url:
https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/cumulus/parachains/chain-specs/{{
default_network }}.json
default_client_version: polkadot-stable2412
default_database: paritydb
default_database_path: '{{ default_base_path }}/chains'
default_database_path: "{{ default_base_path }}/chains"
default_download_base_url: https://github.com/paritytech/polkadot-sdk/releases/download/
default_download_url: '{{ default_download_base_url }}{{ default_client_version }}/polkadot-parachain'
default_group: '{{ service_users[''cumulus''] }}'
default_download_url: "{{ default_download_base_url }}{{ default_client_version }}/polkadot-parachain"
default_group: "{{ service_users['cumulus'] }}"
default_in_peers: 32
default_log_level: info
default_network: asset-hub-polkadot
Expand All @@ -19,7 +21,7 @@ default_prom_port: 7400
default_rpc_port: 9400
default_secure_rpc_port: 42400
default_service: cumulus
default_storage: '{{ default_base_path }}/chains'
default_storage: "{{ default_base_path }}/chains"
default_telemetry_url: wss://telemetry-backend.w3f.community/submit/ 1
default_user: '{{ service_users[''cumulus''] }}'
default_user: "{{ service_users['cumulus'] }}"
zabbix_ext_port: 10400
6 changes: 5 additions & 1 deletion group_vars/penumbra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
penumbra_version: "0.81.0"
penumbra_chain_id: ""
cometbft_version: "0.37.14"
polkachu_version: "2665270"

# dl locations
default_git_repo: "https://github.com/penumbra-zone/penumbra"
penumbra_download_pcli_url: "https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pcli-installer.sh"
penumbra_download_pd_url: "https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pd-installer.sh"
penumbra_download_pclientd_url: "https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pclientd-installer.sh"
cometbft_download_url: "https://github.com/cometbft/cometbft/releases/download/v{{ cometbft_version }}/cometbft_{{ cometbft_version }}_linux_amd64.tar.gz"
default_git_repo: "https://github.com/penumbra-zone/penumbra"
polkachu_download_url: "wget -O penumbra_{{ polkachu_version }}.tar.lz4 https://snapshots.polkachu.com/snapshots/penumbra/penumbra_{{ polkachu_version }}.tar.lz4 --inet4-only"

# service/user
penumbra_service: "penumbra"
Expand All @@ -22,6 +24,8 @@ default_storage_path: "{{ default_home_path }}/data"
default_config_path: "{{ default_home_path }}/config"
default_log_path: "{{ default_home_path }}/logs"
default_script_path: "{{ default_home_path }}/scripts"
default_database_path: "{{ default_home_path }}/network_data"
default_installation_path: "/home/{{ default_user }}/.cargo/bin"

default_network: "penumbra"
default_node_type: "validator"
Expand Down
29 changes: 27 additions & 2 deletions roles/setup_install_penumbra/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
---
- name: Stop Penumbra
ansible.builtin.systemd:
name: pclientd
name: pd
state: stopped
enabled: True

- name: Stop Cometbft
ansible.builtin.systemd:
name: cometbft
state: stopped
enabled: True

- name: Symlink cometbft & pd service to systemd
ansible.builtin.file:
src: "{{ default_home_path }}/{{ item }}.service"
dest: "/etc/systemd/system/{{ item }}.service"
state: link
force: True
owner: "root"
group: "root"
mode: "0644"
loop:
- pd
- cometbft

- name: Systemd daemon-reload
ansible.builtin.systemd:
daemon_reload: True

- name: Start Cometbft
ansible.builtin.systemd:
name: cometbft
state: started
enabled: True

- name: Start Penumbra
ansible.builtin.systemd:
name: pclientd
name: pd
state: started
enabled: True

Expand Down
116 changes: 104 additions & 12 deletions roles/setup_install_penumbra/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,136 @@

- name: Download and install pcli
ansible.builtin.shell:
cmd: "set -o pipefail && curl --proto '=https' --tlsv1.2 -LsSf https://github.com/penumbra-zone/penumbra/releases/download/v{{ default_client_version }}/pcli-installer.sh | sh"
cmd: "set -o pipefail && curl --proto '=https' --tlsv1.2 -LsSf https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pcli-installer.sh | sh"
become: True
become_user: "{{ default_user }}"
when: ansible_local['noderole']['node']['version'] != default_client_version
when: ansible_local['noderole']['node']['version'] != penumbra_version
args:
warn: False
executable: /bin/bash

- name: Download and install pd
ansible.builtin.shell:
cmd: "set -o pipefail && curl --proto '=https' --tlsv1.2 -LsSf https://github.com/penumbra-zone/penumbra/releases/download/v{{ default_client_version }}/pd-installer.sh | sh"
cmd: "set -o pipefail && curl --proto '=https' --tlsv1.2 -LsSf https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pd-installer.sh | sh"
become: True
become_user: "{{ default_user }}"
when: ansible_local['noderole']['node']['version'] != default_client_version
when: ansible_local['noderole']['node']['version'] != penumbra_version
args:
warn: False
executable: /bin/bash

- name: Download and install pclientd
ansible.builtin.shell:
cmd: "set -o pipefail && curl --proto '=https' --tlsv1.2 -LsSf https://github.com/penumbra-zone/penumbra/releases/download/v{{ default_client_version }}/pclientd-installer.sh | sh"
cmd: "set -o pipefail && curl --proto '=https' --tlsv1.2 -LsSf https://github.com/penumbra-zone/penumbra/releases/download/v{{ penumbra_version }}/pclientd-installer.sh | sh"
become: True
become_user: "{{ default_user }}"
when: ansible_local['noderole']['node']['version'] != default_client_version
when: ansible_local['noderole']['node']['version'] != penumbra_version
args:
warn: False
executable: /bin/bash

- name: Download and install cometbft
- name: Download cometbft
ansible.builtin.get_url:
url: "{{ cometbft_download_url }}"
dest: "{{ default_home_path }}"
mode: "u+r+x"
owner: "{{ default_user }}"
group: "{{ default_user }}"
when: ansible_local['noderole']['node']['version'] != default_client_version
when: ansible_local['noderole']['node']['version'] != cometbft_version

- name: Generate network config
ansible.builtin.command:
cmd: "./polkadot key generate-node-key --file {{ default_base_path }}/chains/{{ default_chains_name }}/network/secret_ed25519"
chdir: "{{ default_base_path }}"
- name: Unpack cometbft
ansible.builtin.unarchive:
src: "{{ default_home_path }}/cometbft_{{ cometbft_version }}_linux_amd64.tar.gz"
dest: "{{ default_home_path }}"
remote_src: True
owner: "{{ default_user }}"
group: "{{ default_user }}"
mode: "u+r+x"
when: ansible_local['noderole']['node']['version'] != cometbft_version

- name: Create soft links for penumbra binaries
ansible.builtin.file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
state: link
owner: "{{ default_user }}"
group: "{{ default_user }}"
loop:
- src: "{{ default_installation_path }}/pd"
dest: "{{ default_home_path }}/pd"
- src: "{{ default_installation_path }}/pcli"
dest: "{{ default_home_path }}/pcli"
- src: "{{ default_installation_path }}/pclientd"
dest: "{{ default_home_path }}/pclientd"

- name: Install lz4 package
ansible.builtin.package:
name: lz4
state: present
become: True
become_user: root

- name: Check if cometbft directory exists
ansible.builtin.stat:
path: "{{ default_database_path }}/node0/cometbft"
register: cometbft_dir

- name: Create node0 directory if it doesn't exist
ansible.builtin.file:
path: "{{ default_database_path }}/node0"
state: directory
mode: "0750"
owner: "{{ default_user }}"
group: "{{ default_user }}"
when: not cometbft_dir.stat.exists

- name: Download Polkachu Cometbft snapshot
ansible.builtin.get_url:
url: "{{ polkachu_download_url }}"
dest: "{{ default_database_path }}/node0/"
mode: "u+r+x"
owner: "{{ default_user }}"
group: "{{ default_user }}"
when: not cometbft_dir.stat.exists

- name: Extract and decompress Polkachu snapshot
ansible.builtin.shell:
cmd: "set -o pipefail && lz4 -c -d {{ default_database_path }}/node0/penumbra_{{ polkachu_version }}.tar.lz4 | tar -x -C {{ default_database_path }}/node0/"
args:
executable: /bin/bash
creates: "{{ default_database_path }}/node0/cometbft"
become: true
become_user: "{{ default_user }}"
when: not cometbft_dir.stat.exists

- name: Remove lz4 archive after decompression
ansible.builtin.file:
path: "{{ default_database_path }}/node0/penumbra_{{ polkachu_version }}.tar.lz4"
state: absent
when: not cometbft_dir.stat.exists

- name: Copy Cometbft & pd service templates
ansible.builtin.template:
src: "{{ item }}.service.j2"
dest: "{{ default_home_path }}/{{ item }}.service"
owner: "{{ default_user }}"
group: "{{ default_user }}"
mode: "0640"
loop:
- pd
- cometbft

- name: Flush handlers after service copy
ansible.builtin.meta: flush_handlers

- name: Ensure cometbft service is running
ansible.builtin.systemd:
name: cometbft
state: started
enabled: True

- name: Ensure pd service is running
ansible.builtin.systemd:
name: pd
state: started
enabled: True
2 changes: 1 addition & 1 deletion roles/setup_install_penumbra/templates/cometbft.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Description=CometBFT for Penumbra

[Service]
ExecStart={{ default_home_path }}/cometbft start --home /home/penumbra/.penumbra/network_data/node0/cometbft
ExecStart={{ default_home_path }}/cometbft start --home {{ default_database_path }}/node0/cometbft
Restart=no
User=penumbra
# Raise filehandle limit for RPC and P2P connections.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Unit]
Description=Penumbra pd
Description=Penumbra Node
Wants=cometbft.service

[Service]
# Support binding to 443/TCP for HTTPS.
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE

ExecStart={{ default_home_path }}/pd start
ExecStart={{ default_home_path }}/pd start --home {{ default_database_path }}/node0/pd
# Consider adding an HTTPS URL if you have DNS set up:
# ExecStart=/usr/local/bin/pd start --grpc-auto-https www.example.com

Expand Down

0 comments on commit 8b0a2e6

Please sign in to comment.