Skip to content

Commit

Permalink
refactoring. some minor improvements to the snapshot download script,…
Browse files Browse the repository at this point in the history
… other quality of life enhancements
  • Loading branch information
alchemydc committed Aug 28, 2023
1 parent e93df88 commit 0527ce1
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 69 deletions.
10 changes: 7 additions & 3 deletions group_vars/all/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ grafana_cloud_promtail_url: "https://{{ grafana_cloud_promtail_username }}:{{ gr
users:
- username: 'pokt'
moniker: "SDL-POKT-1"
seeds: "03b74fa3c68356bb40d58ecc10129479b159a145@seed1.mainnet.pokt.network:20656,64c91701ea98440bc3674fdb9a99311461cdfd6f@seed2.mainnet.pokt.network:21656,0057ee693f3ce332c4ffcb499ede024c586ae37b@seed3.mainnet.pokt.network:22856,9fd99b89947c6af57cd0269ad01ecb99960177cd@seed4.mainnet.pokt.network:23856,f2a4d0ec9d50ea61db18452d191687c899c3ca42@seed5.mainnet.pokt.network:24856,f2a9705924e8d0e11fed60484da2c3d22f7daba8@seed6.mainnet.pokt.network:25856,582177fd65dd03806eeaa2e21c9049e653672c7e@seed7.mainnet.pokt.network:26856,2ea0b13ab823986cfb44292add51ce8677b899ad@seed8.mainnet.pokt.network:27856,a5f4a4cd88db9fd5def1574a0bffef3c6f354a76@seed9.mainnet.pokt.network:28856,d4039bd71d48def9f9f61f670c098b8956e52a08@seed10.mainnet.pokt.network:29856,5c133f07ed296bb9e21e3e42d5f26e0f7d2b2832@poktseed100.chainflow.io:26656,[email protected]:26656"
#seeds: "03b74fa3c68356bb40d58ecc10129479b159a145@seed1.mainnet.pokt.network:20656,64c91701ea98440bc3674fdb9a99311461cdfd6f@seed2.mainnet.pokt.network:21656,0057ee693f3ce332c4ffcb499ede024c586ae37b@seed3.mainnet.pokt.network:22856,9fd99b89947c6af57cd0269ad01ecb99960177cd@seed4.mainnet.pokt.network:23856,f2a4d0ec9d50ea61db18452d191687c899c3ca42@seed5.mainnet.pokt.network:24856,f2a9705924e8d0e11fed60484da2c3d22f7daba8@seed6.mainnet.pokt.network:25856,582177fd65dd03806eeaa2e21c9049e653672c7e@seed7.mainnet.pokt.network:26856,2ea0b13ab823986cfb44292add51ce8677b899ad@seed8.mainnet.pokt.network:27856,a5f4a4cd88db9fd5def1574a0bffef3c6f354a76@seed9.mainnet.pokt.network:28856,d4039bd71d48def9f9f61f670c098b8956e52a08@seed10.mainnet.pokt.network:29856,5c133f07ed296bb9e21e3e42d5f26e0f7d2b2832@poktseed100.chainflow.io:26656,[email protected]:26656"
seeds: "7c0d7ec36db6594c1ffaa99724e1f8300bbd52d0@seed1.mainnet.pokt.network:26662,cdcf936d70726dd724e0e6a8353d8e5ba5abdd20@seed2.mainnet.pokt.network:26663,74b4322a91c4a7f3e774648d0730c1e610494691@seed3.mainnet.pokt.network:26662,b3235089ff302c9615ba661e13e601d9d6265b15@seed4.mainnet.pokt.network:26663"
persistent_peers: ""
MaxNumInboundPeers: 30
MaxNumOutboundPeers: 10
Expand All @@ -25,6 +26,7 @@ pokt_user_dir: "/home/{{ pokt_user }}"
monitor_user: 'monitor'
monitor_user_dir: "/home/{{ monitor_user }}"
custom_port_prefix: 55

repo: 'https://github.com/pokt-network/pocket-core'
pokt_release_tag: 'RC-0.10.4'
#pokt_release_tag: 'RC-0.9.2'
Expand All @@ -41,8 +43,10 @@ account_passphrase: "{{ vault_account_passphrase }}"

genesis_url: 'https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/mainnet/genesis.json'
genesis_hash: 'sha256:83e411fe6298d83963f2ebf5af3ef65b49dd029a6eb1a04db31a08b244f3d414'
snapshot_url: 'https://snapshot.nodes.pokt.network/latest.tar.gz'
expose_public_ip: true
#snapshot_url: 'https://snapshot.nodes.pokt.network/latest.tar.gz'
snapshot_url: 'https://pocket-snapshot.liquify.com/files'
#expose_public_ip: true
expose_public_ip: false

ethereum_rpc_uri: "{{ vault_ethereum_rpc_uri }}"
osmosis_rpc_uri: "{{ vault_osmosis_rpc_uri }}"
Expand Down
4 changes: 2 additions & 2 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
tags: 'monitor'
become: true

- role: 'pokt_dev'
tags: 'pokt_dev'
- role: 'pokt_node'
tags: 'pokt_node'
become: true

handlers:
Expand Down
14 changes: 0 additions & 14 deletions roles/pokt_dev/templates/download_snapshot.sh.j2

This file was deleted.

30 changes: 0 additions & 30 deletions roles/pokt_dev/templates/profile.j2

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
line: "\t \"ExternalAddress\": \"tcp://{{ public_ip.json.ip }}:{{ custom_port_prefix }}656\","
state: present
#when: public_ip.changed # can't use this conditional because the IP can't be baked into the template
when: expose_public_ip|bool == true
notify: restart pocket

- name: Deploy snapshot downloader script
Expand All @@ -98,6 +99,13 @@
group: "{{ pokt_user }}"
mode: "0750"

- name: Update sudoers to permit {{ pkot_user }} start/stop pocket systemd service
community.general.sudoers:
name: allow-pocket-start-stop
state: present
user: "{{ pokt_user }}"
commands: /bin/systemctl stop pocket,/bin/systemctl start pocket

- name: Deploy validator key install script
template:
src: install_validator_key.sh.j2
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 11 additions & 4 deletions roles/pokt_dev/tasks/main.yml → roles/pokt_node/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- name: install required apt packages
apt:
name:
- acl # needed to prevent errors when building as unprivileged user via become
state: present
update_cache: yes

- name: Create unprivileged pokt user
user:
name: "{{ pokt_user }}"
Expand Down Expand Up @@ -37,11 +44,11 @@
import_tasks: build_pokt.yml
tags: "build_pokt"

- name: Configure pokt keychain and config, etc.
import_tasks: configure_pokt.yml
tags: "configure_pokt"

- name: Configure systemd
import_tasks: configure_systemd.yml
tags: "configure_systemd"

- name: Configure pokt keychain and config, etc.
import_tasks: configure_pokt.yml
tags: "configure_pokt"

Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,5 @@
"username": "",
"password": ""
}
},
{
"id": "0054",
"url": "{{ osmosis_rpc_uri }}",
"basic_auth": {
"username": "",
"password": ""
}
},
{
"id": "0006",
"url": "{{ solana_rpc_uri }}",
"basic_auth": {
"username": "",
"password": ""
}
}
]
File renamed without changes.
17 changes: 17 additions & 0 deletions roles/pokt_node/templates/download_snapshot.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -ex

echo "Stopping pocket service"
sudo systemctl stop pocket
sleep 3
POCKET_DATA_DIR={{ pokt_user_dir }}/.pocket
echo "Removing old data from $POCKET_DATA_DIR"
rm -rf $POCKET_DATA_DIR/data/*
echo "Getting filename of latest snapshot from {{ snapshot_url }}/latest_compressed.txt"
latestFile=$(curl -s '{{ snapshot_url }}/latest_compressed.txt')
# above likely subjects us to a cmd injection attack :(
echo "Downloading and extracting snapshot data"
wget -O - "{{ snapshot_url }}/$latestFile" | lz4 -d - | tar -xv -C $POCKET_DATA_DIR
echo "Setting perms on downloaded chain data"
chown -R {{ pokt_user }}:{{ pokt_user }} $POCKET_DATA_DIR
echo "Done. Don't forget to start the daemon! with sudo systemctl start pocket"
File renamed without changes.
33 changes: 33 additions & 0 deletions roles/pokt_node/templates/profile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin

INTERVAL=1

alias status='curl -s http://localhost:{{ custom_port_prefix }}657/status'
alias wstatus='watch -n $INTERVAL "curl -s http://localhost:{{ custom_port_prefix }}657/status"'
alias peers='curl -s http://localhost:{{ custom_port_prefix }}657/net_info | jq .result.n_peers'
alias wpeers='watch -n $INTERVAL "curl -s http://localhost:{{ custom_port_prefix }}657/net_info | jq .result.n_peers"'
alias peerinfo="curl -s http://localhost:{{ custom_port_prefix }}657/net_info | jq '.result.peers[]| {moniker: .node_info.moniker, version: .node_info.version, ip: .remote_ip, outbound: .is_outbound}'"
alias wpeerinfo='watch -n 1 "curl -s http://localhost:{{ custom_port_prefix }}657/net_info | jq '\''.result.peers[]| {moniker: .node_info.moniker, version: .node_info.version, ip: .remote_ip, outbound: .is_outbound} '\''"'
alias ll='ls -laF'

File renamed without changes.

0 comments on commit 0527ce1

Please sign in to comment.