Skip to content

Commit

Permalink
add reth
Browse files Browse the repository at this point in the history
  • Loading branch information
hitchhooker committed Feb 25, 2024
1 parent b5a9f3d commit 511c6a1
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 4 deletions.
39 changes: 39 additions & 0 deletions group_vars/reth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
default_block_output_to_private_ip: True

# Ligthhouse
ethereum_lighthouse_version: "4.6.0"
ethereum_lighthouse_download_url: "https://github.com/sigp/lighthouse/releases/download/v{{ ethereum_lighthouse_version }}/lighthouse-v{{ ethereum_lighthouse_version }}-x86_64-unknown-linux-gnu-portable.tar.gz"
ethereum_lighthouse_nodetype: "beacon_node"
ethereum_lighthouse_host: "0.0.0.0"
ethereum_lighthouse_port: 8551
ethereum_lighthouse_beacon_port: 9000
ethereum_lighthouse_checkpoint_url: "https://beaconstate.info"

reth_version: "0.1.0-alpha.19"
reth_download_url: "https://github.com/paradigmxyz/reth/releases/download/v{{ reth_version }}/reth-v{{ reth_version }}-x86_64-unknown-linux-gnu.tar.gz"
reth_github_url: "https://github.com/paragidmxyz/reth/"
reth_service: "reth"
ethereum_user: "{{ service_users['reth'] }}"
ethereum_base: "/opt/reth"
reth_build_path: "{{ ethereum_base }}/reth-{{ reth_version }}"
reth_bin_path: "{{ reth_build_path }}/build/bin"
ethereum_storage_path: "{{ ethereum_base }}/storage"
ethereum_jwtsecret_file: "{{ ethereum_storage_path }}/jwt.hex"
reth_config_path: "{{ ethereum_base }}/config"
reth_private_api_addr: "localhost:9090"
reth_addr: "0.0.0.0"
reth_corsdomain: "*"
reth_pruned_flags: "--prune hrtc"
ethereum_syncmode: "archive"

reth_eth: False
reth_eth_p2p_port: 30303
reth_eth_p2p2_port: 30304
reth_eth_http_port: 8545
reth_eth_ws_port: 8546
reth_eth_bt_port: 42069
reth_eth_sentry_port: 4000
reth_eth_sentry2_port: 4001
reth_eth_http_api: "engine,eth,reth,ots,web3,net,debug,trace,txpool,shh"
...
68 changes: 68 additions & 0 deletions host_vars/bkk07.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
host_name: "bkk06.rotko.net"
host_timezone: "Asia/Bangkok"
ansible_host: "27.131.160.106"
ansible_port: "20787"
role: "proxmox"

kernel_modules:
- k10temp

default_kvm_host: "192.168.77.10"
default_kvm_port: "20797"
default_need_routeros_port_forwarding: True
routeros_delegate_host: "bkk00"
default_need_iptables_port_forwarding: False
default_container_template: "debian-12-standard_12.2-1_amd64.tar.zst"
default_gw_device: "eno1"
default_storage: "tank07lvm"
default_resource_pool: "bkk07_resource_pool"
default_max_cores: 192

port_forwards:
- from_port: "{{ ansible_port }}"
to_host: "{{ container_ip }}:22"
protocol: "tcp"

lxc_nodes:
- host: "eth01"
proxmox_config:
vmid: "101"
hostname: "{{ hostvars['eth01']['host_name'] }}"
ostemplate: 'local:vztmpl/{{ default_container_template }}'
netif: "{{ hostvars['eth01']['netif'] }}"
cores: 16
memory: 32678
swap: 32678
password: s4l4k4l4!
disk: "{{ default_storage }}:20"
mounts: '{"mp0":"{{ default_storage }}:4000,mp={{ hostvars["eth01"]["ethereum_storage_path"] }}"}'
onboot: True
unprivileged: True
validate_certs: False
description: "Rust Ethereum archive node: {{ hostvars['eth01']['host_name'] }}"
state: present
features:
- nesting=1
port_forwards:
- from_port: "50002"
to_host: "{{ hostvars['eth01']['container_ip'] }}:10050"
protocol: "tcp"
- from_port: "{{ hostvars['eth01']['ansible_port'] }}"
to_host: "{{ hostvars['eth01']['container_ip'] }}:22"
protocol: "tcp"
- from_port: "{{ hostvars['eth01']['reth_eth_ws_port'] }}"
to_host: "{{ hostvars['eth01']['container_ip'] }}:{{ hostvars['eth01']['reth_eth_http_port'] }}"
protocol: "tcp"
- from_port: "{{ hostvars['eth01']['reth_eth_http_port'] }}"
to_host: "{{ hostvars['eth01']['container_ip'] }}:{{ hostvars['eth01']['reth_eth_ws_port'] }}"
protocol: "tcp"
- from_port: "{{ hostvars['eth01']['reth_eth_p2p_port'] }}"
to_host: "{{ hostvars['eth01']['container_ip'] }}:{{ hostvars['eth01']['reth_eth_p2p_port'] }}"
protocol: "tcp"
- from_port: "{{ hostvars['eth01']['reth_eth_p2p_port'] }}"
to_host: "{{ hostvars['eth01']['container_ip'] }}:{{ hostvars['eth01']['reth_eth_p2p_port'] }}"
protocol: "udp"
- from_port: "{{ hostvars['eth01']['reth_eth_p2p_port'] }}"
to_host: "{{ hostvars['eth01']['container_ip'] }}:{{ hostvars['eth01']['reth_eth_bt_port'] }}"
protocol: "tcp"
14 changes: 14 additions & 0 deletions host_vars/eth01.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# helnode02 - ethereum01 - reth node
ansible_host: "95.216.235.72"
container_ip: "192.168.72.101"
default_nat_network_forward_cidr: 192.168.72.1/16
ansible_port: "2101"
host_name: "ethereum01.ct.romenet.io"
host_timezone: "Europe/Helsinki"
netif: '{"net0":"name=eth0,gw={{ default_nat_network_forward_cidr.split("/")[0] }},ip={{ container_ip }}/16,bridge={{ default_nat_device }}"}'
role: "reth"
erigon_eth: True
pruned: False
pinned_service: True
...
8 changes: 8 additions & 0 deletions playbooks/reth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Rust Ethereum(reth) Node
hosts: reth
gather_facts: True
roles:
- setup_add_node_role
- setup_install_reth
...
14 changes: 14 additions & 0 deletions roles/setup_add_node_role/handlers/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@
mode: '0644'
when: role == "erigon"

- name: Add Reth service version
community.general.ini_file:
create: True
no_extra_spaces: True
option: "version"
section: "node"
state: present
value: "{{ reth_version }}"
path: "{{ noderole_file }}"
owner: root
group: root
mode: '0644'
when: role == "reth"

- name: Add Evmos service version
community.general.ini_file:
create: True
Expand Down
8 changes: 4 additions & 4 deletions roles/setup_add_node_role/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
- not noderole_result.stat.exists
with_items:
- { section: "node", option: "role", value: "{{ role }}" }
- { section: "node", option: "version", value: "" }
- { section: "node", option: "go_version", value: "" }
- { section: "node", option: "version", value: "undefined" }
- { section: "node", option: "go_version", value: "undefined" }
- { section: "node", option: "pinned", value: "False" }
- { section: "node", option: "type", value: "" }
- { section: "node", option: "type", value: "undefined" }

- name: Add default lighthouse fact to /etc/ansible/facts.d/noderole
community.general.ini_file:
Expand All @@ -41,6 +41,6 @@
mode: '0644'
when:
- not noderole_result.stat.exists
- role == "ethereum"
- role == "ethereum" or role == "reth"
with_items:
- { section: "lighthouse", option: "version", value: "undefined" }
49 changes: 49 additions & 0 deletions roles/setup_install_reth/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Standards: 0.2
---
- name: Symlink Reth client
ansible.builtin.file:
src: "{{ ethereum_base }}/{{ reth_version }}/reth"
dest: "{{ ethereum_base }}/reth"
force: True
state: link
owner: "{{ ethereum_user }}"
group: "{{ ethereum_user }}"

- name: Symlink Reth service
ansible.builtin.file:
src: "{{ ethereum_base }}/reth.service"
dest: "/etc/systemd/system/reth.service"
force: True
state: link
owner: root
group: root

- name: Enable Reth
ansible.builtin.service:
name: reth
enabled: True

- name: Restart Reth
ansible.builtin.service:
name: reth
state: restarted
enabled: True

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

- name: Stop Reth
ansible.builtin.systemd:
name: reth
daemon_reload: True
state: stopped
enabled: True

- name: Start Reth
ansible.builtin.systemd:
name: reth
daemon_reload: True
state: started
enabled: True
...
15 changes: 15 additions & 0 deletions roles/setup_install_reth/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Standards: 0.2
---
galaxy_info:
author: Tommi Niemi <[email protected]>
description: Install or upgrade Reth client
min_ansible_version: 3.0
platforms:
- name: Debian
versions:
- bullseye
- bookworm
dependencies:
- role: setup_install_rust
- role: setup_add_node_role
...
114 changes: 114 additions & 0 deletions roles/setup_install_reth/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Standards: 0.2
---
- name: Ensure group {{ ethereum_user }} exists
ansible.builtin.group:
name: "{{ ethereum_user }}"
state: present
system: True

- name: Ensure user {{ ethereum_user }} exists
ansible.builtin.user:
append: True
comment: Reth service user
create_home: True
group: "{{ ethereum_user }}"
groups: sudo
home: "{{ ethereum_base }}"
name: "{{ ethereum_user }}"
shell: "{{ default_shell }}"
state: present
system: True

- name: Update .profile
ansible.builtin.blockinfile:
path: "{{ ethereum_base }}/.profile"
owner: "{{ ethereum_user }}"
group: "{{ ethereum_user }}"
create: True
mode: "644"
block: |
CARGO_HOME="$HOME/.cargo"
RUSTUP_HOME="$HOME/.rustup"
PATH="$CARGO_HOME/bin:$PATH"
- name: Ensure required directories exists
ansible.builtin.file:
path: "{{ item }}"
owner: "{{ ethereum_user }}"
group: "{{ ethereum_user }}"
mode: "0775"
state: directory
with_items:
- "{{ ethereum_base }}"
- "{{ ethereum_storage_path }}"
- "{{ ethereum_base }}/{{ reth_version }}"

- name: Create jwtsecret file
become: True
become_user: "{{ ethereum_user }}"
ansible.builtin.shell:
cmd: |
set -o pipefail
echo 0x$(openssl rand -hex 32 | tr -d "\n") > {{ ethereum_jwtsecret_file }}
creates: "{{ ethereum_jwtsecret_file }}"
executable: /bin/bash
when: ansible_local['noderole']['node']['pinned'] != "True"

- name: Download and extract reth binary
ansible.builtin.unarchive:
src: "{{ reth_download_url }}"
dest: "{{ ethereum_base }}/{{ reth_version }}"
remote_src: True
mode: '0755'
owner: "{{ ethereum_user }}"
group: "{{ ethereum_user }}"
when:
- ansible_local['noderole']['node']['pinned'] != "True"
- ansible_local['noderole']['node']['version'] != reth_version
notify:
- Symlink Reth client
- Add Service Pinned Status
- Stop Reth
- Systemd daemon-reload
- Start Reth
- Add Reth service version

# - name: Make client reth v{{ reth_version }}
# ansible.builtin.shell: "source {{ ethereum_base }}/.profile && make reth"
# args:
# executable: /bin/bash
# chdir: "{{ reth_build_path }}"
# become: True
# become_user: "{{ ethereum_user }}"
# register: reth_install
# when:
# - ansible_local['noderole']['node']['pinned'] != "True"
# - ansible_local['noderole']['node']['version'] != reth_version
# notify:
# - Symlink Reth client
# - Add Service Pinned Status
# - Stop Reth
# - Systemd daemon-reload
# - Start Reth
# - Add Reth service version
#

- name: Copy reth systemd service to a host
ansible.builtin.template:
src: reth.service.j2
dest: "{{ ethereum_base }}/reth.service"
owner: "{{ ethereum_user }}"
group: "{{ ethereum_user }}"
mode: "0644"
register: reth_service
notify:
- Stop Reth
- Symlink Reth service
- Systemd daemon-reload
- Start Reth

- name: Install lighthouse of node configs require it.
ansible.builtin.include_role:
name: setup_install_lighthouse
when: ethereum_syncmode != "light"
...
37 changes: 37 additions & 0 deletions roles/setup_install_reth/templates/reth.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[Unit]
Description=Rust Ethereum client
Wants=network-online.target
After=network.target network-online.target

[Service]
User={{ ethereum_user }}
Group={{ ethereum_user }}
LimitNOFILE={{ default_max_open_files_in_service }}
Environment=HOME={{ ethereum_base }}
Type=simple
ExecStart={{ ethereum_base }}/reth node \
--chain mainnet \
--datadir {{ ethereum_storage_path }} \
--discovery.port {{ reth_eth_p2p_port }} \
--port {{ reth_eth_p2p_port }} \
--http \
--http.addr 0.0.0.0 \
--http.port {{ reth_eth_http_port }} \
--http.corsdomain * \
--ws \
--ws.addr 0.0.0.0 \
--ws.port {{ reth_eth_ws_port }} \
--ws.origins * \
--ws.api "eth,net,trace,txpool,web3,rpc,reth,ots,eth-call-bundle" \
--authrpc.jwtsecret {{ ethereum_jwtsecret_file }} \
--authrpc.addr {{ ethereum_lighthouse_host }} \
--authrpc.port {{ ethereum_lighthouse_port }}

KillMode=process
KillSignal=SIGTERM
TimeoutStopSec=90
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target

0 comments on commit 511c6a1

Please sign in to comment.