A watcher listens for a certain event and creates proper jobs in the queue. These jobs contain the transaction data (without the nonce) and the transaction hash for the related event. The watcher runs on a given frequency, keeping track of the last processed block.
There are three Watchers:
- Signature Request Watcher: Listens to
UserRequestForSignature
events on Home network. - Collected Signatures Watcher: Listens to
CollectedSignatures
events on Home network. - Affirmation Request Watcher: Listens to
UserRequestForAffirmation
events on Foreign network.
A sender subscribes to the queue and keeps track of the nonce. It takes jobs from the queue, extract transaction data, adds proper nonce and sends it to the network.
There are two Senders:
- Home Sender: Sends transaction to Home network.
- Foreign Sender: Sends transaction to Foreign network.
-
Deploy bridge contracts
- Clone repo:
git clone https://github.com/poanetwork/poa-bridge-contracts
cd poa-bridge-contracts
- Checkout branch
v2
:git checkout v2
- Compile contracts:
truffle compile
- Go to deploy folder:
cd deploy
- create a
.env
file:cp .env.example .env
(look at.env.example
to see the variables that need to be present) - Execute
node deploy.js
- Clone repo:
- RabbitMQ version:
3.7
- Redis version:
4.0
- Create a
.env
file:cp .env.example .env
and fill in the information using the output data from previous deploy step. Check the.env.example
file to see the required variables.
npm run watcher:signature-request
npm run watcher:collected-signatures
npm run watcher:affirmation-request
npm run sender:home
npm run sender:foreign
To send deposits to home contract run node tests/sendUserTxToHome.js
To send withdrawals to foreign contract run node tests/sendUserTxToForeign.js
Make sure your HOME_MIN_AMOUNT_PER_TX
and FOREIGN_MIN_AMOUNT_PER_TX
is same as in your .env deployment contract
On .env
file set BRIDGE_MODE=ERC_TO_ERC
npm run watcher:signature-request
npm run watcher:collected-signatures
npm run watcher:affirmation-request
npm run sender:home
npm run sender:foreign
To send deposits to home contract run node tests/sendUserTxToErcHome.js
To send withdrawals to foreign contract run node tests/sendUserTxToErcForeign.js
- Start RabbitMQ and Redis:
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
To use the bridge UI, clone the repo,
create a .env
using the same values as before, and run npm start
.
Command | Description |
---|---|
rabbitmqctl list_queues |
List all queues |
rabbitmqctl purge_queue home |
Remove all messages from home queue |
Use redis-cli
Command | Description |
---|---|
KEYS * |
Returns all keys |
SET signature-request:lastProcessedBlock 1234 |
Set key to hold the string value. |
GET signature-request:lastProcessedBlock |
Get the value of key. |
DEL signature-request:lastProcessedBlock |
Removes the specified key. |
FLUSHALL |
Delete all the keys of all the existing databases |
Variable | Description | Values |
---|---|---|
ALLOW_HTTP |
Explicitly allows the usage of http connections instead of https . |
yes / no |