replace geth-miner role with infra-role-geth

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-05-07 15:04:47 +02:00
parent 7212fef1ee
commit 3e59f8e846
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
14 changed files with 13 additions and 216 deletions

View File

@ -3,16 +3,12 @@
faucet_network: '{{ stage }}'
faucet_domain: 'faucet-{{ stage }}.status.im'
faucet_cors_rule: '^https?://.*\.infura\.status.im'
#faucet_geth_rpc_port: 8545
#faucet_geth_name: 'faucet-geth'
#faucet_geth_alias: 'geth'
# geth necessary for Faucet to work
geth_network_name: '{{ faucet_network }}'
geth_rpc_port: '{{ faucet_geth_cont_rpc_port }}'
geth_cont_name: '{{ faucet_geth_cont_name }}'
geth_extra_alias: '{{ faucet_geth_cont_alias }}'
geth_max_peers: 50
geth_extra_alias: 'miner'
geth_sync_mode: full
geth_log_level_name: info

View File

@ -1,6 +1,12 @@
---
# stage contains the network name
miner_network: '{{ stage }}'
miner_base_account_addr: '{{lookup("passwordstore", "services/faucet/account-addr")}}'
miner_base_account_pass: '{{lookup("passwordstore", "services/faucet/account-pass")}}'
miner_base_account_json: '{{lookup("passwordstore", "services/faucet/account-json")}}'
geth_network_name: '{{ stage }}'
geth_miner_enabled: true
geth_cont_name: 'geth-miner'
geth_extra_alias: 'miner'
geth_sync_mode: full
geth_log_level_name: info
geth_account_pass: '{{lookup("passwordstore", "services/faucet/account-pass")}}'
geth_account_addr: '{{lookup("passwordstore", "services/faucet/account-addr")}}'
geth_account_json: '{{lookup("passwordstore", "services/faucet/account-json")}}'

View File

@ -12,5 +12,5 @@
- name: Configure faucet miners
hosts: faucet-miners
roles:
- role: geth-miner
tags: geth-miner
- role: infra-role-geth
tags: geth

View File

@ -1,29 +0,0 @@
# Description
This role configures the [geth](https://github.com/ethereum/go-ethereum) service which mines Ethereum in Ropsten and Rinkeby networks for use with the [faucet](https://github.com/status-im/faucet) hosted on the `master` hosts.
# Configuration
The only required settings are:
```yaml
miner_network: rinkeby
miner_base_account_pass: 123qwe
miner_base_account_addr: 0x12312312312312321
miner_base_account_json: '{"wallet":"json"}'
```
# API
# Usage
To check sync state you can use the `ageth` wrapper for attaching to `geth` RPC port:
```bash
admin@master-01.gc-us-central1-a.faucet.ropsten:~ % ageth eth.syncing
{
currentBlock: 202432,
highestBlock: 5120931,
knownStates: 0,
pulledStates: 0,
startingBlock: 149504
}
```

View File

@ -1,34 +0,0 @@
---
# map of network IDs
miner_network_ids:
frontier: 1
morden: 2
ropsten: 3
rinkeby: 4
miner_network: ~
miner_network_id: '{{ miner_network_ids[miner_network] | mandatory }}'
# miner reward account
miner_base_account_pass: ~
miner_base_account_addr: ~
miner_base_account_json: ~
miner_cont_tag: v1.8.23
miner_cont_image: 'ethereum/client-go:{{ miner_cont_tag }}'
miner_cont_name: 'geth-miner'
miner_cont_vol: '/docker/{{ miner_cont_name }}'
miner_verbosity: 3
miner_extra_data: 'Status.im Miner'
miner_main_port: 30303
miner_rpc_port: 8545
miner_max_peers: 35
miner_rcp_api: 'eth,net,web3,admin,personal,shh'
miner_shh_pow: 0.001
miner_lightserv: 60
miner_maxpendpeers: 5
# generic container settings
cont_state: started
cont_recreate: false
cont_restart: false

View File

@ -1,3 +0,0 @@
---
- name: Save iptables rules
shell: iptables-save > /etc/iptables/rules.v4

View File

@ -1,27 +0,0 @@
---
- name: Create container folders
file:
path: '{{ item }}'
state: directory
mode: 0750
owner: dockremap
group: docker
with_items:
- '{{ miner_cont_vol }}/data'
- '{{ miner_cont_vol }}/data/keystore'
- name: Create account password file
copy:
dest: '{{ miner_cont_vol }}/data/keystore/faucet.pass'
content: '{{ miner_base_account_pass | mandatory }}'
mode: 0640
owner: dockremap
group: docker
- name: Create account keystore file
copy:
dest: '{{ miner_cont_vol }}/data/keystore/faucet.json'
content: '{{ miner_base_account_json | mandatory }}'
mode: 0640
owner: dockremap
group: docker

View File

@ -1,14 +0,0 @@
---
- name: Consul service definition - geth-miner
include_role: name=consul-service
vars:
consul_config_name: '{{ miner_cont_name | replace("-", "_") }}'
consul_services:
- name: '{{ miner_cont_name }}'
tags: ['{{ env }}.{{ stage }}', 'geth', 'miner', 'faucet']
port: '{{ miner_main_port }}'
checks:
- id: geth-miner-rpc-health
name: Geth Miner RPC Health
type: script
script: 'curl -s -X POST -H Content-type:application/json --data {"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1} http://localhost:{{ miner_rpc_port }}/'

View File

@ -1,34 +0,0 @@
---
- name: Create geth miner
docker_container:
name: '{{ miner_cont_name }}'
image: '{{ miner_cont_image }}'
user: root
pull: true
restart_policy: always
state: '{{ cont_state }}'
recreate: '{{ cont_recreate }}'
restart: '{{ cont_restart }}'
ports:
- '127.0.0.1:{{ miner_rpc_port }}:{{ miner_rpc_port }}'
- '{{ miner_main_port }}:{{ miner_main_port }}'
command: |
--networkid={{ miner_network_id }}
--datadir=/data
--password=/data/keystore/faucet.pass
--port={{ miner_main_port }}
--v5disc
--shh
--shh.pow={{ miner_shh_pow }}
--rpc
--rpcaddr="0.0.0.0"
--rpcport="{{ miner_rpc_port }}"
--rpcapi="{{ miner_rcp_api }}"
--maxpeers="{{ miner_max_peers }}"
--maxpendpeers="{{ miner_maxpendpeers }}"
--lightserv="{{ miner_lightserv }}"
--mine
--miner.threads="{{ ansible_processor_vcpus }}"
--miner.etherbase="{{ miner_base_account_addr | mandatory }}"
volumes:
- '{{ miner_cont_vol }}/data:/data:rw'

View File

@ -1,15 +0,0 @@
---
- name: Enable geth main port
iptables:
comment: 'Enable geth'
action: insert
chain: DOCKER-USER
jump: ACCEPT
source: '0.0.0.0/0'
protocol: '{{ item }}'
destination_port: '{{ miner_main_port }}'
with_items:
- tcp
- udp
notify:
- Save iptables rules

View File

@ -1,6 +0,0 @@
---
- import_tasks: config.yml
- import_tasks: wrapper.yml
- import_tasks: container.yml
- import_tasks: firewall.yml
- import_tasks: consul.yml

View File

@ -1,31 +0,0 @@
---
- name: Get account wallet state
docker_container:
name: 'geth-account-verify'
image: '{{ miner_cont_image }}'
user: root
pull: true
detach: false
interactive: true
command: |
--datadir=/data
--password=/data/faucet.pass
--networkid={{ miner_network_id }}
--verbosity=1
console
--exec=personal.listWallets
volumes:
- '{{ miner_cont_vol }}/data:/data:rw'
register: geth_wallets
- debug: msg={{geth_wallets}}
- name: Extract wallet state
set_fact:
wallet_state: '{{ geth_wallets.stdout | from_json | json_query(".[0].status") }}'
- name: Verify the account wallet can be unlocked
assert:
that:
- '{{ wallet_state == "Unlocked" }}'
msg: 'Wallet state must be unlocked!'

View File

@ -1,6 +0,0 @@
---
- name: Create geth attach wrapper
template:
src: geth-attach-wrapper.sh
dest: /usr/local/bin/ageth
mode: 0755

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
if [[ -z "$@" ]]; then
docker exec -it {{ miner_cont_name }} geth attach http://localhost:{{ miner_rpc_port }}
else
docker exec {{ miner_cont_name }} geth attach http://localhost:{{ miner_rpc_port }} --exec "$@"
fi