Skip to content

Commit

Permalink
Updates after deployment test (#75)
Browse files Browse the repository at this point in the history
* Force ln to mitigate error when postinstall is repeated

* Update readme

* Using yarn in place of npm run

* Changed env order - home first

* Removed gh-pages UI deploy

* Readme cosmetics

* Removed duplicate bridge overview

* Update readme

* Update repository address

* Update readme

* Changed NPM to Yarn everywhere

* Update readme

* Using tokenbridge monorepo in deployment instead of token-bridge

* Update ui/README.md

Co-Authored-By: Andrew Gross <andogro@gmail.com>

* Revert and/or change as per @akolotov explanation

* Removed checkWorker3 that was used in legacy bridge-rust-v1-native-to-erc

* Update deployment/oracle/README.md

Co-Authored-By: Alexander Kolotov <alexandr.kolotov@gmail.com>

* Apply suggestions from code review

Co-Authored-By: Alexander Kolotov <alexandr.kolotov@gmail.com>

* Update root readme and Update sub-repo readmes to point to root monorepository initialization.

* Removed obsolete GET /stuckTransfers

* Remove stuckTransfers

* Use shell instead of unmaintained docker_service module. Update naming in templates.
  • Loading branch information
rzadp authored May 31, 2019
1 parent 1ab4a0e commit 93347b4
Show file tree
Hide file tree
Showing 27 changed files with 201 additions and 295 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ build
.idea
.nyc_output
logs/
responses/*
!responses/.gitkeep


*.err
*.out
data
Expand All @@ -44,3 +44,6 @@ Vagrantfile
vagrant-hosts.yml
.vagrant

#monitor
monitor/responses/*
!monitor/.gitkeep
48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Sub-repositories maintained within this monorepo are listed below.
| [UI](ui/README.md) | DApp interface to transfer tokens and coins between chains. |
| [Monitor](monitor/README.md) | Tool for checking balances and unprocessed events in bridged networks. |
| [Deployment](deployment/README.md) | Ansible playbooks for deploying cross-chain bridges. |
| [Oracle-E2E]() | End to end tests for the Oracle |
| [UI-E2E]() | End to end tests for the UI |
| [Oracle-E2E](oracle-e2e/README.md) | End to end tests for the Oracle |
| [UI-E2E](ui-e2e/README.md) | End to end tests for the UI |

Additionally there are [Solidity contracts](https://github.com/poanetwork/poa-bridge-contracts) used to manage bridge validators, collect signatures, and confirm asset relay and disposal.
Additionally there are [Smart Contracts](https://github.com/poanetwork/poa-bridge-contracts) used to manage bridge validators, collect signatures, and confirm asset relay and disposal.

## Network Definitions

Expand All @@ -44,33 +44,55 @@ The POA TokenBridge provides three operational modes:
- [x] `ERC20-to-ERC20` ERC20-compatible tokens on the Foreign network are locked and minted as ERC20-compatible tokens (ERC677 tokens) on the Home network. When transferred from Home to Foreign, they are burnt on the Home side and unlocked in the Foreign network. This can be considered a form of atomic swap when a user swaps the token "X" in network "A" to the token "Y" in network "B". **More Information: [ERC20-to-ERC20](https://medium.com/poa-network/introducing-the-erc20-to-erc20-tokenbridge-ce266cc1a2d0)**
- [x] `ERC20-to-Native`: Pre-existing **tokens** in the Foreign network are locked and **coins** are minted in the `Home` network. In this mode, the Home network consensus engine invokes [Parity's Block Reward contract](https://wiki.parity.io/Block-Reward-Contract.html) to mint coins per the bridge contract request. **More Information: [xDai Chain](https://medium.com/poa-network/poa-network-partners-with-makerdao-on-xdai-chain-the-first-ever-usd-stable-blockchain-65a078c41e6a)**

## Building, running, linting & tests
## Initializing the monorepository

To initialize submodules:
Clone the repository with submodules:
```bash
git clone --recursive https://github.com/poanetwork/tokenbridge

`git submodule update --init`
# or initialize submodules if already cloned without --recursive option:
git submodule update --init
```

To install dependencies:
Install dependencies:

`yarn install`
```
yarn install && yarn install:deploy
```

To build all projects:
_**Note**: The installation should be performed with an unprivileged Linux account or with the following flag: `yarn install --unsafe-perm`. [More information](https://docs.npmjs.com/misc/scripts#user)_

`yarn run build`
Compile the Smart Contracts

```
yarn compile:contracts
```

## Linting

Running linter for all JS projects:

`yarn lint`
```
yarn lint
```

Running linter for all Ansible playbooks:

- [ansible-lint](https://github.com/ansible/ansible-lint) is required

`yarn ansible-lint`
```
yarn ansible-lint
```

## Tests

Running tests for all projects:

`yarn test`
```
yarn test
```

Additionaly there are end-to-end tests for [Oracle](oracle-e2e/README.md) and [UI](ui-e2e/README.md).

For details on building, running and developing please refer to respective READMEs in sub-repositories.

Expand Down
12 changes: 7 additions & 5 deletions deployment/oracle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

1. Clone this repository and go to the `deployment/oracle` folder
```
git clone https://github.com/poanetwork/tokenbridge
git clone --recursive https://github.com/poanetwork/tokenbridge
cd tokenbridge/deployment/oracle
```
2. Create the file `hosts.yml` from `hosts.yml.example`
Expand Down Expand Up @@ -53,17 +53,17 @@ cp hosts.yml.example hosts.yml

1. The `group_vars/<bridge_name>.yml` file contains the public bridge parameters. This file is prepared by administrators for each bridge. The validator only needs to add the required bridge name in the hosts.yml file to tell Ansible which file to use.

`group_vars/example.yml` shows an example configuration for the POA/Sokol - POA/Sokol bridge. Parameter values should match values from the .env file for the token-bridge. See [Configuration parameters](../../oracle/README.md#configuration-parameters) for details.
`group_vars/example.yml` shows an example configuration for the POA/Sokol - POA/Sokol bridge. Parameter values should match values from the .env file for the Oracle. See [Configuration parameters](../../oracle/README.md#configuration-parameters) for details.

2. You can also add the following parameters in the `group_vars` to change the default behavior of `deployment-bridge` playbooks:

2.1 `compose_service_user` - specifies users to be created by playbooks. This user will be used to run POA bridge.
2.1 `compose_service_user` - specifies users to be created by playbooks. This user will be used to run Token Bridge Oracle.

2.2 `bridge_repo` contains address of token-bridge repository. The default value is https://github.com/poanetwork/token-bridge.
2.2 `bridge_repo` contains address of Token Bridge Oracle repository. The default value is https://github.com/poanetwork/tokenbridge.

2.3 `bridge_repo_branch` points to the specific branch or commit to use with the `bridge_repo`. If `bridge_repo_branch` is not specified, the default (`master`) branch is used.

2.4 `bridge_path` set the path where token-bridge would be installed. By default it point to the home folder of `compose_service_user`
2.4 `bridge_path` set the path where Token Bridge Oracle would be installed. By default it point to the home folder of `compose_service_user`

2.5 `docker_compose_version` - specifies a version of docker-compose to be installed.

Expand Down Expand Up @@ -97,6 +97,8 @@ To be used with the ansible-playbook command, for example:

* `--private-key=<file_name>` - if private keyfile is required to connect to the ubuntu instance.

* `--user=<username>` - connect as this username

## Bridge service commands

The Bridge service is named `poabridge`. Use the default `SysVinit` commands to `start`, `stop`, `restart`, and `rebuild` the service and to check the `status` of the service.
Expand Down
7 changes: 3 additions & 4 deletions deployment/oracle/roles/jumpbox/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
- name: Launch container
docker_service:
project_src: "{{ bridge_path }}"
state: present
build: yes
shell: docker-compose up -d
args:
chdir: "{{ bridge_path }}/oracle"
4 changes: 2 additions & 2 deletions deployment/oracle/roles/logging/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: Slurp docker compose file
slurp:
src: "{{ bridge_path }}/docker-compose.yml"
src: "{{ bridge_path }}/oracle/docker-compose.yml"
register: docker_compose_slurp

- name: Parse docker compose file
Expand All @@ -15,7 +15,7 @@
- name: Write new docker-compose file
copy:
content: "{{ docker_compose_parsed | to_yaml }}"
dest: "{{ bridge_path }}/docker-compose.yml"
dest: "{{ bridge_path }}/oracle/docker-compose.yml"

- name: Set the local container logs configuration file
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ template(name="DockerLogFileName" type="list") {
constant(value="/docker.log")
}

if $programname startswith 'bridge_' then \
if $programname startswith 'oracle_bridge_' then \
?DockerLogFileName
else
/var/log/docker/no_tag/docker.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ template(name="RemoteForwardFormat" type="list") {
property(name="msg")
}

if $programname startswith 'bridge_' or $programname startswith 'docker' then {
if $programname startswith 'oracle_bridge_' or $programname startswith 'docker' then {
action(
type="omfwd"
protocol="{{ syslog_server_port.split(":")[0] }}"
Expand Down
6 changes: 3 additions & 3 deletions deployment/oracle/roles/post_config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
become_user: "{{ compose_service_user }}"
shell: docker-compose run --entrypoint "node scripts/getValidatorStartBlocks.js" bridge_affirmation
args:
chdir: "{{ bridge_path }}"
chdir: "{{ bridge_path }}/oracle"
register: BLOCKS

- name: Write blocks
blockinfile:
path: "{{ bridge_path }}/.env"
path: "{{ bridge_path }}/oracle/.env"
marker: "## {mark} Calculated by scripts/getValidatorStartBlocks.js"
block: |
HOME_START_BLOCK={{ (BLOCKS.stdout | from_json).homeStartBlock }}
Expand All @@ -17,7 +17,7 @@
become_user: "{{ compose_service_user }}"
shell: docker-compose run -e VALIDATOR_ADDRESS_PRIVATE_KEY="{{ VALIDATOR_ADDRESS_PRIVATE_KEY }}" --entrypoint "node scripts/privateKeyToAddress.js" bridge_affirmation
args:
chdir: "{{ bridge_path }}"
chdir: "{{ bridge_path }}/oracle"
register: VADDRESS

- name: Set VALIDATOR_ADDRESS variable
Expand Down
2 changes: 1 addition & 1 deletion deployment/oracle/roles/pre_config/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- name: Install .env config
template:
src: .env.j2
dest: "{{ bridge_path }}/.env"
dest: "{{ bridge_path }}/oracle/.env"
4 changes: 2 additions & 2 deletions deployment/oracle/roles/repo/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bridge_path: "/home/{{ compose_service_user }}/bridge"
bridge_repo: https://github.com/poanetwork/token-bridge.git
bridge_repo_branch: master
bridge_repo: https://github.com/poanetwork/tokenbridge.git
bridge_repo_branch: master
2 changes: 1 addition & 1 deletion deployment/oracle/roles/servinstall/templates/poabridge.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Description: Enable service provided by daemon.
### END INIT INFO

WORKDIR="{{ '/home/' + compose_service_user | default('poadocker') + '/' + bridge_path if bridge_path[:1] != "/" else bridge_path }}"
WORKDIR="{{ '/home/' + compose_service_user | default('poadocker') + '/' + bridge_path + '/oracle' if bridge_path[:1] != "/" else bridge_path + '/oracle' }}"

#Getting path to private key file and variable name for parsing key file
keyfile="{{ keyfile_path }}"
Expand Down
61 changes: 26 additions & 35 deletions monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,34 +94,23 @@ Example of an API
}
```

* `GET /stuckTransfers` - check stucked transfers that wasnot called by transferAndCall
```json
{

"stuckTransfers": [
{
"address": "0x6758B7d441a9739b98552B373703d8d3d14f9e62",
"blockNumber": 5964312,
"transactionHash": "0x74413ba79509a292d5d0d6edd364b3617c83a57b13d603de9deb6c8e6b6c6daf",
...
"returnValues": {
"0": "0x8D4bbc1B533aB9e3a743210870b6e3c4c0f7E935",
"1": "0xd819E948b14cA6AAD2b7Ffd333cCDf732b129EeD",
"2": "10000000000000000000000",
"from": "0x8D4bbc1B533aB9e3a743210870b6e3c4c0f7E935",
"to": "0xd819E948b14cA6AAD2b7Ffd333cCDf732b129EeD",
"value": "10000000000000000000000"
},
...
}
],
"total": 2,
"lastChecked": 1535058662
}
# How to run

## Setup

1. [Initialize](../README.md#initializing-the-monorepository) the monorepository.

2. Go to the monitor sub-repository:
```
cd monitor
```

# How to run
Create .env file (see `.env.example` for parameters reference)
3. Create .env file:
```
cp .env.example .env
```

#### Example:
```bash
HOME_RPC_URL=https://sokol.poa.network
FOREIGN_RPC_URL=https://kovan.infura.io/mew
Expand All @@ -133,17 +122,19 @@ GAS_PRICE_FALLBACK=21
LEFT_TX_THRESHOLD=100
```

```bash
npm i
# check balances of contracts and validators
## Check balances of contracts and validators
```
node checkWorker.js
# check unprocessed events
```

## Check unprocessed events
```
node checkWorker2.js
# check stuck transfers called by transfer, not transferAndCall
# only applicable for bridge-rust-v1-native-to-erc
node checkWorker3.js
# run web interface
node index.js
```

## Run web interface
```
yarn start
```

To enabled debug logging, set `DEBUG=1` env variable.
Expand Down
23 changes: 0 additions & 23 deletions monitor/checkWorker3.js

This file was deleted.

Loading

0 comments on commit 93347b4

Please sign in to comment.