Skip to content

Commit

Permalink
Merge the develop branch to the master branch, preparation to v1.3.0-rc0
Browse files Browse the repository at this point in the history
  • Loading branch information
akolotov authored Jan 13, 2020
2 parents 727371f + 65dd131 commit 73d5002
Show file tree
Hide file tree
Showing 38 changed files with 342 additions and 139 deletions.
1 change: 1 addition & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ MONITOR_VALIDATOR_HOME_TX_LIMIT | Average gas usage of a transaction sent by a v
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT | Average gas usage of a transaction sent by a validator, it is used to estimate the number of transaction that can be paid by the validator. | integer
MONITOR_TX_NUMBER_THRESHOLD | If estimated number of transaction is equal to or below this value, the monitor will report that the validator has less funds than it is required. | integer
MONITOR_PORT | The port for the Monitor. | integer
MONITOR_BRIDGE_NAME | The name to be used in the url path for the bridge | string
Binary file not shown.
3 changes: 3 additions & 0 deletions deployment-e2e/molecule/monitor/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- import_playbook: ../../../deployment/site.yml
- import_playbook: ./run-checks.yml
3 changes: 2 additions & 1 deletion deployment-e2e/molecule/monitor/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ provisioner:
r: ["bug"]
playbooks:
prepare: ../prepare.yml
converge: ../../../deployment/site.yml
converge: ./converge.yml
inventory:
host_vars:
monitor-host:
MONITOR_PORT: 3003
syslog_server_port: "udp://127.0.0.1:514"
verifier:
name: testinfra
Expand Down
7 changes: 7 additions & 0 deletions deployment-e2e/molecule/monitor/run-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Generate initial data for monitor
hosts: monitor
become: true
tasks:
- name: Run monitor checks
shell: /bin/bash -c 'cd /home/poadocker/bridge/monitor/scripts; ./getBridgeStats.sh >cronWorker.out 2>cronWorker.err'
6 changes: 3 additions & 3 deletions deployment-e2e/molecule/monitor/tests/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ def test_logging(host, filename):

def test_home_exists(host):
assert host.run_test(
'curl -s http://localhost:3003 | '
'curl -s http://localhost:3003/bridge | '
'grep -q -i "home"'
)


def test_foreign_exists(host):
assert host.run_test(
'curl -s http://localhost:3003 | '
'curl -s http://localhost:3003/bridge | '
'grep -q -i "foreign"'
)


def test_no_error(host):
assert host.run_expect(
[1],
'curl -s http://localhost:3003 | '
'curl -s http://localhost:3003/bridge | '
'grep -i -q "error"'
)
4 changes: 4 additions & 0 deletions deployment/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ Example config for installing only UI:
1. Go to the group_vars folder.
`cd group_vars`
2. Note the <bridge_name> and add it to the hosts.yml configuration. For example, if a bridge file is named sokol-kovan.yml, you would change the <bridge_name> value in hosts.yml to sokol-kovan.

## Examples

[Deploy a monitor for multiple bridges](./MONITOR.md)

## Administrator Configurations

Expand Down
104 changes: 104 additions & 0 deletions deployment/MONITOR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
## Deploy multiple bridge monitor on the same host

If you want to deploy a monitor for different bridges, the [monitor variables](../monitor/.env.example) should be configured in `group_vars/<bridge_name>.yml` for each bridge.

For example, let's say we are going to deploy a monitor for xDai bridge and for WETC bridge.

#### Setup ansible configuration for xDai Bridge

First we create `hosts.yml` file to deploy the monitor for xdai bridge
```yaml
---
xdai:
children:
monitor:
hosts:
<host_ip_A>:
ansible_user: ubuntu
```
In `group_vars/xdai.yml`
```
---
MONITOR_BRIDGE_NAME: "xdai"
MONITOR_PORT: 3003

COMMON_HOME_RPC_URL: "https://dai.poa.network"
COMMON_HOME_BRIDGE_ADDRESS: "0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6"
COMMON_FOREIGN_RPC_URL: "https://mainnet.infura.io/v3/INFURA_KEY"
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016"

COMMON_HOME_GAS_PRICE_FALLBACK: 0
COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL: "https://gasprice.poa.network/"
COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE: "standard"
COMMON_FOREIGN_GAS_PRICE_FALLBACK: 10000000000
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1

MONITOR_HOME_START_BLOCK: 759
MONITOR_FOREIGN_START_BLOCK: 6478417
MONITOR_VALIDATOR_HOME_TX_LIMIT: 0
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT: 300000
MONITOR_TX_NUMBER_THRESHOLD: 100
```
Run the playbook to deploy the monitor for xdai bridge
```
ansible-playbook -i hosts.yml site.yml
```
This command will deploy the monitor component and enable statistics for xdai bridge.
#### Setup ansible configuration for WETC Bridge
Update `hosts.yml` file to deploy the monitor for WETC Bridge
```yaml
---
wetc:
children:
monitor:
hosts:
<host_ip_A>:
ansible_user: ubuntu
```

In `group_vars/wetc.yml`
```
---
MONITOR_BRIDGE_NAME: "wetc"
COMMON_HOME_RPC_URL: "https://ethereumclassic.network"
COMMON_HOME_BRIDGE_ADDRESS: "0x073081832B4Ecdce79d4D6753565c85Ba4b3BeA9"
COMMON_FOREIGN_RPC_URL: "https://mainnet.infura.io/v3/32e8e252699a4ac1b5dd5c1ef53cc301"
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x0cB781EE62F815bdD9CD4c2210aE8600d43e7040"
COMMON_HOME_GAS_PRICE_SUPPLIER_URL: "https://gasprice-etc.poa.network/"
COMMON_HOME_GAS_PRICE_SPEED_TYPE: "standard"
COMMON_HOME_GAS_PRICE_FALLBACK: 15000000000
COMMON_HOME_GAS_PRICE_FACTOR: 1
COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL: "https://gasprice.poa.network/"
COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE: "standard"
COMMON_FOREIGN_GAS_PRICE_FALLBACK: 10000000000
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
MONITOR_HOME_START_BLOCK: 7703292
MONITOR_FOREIGN_START_BLOCK: 7412459
MONITOR_VALIDATOR_HOME_TX_LIMIT: 300000
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT: 300000
MONITOR_TX_NUMBER_THRESHOLD: 100
```
Given that there is a monitor component deployed in the system, the `MONITOR_PORT` variable is not needed.

Run the playbook to deploy the monitor for WETC Bridge
```
ansible-playbook -i hosts.yml site.yml
```

They playbook will detect that the monitor component is already deployed in the system, so it will only generate the configuration needed to enable the WETC Bridge statistics.

##### Get Monitor results
The monitor output will be available at `http://host_ip_A:MONITOR_PORT/MONITOR_BRIDGE_NAME`.

Given that in `xdai.env` the variable `MONITOR_BRIDGE_NAME` is set to `xdai`, the results are in the url `http://host_ip_A:3003/xdai/`.

Similar to the xdai case, in `wetc.env` the variable `MONITOR_BRIDGE_NAME` is set to `wetc`, so the results are in the url `http://host_ip_A:3003/wetc/`.
1 change: 1 addition & 0 deletions deployment/group_vars/dai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000

## Monitor
MONITOR_BRIDGE_NAME: "xdai"
MONITOR_PORT: 3003
MONITOR_HOME_START_BLOCK: 759
MONITOR_FOREIGN_START_BLOCK: 6478417
Expand Down
3 changes: 2 additions & 1 deletion deployment/group_vars/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000

## Monitor
MONITOR_BRIDGE_NAME: "bridge"
MONITOR_PORT: 3003
MONITOR_HOME_START_BLOCK: 0
MONITOR_FOREIGN_START_BLOCK: 0
MONITOR_VALIDATOR_HOME_TX_LIMIT: 300000
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT: 300000
MONITOR_LEFT_TX_THRESHOLD: 100
MONITOR_TX_NUMBER_THRESHOLD: 100
5 changes: 3 additions & 2 deletions deployment/group_vars/ultimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/eth/kovan/address/%
UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000

#montior
#monitor
MONITOR_BRIDGE_NAME: "bridge"
MONITOR_HOME_START_BLOCK: 0
MONITOR_FOREIGN_START_BLOCK: 0
MONITOR_VALIDATOR_HOME_TX_LIMIT: 300000
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT: 300000
MONITOR_LEFT_TX_THRESHOLD: 100
MONITOR_TX_NUMBER_THRESHOLD: 100
1 change: 1 addition & 0 deletions deployment/group_vars/wetc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000

## Monitor
MONITOR_BRIDGE_NAME: "wetc"
MONITOR_PORT: 3003
MONITOR_HOME_START_BLOCK: 7703292
MONITOR_FOREIGN_START_BLOCK: 7412459
Expand Down
23 changes: 20 additions & 3 deletions deployment/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
---
- include_tasks: dependencies.yml
- include_tasks: repo.yml
- include_tasks: logging.yml
- name: Check if component is already deployed
shell: "test -f {{ bridge_path }}/{{ component }}/docker-compose.yml && echo 'true'"
ignore_errors: True
register: already_deployed
when: check_deployed is defined

- name: Set if tasks should be skipped
set_fact: skip_task="{{ already_deployed.stdout | default('false') }}"

- name: Include dependencies tasks
include_tasks: dependencies.yml
when: skip_task != true

- name: Include repo tasks
include_tasks: repo.yml
when: skip_task != true

- name: Include logging tasks
include_tasks: logging.yml
when: skip_task != true
2 changes: 1 addition & 1 deletion deployment/roles/monitor/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
dependencies:
- role: common
- { role: common, check_deployed: true, component: 'monitor' }
2 changes: 1 addition & 1 deletion deployment/roles/monitor/tasks/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
day: "{{ monitor_cron_schedule.split(' ')[2] }}"
month: "{{ monitor_cron_schedule.split(' ')[3] }}"
weekday: "{{ monitor_cron_schedule.split(' ')[4] }}"
job: "/bin/bash -c 'cd {{ bridge_path }}/monitor/scripts; ./checkDocker.sh >cronWorker.out 2>cronWorker.err'"
job: "/bin/bash -c 'cd {{ bridge_path }}/monitor/scripts; ./getBridgeStats.sh >cronWorker.out 2>cronWorker.err'"
- name: Add cron entry
cron:
name: "RUN_MONITOR_CHECKS"
Expand Down
20 changes: 16 additions & 4 deletions deployment/roles/monitor/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
---
- include_tasks: pre_config.yml
- include_tasks: logging.yml
- include_tasks: jumpbox.yml
- include_tasks: servinstall.yml
- include_tasks: cron.yml

- name: Include logging tasks
include_tasks: logging.yml
when: skip_task != true

- name: Include jumpbox tasks
include_tasks: jumpbox.yml
when: skip_task != true

- name: Include servinstall tasks
include_tasks: servinstall.yml
when: skip_task != true

- name: Include cron tasks
include_tasks: cron.yml
when: skip_task != true
6 changes: 6 additions & 0 deletions deployment/roles/monitor/tasks/pre_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
template:
src: .env.j2
dest: "{{ bridge_path }}/monitor/.env"
when: skip_task != true

- name: Install bridge config env
template:
src: config.env.j2
dest: "{{ bridge_path }}/monitor/configs/{{ MONITOR_BRIDGE_NAME }}.env"
23 changes: 0 additions & 23 deletions deployment/roles/monitor/templates/.env.j2
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
COMMON_HOME_RPC_URL={{ COMMON_HOME_RPC_URL }}
COMMON_FOREIGN_RPC_URL={{ COMMON_FOREIGN_RPC_URL }}
COMMON_HOME_BRIDGE_ADDRESS={{ COMMON_HOME_BRIDGE_ADDRESS }}
COMMON_FOREIGN_BRIDGE_ADDRESS={{ COMMON_FOREIGN_BRIDGE_ADDRESS }}
MONITOR_HOME_START_BLOCK={{ MONITOR_HOME_START_BLOCK }}
MONITOR_FOREIGN_START_BLOCK={{ MONITOR_FOREIGN_START_BLOCK }}
MONITOR_VALIDATOR_HOME_TX_LIMIT={{ MONITOR_VALIDATOR_HOME_TX_LIMIT }}
{% if COMMON_HOME_GAS_PRICE_SUPPLIER_URL | default('') != '' %}
COMMON_HOME_GAS_PRICE_SUPPLIER_URL={{ COMMON_HOME_GAS_PRICE_SUPPLIER_URL }}
{% endif %}
{% if COMMON_HOME_GAS_PRICE_SPEED_TYPE | default('') != '' %}
COMMON_HOME_GAS_PRICE_SPEED_TYPE={{ COMMON_HOME_GAS_PRICE_SPEED_TYPE }}
{% endif %}
COMMON_HOME_GAS_PRICE_FALLBACK={{ COMMON_HOME_GAS_PRICE_FALLBACK }}
{% if COMMON_HOME_GAS_PRICE_FACTOR | default('') != '' %}
COMMON_HOME_GAS_PRICE_FACTOR={{ COMMON_HOME_GAS_PRICE_FACTOR }}
{% endif %}
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT={{ MONITOR_VALIDATOR_FOREIGN_TX_LIMIT }}
COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL={{ COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL }}
COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE={{ COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE }}
COMMON_FOREIGN_GAS_PRICE_FALLBACK={{ COMMON_FOREIGN_GAS_PRICE_FALLBACK }}
COMMON_FOREIGN_GAS_PRICE_FACTOR={{ COMMON_FOREIGN_GAS_PRICE_FACTOR }}
MONITOR_LEFT_TX_THRESHOLD={{ MONITOR_LEFT_TX_THRESHOLD }}
MONITOR_PORT={{ MONITOR_PORT }}
34 changes: 34 additions & 0 deletions deployment/roles/monitor/templates/config.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
MONITOR_BRIDGE_NAME={{ MONITOR_BRIDGE_NAME }}

COMMON_HOME_RPC_URL={{ COMMON_HOME_RPC_URL }}
COMMON_HOME_BRIDGE_ADDRESS={{ COMMON_HOME_BRIDGE_ADDRESS }}
COMMON_FOREIGN_RPC_URL={{ COMMON_FOREIGN_RPC_URL }}
COMMON_FOREIGN_BRIDGE_ADDRESS={{ COMMON_FOREIGN_BRIDGE_ADDRESS }}

{% if COMMON_HOME_GAS_PRICE_SUPPLIER_URL | default('') != '' %}
COMMON_HOME_GAS_PRICE_SUPPLIER_URL={{ COMMON_HOME_GAS_PRICE_SUPPLIER_URL }}
{% endif %}
{% if COMMON_HOME_GAS_PRICE_SPEED_TYPE | default('') != '' %}
COMMON_HOME_GAS_PRICE_SPEED_TYPE={{ COMMON_HOME_GAS_PRICE_SPEED_TYPE }}
{% endif %}
COMMON_HOME_GAS_PRICE_FALLBACK={{ COMMON_HOME_GAS_PRICE_FALLBACK }}
{% if COMMON_HOME_GAS_PRICE_FACTOR | default('') != '' %}
COMMON_HOME_GAS_PRICE_FACTOR={{ COMMON_HOME_GAS_PRICE_FACTOR }}
{% endif %}

{% if COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL | default('') != '' %}
COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL={{ COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL }}
{% endif %}
{% if COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE | default('') != '' %}
COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE={{ COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE }}
{% endif %}
COMMON_FOREIGN_GAS_PRICE_FALLBACK={{ COMMON_FOREIGN_GAS_PRICE_FALLBACK }}
{% if COMMON_FOREIGN_GAS_PRICE_FACTOR | default('') != '' %}
COMMON_FOREIGN_GAS_PRICE_FACTOR={{ COMMON_FOREIGN_GAS_PRICE_FACTOR }}
{% endif %}

MONITOR_HOME_START_BLOCK={{ MONITOR_HOME_START_BLOCK }}
MONITOR_FOREIGN_START_BLOCK={{ MONITOR_FOREIGN_START_BLOCK }}
MONITOR_VALIDATOR_HOME_TX_LIMIT={{ MONITOR_VALIDATOR_HOME_TX_LIMIT }}
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT={{ MONITOR_VALIDATOR_FOREIGN_TX_LIMIT }}
MONITOR_TX_NUMBER_THRESHOLD={{ MONITOR_TX_NUMBER_THRESHOLD }}
1 change: 1 addition & 0 deletions deployment/roles/monitor/templates/tokenbridge-monitor.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ start(){
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose rm -fv
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose up --detach
sudo -u "{{ compose_service_user }}" /bin/bash -c 'cd scripts; ./getBridgeStats.sh >cronWorker.out 2>cronWorker.err'
}

stop(){
Expand Down
1 change: 1 addition & 0 deletions e2e-commons/components-envs/monitor-amb.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK=1000000000
COMMON_FOREIGN_GAS_PRICE_FACTOR=1
MONITOR_TX_NUMBER_THRESHOLD=100
MONITOR_PORT=3013
MONITOR_BRIDGE_NAME=bridge
1 change: 1 addition & 0 deletions e2e-commons/components-envs/monitor-erc20-native.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK=1000000000
COMMON_FOREIGN_GAS_PRICE_FACTOR=1
MONITOR_TX_NUMBER_THRESHOLD=100
MONITOR_PORT=3012
MONITOR_BRIDGE_NAME=bridge
1 change: 1 addition & 0 deletions e2e-commons/components-envs/monitor-erc20.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK=1000000000
COMMON_FOREIGN_GAS_PRICE_FACTOR=1
MONITOR_TX_NUMBER_THRESHOLD=100
MONITOR_PORT=3011
MONITOR_BRIDGE_NAME=bridge
1 change: 1 addition & 0 deletions e2e-commons/components-envs/monitor.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK=1000000000
COMMON_FOREIGN_GAS_PRICE_FACTOR=1
MONITOR_TX_NUMBER_THRESHOLD=100
MONITOR_PORT=3010
MONITOR_BRIDGE_NAME=bridge
Loading

0 comments on commit 73d5002

Please sign in to comment.