Skip to content

Commit 8fa6cb1

Browse files
committed
update
1 parent 67c12b8 commit 8fa6cb1

File tree

10 files changed

+193
-35
lines changed

10 files changed

+193
-35
lines changed

README.md

Lines changed: 112 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,121 @@
1-
# Substrate-based Validator Node Ansible Setup
1+
# Cosmos-based Node Ansible Setup
2+
3+
This repo is to set up the Cosmos-based node. It currently support:
4+
5+
- Juno (mainnet and testnet)
6+
- Sifchain (betanet and testnet)
7+
- Evmos (testnet)
8+
9+
## Summary
10+
11+
You run one playbook and set up a node. For example:
12+
13+
```bash
14+
ansible-playbook -i inventory juno_full_setup.yml -e "target=juno_testnet"
15+
```
16+
17+
But before you rush with this easy setup, you probably want to read on so you understand the structure of this Ansible program and all the features it offers.
18+
19+
## Some Preparations
20+
21+
First, make sure that you have a production inventory file with your confidential server info. You will start by copying the sample inventory file (included in the repo). The sample file gives you a good idea on how to define the inventory.
22+
23+
```bash
24+
cp inventory.sample inventory
25+
```
26+
27+
Needless to say, you need to update the dummy values in the inventory file. For each node, you need to update the server IP. While you are free to keep the default, you might also want to update:
28+
29+
1. ansible_user: The sample file assumes `ubuntu`.
30+
2. ansible_port: The sample file assumes `22`. But if you are like me, you will have a different ssh port other than `22` to avoid port sniffing.
31+
3. ansible_ssh_private_key_file: The sample file assumes `~/.ssh/id_rsa`, but you might have a different key location.
32+
4. log_monitor: Enter your monitor server IP. It is most likely a private IP address if you use a firewall around your private virtual cloud (VPC).
33+
34+
It is beyond the scope of this guide to help you create a sudo user, alternate ssh port, create a private key, install Ansible on your machine, etc. You can do a quick online search and find the answers. In my experience, Digital Ocean have some quality guides on these topics. Stack Overflow can help you trouble-shoot if you are stuck.
35+
36+
## Basic Cluster Structure
37+
38+
The basic cluster structure is:
39+
40+
1. Name each juno node as `juno_testnet`, `juno_mainnet`, etc. Group all Juno nodes into `juno` group.
41+
2. Name each juno node as `sifchain_testnet`, `sifchain_mainnet`, etc. Group all Sifchain nodes into `sifchain` group.
42+
3. ...
43+
44+
The structure allows you to target `vars` to each node, or a group cluster, or the whole cluster. Make sure that you are familiar with the files in the `group_vars` folder. They follow this clustered structure closely.
45+
46+
## Main Playbook
47+
48+
The key Ansible playbook is `xxxxx_full_setup.yml` files. It will set up a fresh node from scratch. For example:
49+
50+
```bash
51+
ansible-playbook -i inventory sifchain_full_setup.yml -e "target=sifchain_betanet"
52+
```
53+
54+
## Some Useful Commands
55+
56+
block height
257

358
```bash
459
watch -n 60 -d "curl -s http://localhost:26657/status | jq -r .result.sync_info.latest_block_height"
5-
curl -s localhost:26657/net_info | jq -r .result.peers[].node_info.moniker
60+
```
61+
62+
Connected Peers
63+
64+
```bash
65+
curl -s localhost:26657/net_info | jq -r '.result.peers[] | .node_info.moniker, .node_info.id, .node_info.listen_addr, .remote_ip'
66+
```
67+
68+
Check logs and cosmovisor status
69+
70+
```bash
71+
journalctl -u cosmovisor.service -f
672
journalctl -u cosmovisor.service -f | grep "committed"
773
systemctl status cosmovisor
8-
curl -s localhost:26657/net_info | jq -r '.result.peers[] | .node_info.moniker, .node_info.id, .node_info.listen_addr, .remote_ip'
9-
curl -s localhost:26657/net_info | jq -r .result.peers[].node_info.moniker
10-
watch -n 2 " curl -s localhost:26657/net_info | jq -r '.result.n_peers'"
1174
```
1275

76+
Sifchain: create validator
77+
78+
```bash
79+
sifnoded tx staking create-validator \
80+
--amount 1000000000000000000000rowan \
81+
--commission-max-change-rate "0.01" \
82+
--commission-rate "0.02" \
83+
--commission-max-rate "0.1" \
84+
--min-self-delegation "1" \
85+
--website "https://polkachu.com" \
86+
--identity "0A6AF02D1557E5B4" \
87+
--details "Polkachu is the trusted staking service provider for blockchain projects. 100% refund for downtime slash. Contact us at [email protected]" \
88+
--pubkey=$(sifnoded tendermint show-validator) \
89+
--moniker 'Polkachu' \
90+
--chain-id sifchain-1 \
91+
--gas-adjustment="1.5" \
92+
--gas="200000" \
93+
--fees 100000000000000000rowan \
94+
--from polkachu
1395
```
96+
97+
Sifchain: Delegate
98+
99+
```bash
100+
sifnoded tx staking delegate sifvaloper1gp957czryfgyvxwn3tfnyy2f0t9g2p4pfj2j90 420000000000000000000rowan \
101+
--chain-id sifchain-1 \
102+
--from=polkachu \
103+
--gas-adjustment="1.5" \
104+
--gas="200000" \
105+
--fees 100000000000000000rowan
106+
```
107+
108+
```bash
14109
junod tx staking create-validator \
15-
--amount 6000000ujunox \
16-
--commission-max-change-rate "0.1" \
17-
--commission-max-rate "0.20" \
18-
--commission-rate "0.1" \
19-
--min-self-delegation "1" \
20-
--details "This is my validator" \
21-
--pubkey=$(junod tendermint show-validator) \
22-
--moniker '[Polkachu] 1% fee' \
23-
--chain-id uni \
24-
--gas-prices 0.025ujunox \
25-
--from polkachu
26-
```
27-
28-
junod tx staking edit-validator --website="https://polkachu.com" --from=polkachu --gas-prices="0.025ujunox" --chain-id=uni
29-
junod tx staking delegate junovaloper1gp957czryfgyvxwn3tfnyy2f0t9g2p4pvzc6k3 1390000ujunox --chain-id=uni --from=polkachu --gas-prices="0.025ujunox"
110+
--amount 6000000ujunox \
111+
--commission-max-change-rate "0.1" \
112+
--commission-max-rate "0.20" \
113+
--commission-rate "0.1" \
114+
--min-self-delegation "1" \
115+
--details "This is my validator" \
116+
--pubkey=$(junod tendermint show-validator) \
117+
--moniker '[Polkachu] 1% fee' \
118+
--chain-id uni \
119+
--gas-prices 0.025ujunox \
120+
--from polkachu
121+
```

group_vars/evmos_testnet.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
validator_name: polkachu-evmos-testnet
2+
log_name: evmos_testnet
3+
network: evmos
4+
folder: '.evmosd'
5+
daemon: evmosd
6+
chain_id: evmos_9000-2
7+
node_version: v0.2.0
8+
genesis: 'https://raw.githubusercontent.com/CosmosContracts/testnets/main/uni/genesis.json'
9+
repo: https://github.com/CosmosContracts/juno
10+
minimum_has_price: '0.025ujunox'
11+
12+
seed: 'c36cec90ded95d162b85f8ecd00ecd7c8849ca75@arsiamons.seed.evmos.org:26656,3787335176bbb91bf14a67724ebe0f0940ca5afb@evmos-seed.artifact-staking.io:26656,faa31510d9280e74e7f2e767a62023bd5c896c27@evmos-testnet.mercury-nodes.net:29447'
13+
# evmosd tx staking create-validator \
14+
# --amount=1000000000000aphoton \
15+
# --pubkey=$(evmosd tendermint show-validator) \
16+
# --moniker="polkachu-evomos-testnet" \
17+
# --chain-id= evmos_9000-2 \
18+
# --commission-rate="0.10" \
19+
# --commission-max-rate="0.20" \
20+
# --commission-max-change-rate="0.01" \
21+
# --min-self-delegation="1000000" \
22+
# --gas="auto" \
23+
# --gas-prices="0.025aphoton" \
24+
# --from=polkachu

group_vars/juno_mainnet.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
validator_name: polkachu-juno-mainnet
2+
log_name: juno_mainnet
23
network: juno
4+
folder: '.juno'
35
daemon: junod
46
chain_id: juno-1
57
node_version: v1.0.0
68
genesis: 'https://raw.githubusercontent.com/CosmosContracts/mainnet/main/juno-1/genesis.json'
79
repo: https://github.com/CosmosContracts/juno
8-
minimum_has_price: '0.025ujunox'
10+
minimum_has_price: '0.025ujuno'
911

group_vars/juno_testnet.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
validator_name: polkachu-juno-testnet
2+
log_name: juno_testnet
23
network: juno
4+
folder: '.juno'
35
daemon: junod
46
chain_id: uni
57
node_version: v1.0.0

group_vars/sifchain.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

group_vars/sifchain_betanet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
validator_name: polkachu-sifchain-betanet
2+
log_name: sifchain_betanet
23
network: sifnoded
34
daemon: sifnoded
45
chain_id: sifchain-1

group_vars/sifchain_testnet.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
validator_name: polkachu-sifchain-testnet
2+
log_name: sifchain_testnet
3+
24
chain_type: testnet
35
chain_id: sifchain-testnet-1
46
node_version: testnet-0.9.0

inventory.sample

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1-
[juno-test]
2-
10.0.0.1 validator_name=polkadot-juno-test log_name=juno-test
1+
[sifchain_betanet]
2+
10.0.0.1
3+
4+
[sifchain_testnet]
5+
10.0.0.2
6+
7+
[juno_testnet]
8+
10.0.0.2
9+
10+
[juno_mainnet]
11+
10.0.0.3
12+
13+
[evmos_testnet]
14+
10.0.0.4
15+
16+
[sifchain:children]
17+
sifchain_betanet
18+
sifchain_testnet
19+
20+
[juno:children]
21+
juno_mainnet
22+
juno_testnet
23+
24+
[evmos:children]
25+
evmos_testnet
326

427
[all:vars]
5-
ansible_user=ansible
28+
ansible_user=ubuntu
629
ansible_port=22
730
ansible_ssh_private_key_file="~/.ssh/id_rsa"
8-
log_monitor=10.0.0.2
31+
log_monitor=10.0.0.100
32+
path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/go/bin:/home/ubuntu/go/bin"

roles/juno/tasks/main.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,29 @@
3030

3131
- name: Update config files
3232
lineinfile:
33-
path: '/home/ubuntu/.{{ network }}/config/app.toml'
33+
path: '/home/ubuntu/{{ folder }}/config/app.toml'
3434
regexp: 'minimum-gas-prices '
3535
line: 'minimum-gas-prices = "{{ minimum_has_price }}"'
3636
state: present
3737

3838
- name: Update the config.toml file
3939
lineinfile:
40-
path: '/home/ubuntu/.{{ network }}/config/config.toml'
40+
path: '/home/ubuntu/{{ folder }}/config/config.toml'
4141
regexp: 'persistent_peers = ""'
4242
line: 'persistent_peers = "{{ peers }}"'
4343
state: present
4444

45+
- name: Enable prometheus on the config.toml file
46+
lineinfile:
47+
path: '/home/ubuntu/{{ folder }}/config/config.toml'
48+
regexp: 'prometheus = false'
49+
line: 'prometheus = true'
50+
state: present
51+
4552
- name: Download genesis file
4653
get_url:
4754
url: '{{ genesis }}'
48-
dest: '/home/ubuntu/.{{ network }}/config/genesis.json'
55+
dest: '/home/ubuntu/{{ folder }}/config/genesis.json'
4956
mode: '0644'
5057

5158
- name: register public ip
@@ -55,24 +62,24 @@
5562

5663
- name: Set up external address
5764
lineinfile:
58-
path: '/home/ubuntu/.{{ network }}/config/config.toml'
65+
path: '/home/ubuntu/{{ folder }}/config/config.toml'
5966
regexp: 'external_address = ""'
6067
line: 'external_address = "{{ public_ip.json.ip }}:26656"'
6168
state: present
6269

63-
- name: Create directories
70+
- name: Create cosmovisor directories
6471
file:
6572
path: '{{ item }}'
6673
state: directory
6774
mode: '0755'
6875
with_items:
69-
- '/home/ubuntu/.{{ network }}/cosmovisor/genesis/bin'
70-
- '/home/ubuntu/.{{ network }}/cosmovisor/upgrades'
76+
- '/home/ubuntu/{{ folder }}/cosmovisor/genesis/bin'
77+
- '/home/ubuntu/{{ folder }}/cosmovisor/upgrades'
7178

72-
- name: copy
79+
- name: copy daemon file to cosmovisor
7380
copy:
7481
src: '/home/ubuntu/go/bin/{{ daemon }}'
75-
dest: '/home/ubuntu/.{{ network }}/cosmovisor/genesis/bin'
82+
dest: '/home/ubuntu/{{ folder }}/cosmovisor/genesis/bin'
7683
remote_src: true
7784
mode: '0755'
7885

roles/prepare/tasks/firewall.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
when:
2626
- not ufw_status_result.stdout is search("26657/tcp.*ALLOW IN.*Anywhere")
2727

28+
- name: open prometheus port
29+
command: ufw allow 26660/tcp
30+
when:
31+
- not ufw_status_result.stdout is search("26660/tcp.*ALLOW IN.*Anywhere")
32+
2833
- name: enable firewall
2934
shell: |
3035
set -o pipefail

0 commit comments

Comments
 (0)