Skip to content

Commit

Permalink
Merge pull request #128 from poanetwork/develop
Browse files Browse the repository at this point in the history
Merge the develop branch to the master branch
  • Loading branch information
akolotov authored Dec 29, 2018
2 parents aa72238 + e4fb533 commit 7ccf71d
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 51 deletions.
13 changes: 11 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
node_modules
CODE_OF_CONDUCT.md
CONTRIBUTING.md
docker-compose.yml
Dockerfile
.dockerignore
docs
e2e
.git
.env*
.git*
LICENSE
README.md
node_modules
19 changes: 9 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ HOME_BRIDGE_ADDRESS=0x86b621b839Ff86Bb59fA57015b02318f9a870d80
FOREIGN_BRIDGE_ADDRESS=0x8dDCa2eB86D22FcB93342753515986e258A90169
ERC20_TOKEN_ADDRESS=0x7AA0A62497B5f4120fbe5D26c95bC612c2b96C14

VALIDATOR_ADDRESS=0xb8988B690910913c97A090c3a6f80FAD8b3A4683
VALIDATOR_ADDRESS_PRIVATE_KEY=

HOME_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
Expand All @@ -21,8 +20,8 @@ FOREIGN_GAS_PRICE_SPEED_TYPE=standard
FOREIGN_GAS_PRICE_FALLBACK=1000000000
FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000

QUEUE_URL=amqp://127.0.0.1
REDIS_URL=redis://127.0.0.1:6379
QUEUE_URL=amqp://rabbit
REDIS_URL=redis://redis
REDIS_LOCK_TTL=1000

HOME_START_BLOCK=
Expand All @@ -31,10 +30,10 @@ FOREIGN_START_BLOCK=
LOG_LEVEL=debug
MAX_PROCESSING_TIME=20000

#testing accs
USER_ADDRESS=0x59c4474184579b9c31b5e51445b6eef91cebf370
USER_ADDRESS_PRIVATE_KEY=
HOME_MIN_AMOUNT_PER_TX=0.001
FOREIGN_MIN_AMOUNT_PER_TX=0.001
HOME_TEST_TX_GAS_PRICE=1000000000
FOREIGN_TEST_TX_GAS_PRICE=1000000000
#Uncomment these lines only if you are going to send transaction by testing scripts
#USER_ADDRESS=0x59c4474184579b9c31b5e51445b6eef91cebf370
#USER_ADDRESS_PRIVATE_KEY=
#HOME_MIN_AMOUNT_PER_TX=0.001
#FOREIGN_MIN_AMOUNT_PER_TX=0.001
#HOME_TEST_TX_GAS_PRICE=1000000000
#FOREIGN_TEST_TX_GAS_PRICE=1000000000
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ COPY package-lock.json .
RUN npm install
COPY . .
CMD echo "To start a bridge process run:" \
"docker-compose run bridge npm run watcher:signature-request" \
"docker-compose run bridge npm run watcher:collected-signatures" \
"docker-compose run bridge npm run watcher:affirmation-request" \
"docker-compose run bridge npm run sender:home" \
"docker-compose run bridge npm run sender:foreign"
"VALIDATOR_ADDRESS=<validator address> VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up -d --build"
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,9 @@ There are two options to run the nodejs oracle:

### Docker

- Start RabbitMQ and Redis: if you are running the bridge containers for the first time use `docker-compose up -d --build` otherwise use `docker-compose up -d`
- `docker-compose run bridge npm run watcher:signature-request`
- `docker-compose run bridge npm run watcher:collected-signatures`
- `docker-compose run bridge npm run watcher:affirmation-request`
- `docker-compose run bridge npm run sender:home`
- `docker-compose run bridge npm run sender:foreign`
- While running the bridge containers for the first time use `VALIDATOR_ADDRESS=<validator address> VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up -d --build`
- For further launches use `VALIDATOR_ADDRESS=<validator address> VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up --detach`
- If you want to use any command from this document, prefix it with `docker-compose exec bridge_affirmation`, if not already prefixed, to execute command inside on of the running docker containers. Make sure bridge service is started before using the commands.

### NPM

Expand All @@ -174,12 +171,11 @@ Execute this command in the bridge root directory:
```shell
bash ./reset-lastBlock.sh <watcher> <block num>
```
or
for NPM installation or
```shell
docker-compose run bridge bash ./reset-lastBlock.sh <watcher> <block num>
docker-compose exec bridge_affirmation bash ./reset-lastBlock.sh <watcher> <block num>
```

where the _watcher_ could be one of:
for docker installation respectively, where the _watcher_ could be one of:

- `signature-request`
- `collected-signatures`
Expand Down Expand Up @@ -248,13 +244,15 @@ npm test

See the [E2E README](/e2e) for instructions.

*Notice*: for docker-based installations do not forget to add `docker-compose exec bridge_affirmation` before the test commands listed below.

### Native-to-ERC20 Mode Testing

When running the processes, the following commands can be used to test functionality.

- To send deposits to a home contract run `node scripts/native_to_erc20/sendHome.js <tx num>` (or `docker-compose run bridge node scripts/native_to_erc20/sendHome.js <tx num>`), where `<tx num>` is how many tx will be sent out to deposit.
- To send deposits to a home contract run `node scripts/native_to_erc20/sendHome.js <tx num>`, where `<tx num>` is how many tx will be sent out to deposit.

- To send withdrawals to a foreign contract run `node scripts/native_to_erc20/sendForeign.js <tx num>` (or `docker-compose run bridge node scripts/native_to_erc20/sendForeign.js <tx num>`), where `<tx num>` is how many tx will be sent out to withdraw.
- To send withdrawals to a foreign contract run `node scripts/native_to_erc20/sendForeign.js <tx num>`, where `<tx num>` is how many tx will be sent out to withdraw.

### ERC20-to-ERC20 Mode Testing

Expand All @@ -268,7 +266,6 @@ When running the processes, the following commands can be used to test functiona

- To make withdrawal to Home from a Foreign contract run `node scripts/erc20_to_native/sendHome.js <tx num>`.


### Configuration parameters for testing

| Variable | Description |
Expand Down
Binary file not shown.
138 changes: 117 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,122 @@
version: "3"
version: '2.4'
services:
redis:
image: "redis:4"
command: ["redis-server", "--appendonly", "yes"]
hostname: redis
restart: on-failure
volumes:
- ~/bridge_data/redis:/data
rabbit:
image: "rabbitmq:3-management"
cpus: 0.3
mem_limit: 500m
environment: ['RABBITMQ_NODENAME=node@rabbit']
hostname: rabbit
environment:
- RABBITMQ_NODENAME=node@rabbit
volumes:
- ~/bridge_data/rabbitmq:/var/lib/rabbitmq/mnesia
restart: on-failure
bridge:
image: rabbitmq:3
networks:
- net_rabbit_bridge_request
- net_rabbit_bridge_collected
- net_rabbit_bridge_affirmation
- net_rabbit_bridge_senderhome
- net_rabbit_bridge_senderforeign
restart: unless-stopped
volumes: ['~/bridge_data/rabbitmq:/var/lib/rabbitmq/mnesia']
redis:
cpus: 0.1
mem_limit: 500m
command: [redis-server, --appendonly, 'yes']
hostname: redis
image: redis:4
networks:
- net_db_bridge_request
- net_db_bridge_collected
- net_db_bridge_affirmation
- net_db_bridge_senderhome
- net_db_bridge_senderforeign
restart: unless-stopped
volumes: ['~/bridge_data/redis:/data']
bridge_request:
cpus: 0.1
mem_limit: 500m
build: .
command: 'true'
env_file: ./.env
environment:
- NODE_ENV=production
- VALIDATOR_ADDRESS_PRIVATE_KEY=${VALIDATOR_ADDRESS_PRIVATE_KEY}
restart: unless-stopped
entrypoint: npm run watcher:signature-request
networks:
- net_db_bridge_request
- net_rabbit_bridge_request
bridge_collected:
cpus: 0.1
mem_limit: 500m
build: .
command: 'true'
env_file: ./.env
environment:
- NODE_ENV=production
- VALIDATOR_ADDRESS=${VALIDATOR_ADDRESS}
restart: unless-stopped
entrypoint: npm run watcher:collected-signatures
networks:
- net_db_bridge_collected
- net_rabbit_bridge_collected
bridge_affirmation:
cpus: 0.1
mem_limit: 500m
build: .
command: 'true'
env_file: ./.env
environment:
- NODE_ENV=production
- VALIDATOR_ADDRESS=${VALIDATOR_ADDRESS}
restart: unless-stopped
entrypoint: npm run watcher:affirmation-request
networks:
- net_db_bridge_affirmation
- net_rabbit_bridge_affirmation
bridge_senderhome:
cpus: 0.1
mem_limit: 500m
build: .
command: 'true'
env_file: ./.env
environment:
- NODE_ENV=production
- VALIDATOR_ADDRESS_PRIVATE_KEY=${VALIDATOR_ADDRESS_PRIVATE_KEY}
restart: unless-stopped
entrypoint: npm run sender:home
networks:
- net_db_bridge_senderhome
- net_rabbit_bridge_senderhome
bridge_senderforeign:
cpus: 0.1
mem_limit: 500m
build: .
command: 'true'
env_file: ./.env
environment:
- NODE_ENV=production
- QUEUE_URL=amqp://rabbit
- REDIS_URL=redis://redis
command: "true"
restart: on-failure
environment:
- NODE_ENV=production
- VALIDATOR_ADDRESS_PRIVATE_KEY=${VALIDATOR_ADDRESS_PRIVATE_KEY}
restart: unless-stopped
entrypoint: npm run sender:foreign
networks:
- net_db_bridge_senderforeign
- net_rabbit_bridge_senderforeign

networks:
net_db_bridge_request:
driver: bridge
net_db_bridge_collected:
driver: bridge
net_db_bridge_affirmation:
driver: bridge
net_db_bridge_senderhome:
driver: bridge
net_db_bridge_senderforeign:
driver: bridge
net_rabbit_bridge_request:
driver: bridge
net_rabbit_bridge_collected:
driver: bridge
net_rabbit_bridge_affirmation:
driver: bridge
net_rabbit_bridge_senderhome:
driver: bridge
net_rabbit_bridge_senderforeign:
driver: bridge

0 comments on commit 7ccf71d

Please sign in to comment.