Compare commits
6 Commits
master
...
combined-b
Author | SHA1 | Date | |
---|---|---|---|
|
6692a5fc87 | ||
|
85e23bd992 | ||
|
a2e110dbc7 | ||
|
aa56744e8d | ||
|
2393d6c554 | ||
|
0de29b5847 |
@ -19,7 +19,7 @@ Sub-repositories maintained within this monorepo are listed below.
|
||||
|
||||
| Sub-repository | Description |
|
||||
| --- | --- |
|
||||
| [Oracle](oracle/README.md) | Responsible for listening to bridge related events and authorizing asset transfers. |
|
||||
| [Oracle](oracle/README.md) | Oracle responsible for listening to bridge related events and authorizing asset transfers. |
|
||||
| [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](oracle-e2e/README.md) | End to end tests for the Oracle |
|
||||
|
@ -22,16 +22,6 @@ export const getRequiredBlockConfirmations = async (
|
||||
web3: Web3 | null = null,
|
||||
api: string = ''
|
||||
) => {
|
||||
let blockConfirmations
|
||||
|
||||
try {
|
||||
blockConfirmations = await contract.methods.requiredBlockConfirmations().call()
|
||||
} catch {}
|
||||
|
||||
if (blockConfirmations) {
|
||||
return parseInt(blockConfirmations)
|
||||
}
|
||||
|
||||
const eventsFromSnapshot = snapshotProvider.requiredBlockConfirmationEvents(blockNumber)
|
||||
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
||||
|
||||
@ -45,10 +35,16 @@ export const getRequiredBlockConfirmations = async (
|
||||
|
||||
const events = [...eventsFromSnapshot, ...contractEvents]
|
||||
|
||||
// Use the value from last event before the transaction
|
||||
const event = events[events.length - 1]
|
||||
blockConfirmations = event.returnValues.requiredBlockConfirmations
|
||||
|
||||
let blockConfirmations
|
||||
if (events.length > 0) {
|
||||
// Use the value from last event before the transaction
|
||||
const event = events[events.length - 1]
|
||||
blockConfirmations = event.returnValues.requiredBlockConfirmations
|
||||
} else {
|
||||
// This is a special case where RequiredBlockConfirmationChanged was not emitted during initialization in early versions of AMB
|
||||
// of Sokol - Kovan. In this case the current value is used.
|
||||
blockConfirmations = await contract.methods.requiredBlockConfirmations().call()
|
||||
}
|
||||
return parseInt(blockConfirmations)
|
||||
}
|
||||
|
||||
@ -61,16 +57,6 @@ export const getRequiredSignatures = async (
|
||||
web3: Web3 | null = null,
|
||||
api: string = ''
|
||||
) => {
|
||||
let requiredSignatures
|
||||
|
||||
try {
|
||||
requiredSignatures = await contract.methods.requiredSignatures().call()
|
||||
} catch {}
|
||||
|
||||
if (requiredSignatures) {
|
||||
return parseInt(requiredSignatures)
|
||||
}
|
||||
|
||||
if (blockNumber === 'latest') {
|
||||
return contract.methods.requiredSignatures().call()
|
||||
}
|
||||
@ -90,7 +76,7 @@ export const getRequiredSignatures = async (
|
||||
|
||||
// Use the value form last event before the transaction
|
||||
const event = events[events.length - 1]
|
||||
;({ requiredSignatures } = event.returnValues)
|
||||
const { requiredSignatures } = event.returnValues
|
||||
return parseInt(requiredSignatures)
|
||||
}
|
||||
|
||||
@ -101,13 +87,9 @@ export const getValidatorList = async (
|
||||
web3: Web3 | null = null,
|
||||
api: string = ''
|
||||
) => {
|
||||
try {
|
||||
const currentList = await contract.methods.validatorList().call()
|
||||
|
||||
if (currentList) {
|
||||
return currentList
|
||||
}
|
||||
} catch {}
|
||||
if (blockNumber === 'latest') {
|
||||
return contract.methods.validatorList().call()
|
||||
}
|
||||
|
||||
const addedEventsFromSnapshot = snapshotProvider.validatorAddedEvents(blockNumber)
|
||||
const removedEventsFromSnapshot = snapshotProvider.validatorRemovedEvents(blockNumber)
|
||||
|
@ -5,7 +5,8 @@ sokol-kovan:
|
||||
hosts:
|
||||
127.0.0.1:
|
||||
ansible_user: ubuntu
|
||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
#syslog_server_port: "udp://127.0.0.1:514"
|
||||
monitor:
|
||||
hosts:
|
||||
|
@ -1,6 +1,3 @@
|
||||
---
|
||||
bridge_path: "/home/{{ compose_service_user }}/bridge"
|
||||
ORACLE_ALLOW_HTTP_FOR_RPC: no
|
||||
ORACLE_QUEUE_URL: amqp://rabbit
|
||||
ORACLE_REDIS_URL: redis://redis
|
||||
keyfile_path: "/root/.key"
|
||||
|
@ -2,8 +2,6 @@
|
||||
- include_tasks: logging_by_syslog.yml
|
||||
with_items:
|
||||
- docker-compose
|
||||
- docker-compose-transfer
|
||||
- docker-compose-amb
|
||||
loop_control:
|
||||
loop_var: file
|
||||
|
||||
|
@ -1,39 +1,59 @@
|
||||
---
|
||||
- name: Get blocks
|
||||
- name: Get blocks for TokenBridge
|
||||
become_user: "{{ compose_service_user }}"
|
||||
shell: docker-compose run --rm --entrypoint "node scripts/getValidatorStartBlocks.js" bridge_affirmation
|
||||
args:
|
||||
chdir: "{{ bridge_path }}/oracle"
|
||||
register: BLOCKS
|
||||
when: (ORACLE_HOME_START_BLOCK is not defined) or (ORACLE_FOREIGN_START_BLOCK is not defined)
|
||||
register: TBBLOCKS
|
||||
when: (TB_HOME_START_BLOCK is not defined) or (TB_FOREIGN_START_BLOCK is not defined)
|
||||
|
||||
- name: Write blocks
|
||||
- name: Get blocks for AMB
|
||||
become_user: "{{ compose_service_user }}"
|
||||
shell: docker-compose run --rm --entrypoint "node scripts/getValidatorStartBlocks.js" bridge_amb_affirmation
|
||||
args:
|
||||
chdir: "{{ bridge_path }}/oracle"
|
||||
register: AMBBLOCKS
|
||||
when: (AMB_HOME_START_BLOCK is not defined) or (AMB_FOREIGN_START_BLOCK is not defined)
|
||||
|
||||
- name: Write blocks for TokenBridge
|
||||
blockinfile:
|
||||
path: "{{ bridge_path }}/oracle/.env"
|
||||
marker: "## {mark} Calculated by scripts/getValidatorStartBlocks.js"
|
||||
block: |
|
||||
ORACLE_HOME_START_BLOCK={{ (BLOCKS.stdout | from_json).homeStartBlock }}
|
||||
ORACLE_FOREIGN_START_BLOCK={{ (BLOCKS.stdout | from_json).foreignStartBlock }}
|
||||
when: (ORACLE_HOME_START_BLOCK is not defined) or (ORACLE_FOREIGN_START_BLOCK is not defined)
|
||||
TB_HOME_START_BLOCK={{ (TBBLOCKS.stdout | from_json).homeStartBlock }}
|
||||
TB_FOREIGN_START_BLOCK={{ (TBBLOCKS.stdout | from_json).foreignStartBlock }}
|
||||
when: (TB_HOME_START_BLOCK is not defined) or (TB_FOREIGN_START_BLOCK is not defined)
|
||||
|
||||
- name: Get validator address
|
||||
- name: Write blocks for AMB
|
||||
blockinfile:
|
||||
path: "{{ bridge_path }}/oracle/.env"
|
||||
marker: "## {mark} Calculated by scripts/getValidatorStartBlocks.js"
|
||||
block: |
|
||||
AMB_HOME_START_BLOCK={{ (AMBBLOCKS.stdout | from_json).homeStartBlock }}
|
||||
AMB_FOREIGN_START_BLOCK={{ (AMBBLOCKS.stdout | from_json).foreignStartBlock }}
|
||||
when: (AMB_HOME_START_BLOCK is not defined) or (AMB_FOREIGN_START_BLOCK is not defined)
|
||||
|
||||
- name: Get validator address for TokenBridge
|
||||
become_user: "{{ compose_service_user }}"
|
||||
shell: docker-compose run --rm -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="{{ ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY }}" --entrypoint "node scripts/privateKeyToAddress.js" bridge_affirmation
|
||||
shell: docker-compose run --rm -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="{{ TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY }}" --entrypoint "node scripts/privateKeyToAddress.js" bridge_affirmation
|
||||
args:
|
||||
chdir: "{{ bridge_path }}/oracle"
|
||||
register: VADDRESS
|
||||
register: TBVADDRESS
|
||||
|
||||
- name: Set ORACLE_VALIDATOR_ADDRESS variable
|
||||
- name: Set TB_ORACLE_VALIDATOR_ADDRESS variable
|
||||
set_fact:
|
||||
ORACLE_VALIDATOR_ADDRESS: "{{ VADDRESS.stdout }}"
|
||||
TB_ORACLE_VALIDATOR_ADDRESS: "{{ TBVADDRESS.stdout }}"
|
||||
|
||||
- name: Extend docker compose file for erc to native
|
||||
set_fact: composefileoverride="-f docker-compose-transfer.yml"
|
||||
when: ORACLE_BRIDGE_MODE == "ERC_TO_NATIVE"
|
||||
- name: Get validator address for AMB
|
||||
become_user: "{{ compose_service_user }}"
|
||||
shell: docker-compose run --rm -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="{{ AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY }}" --entrypoint "node scripts/privateKeyToAddress.js" bridge_affirmation
|
||||
args:
|
||||
chdir: "{{ bridge_path }}/oracle"
|
||||
register: AMBVADDRESS
|
||||
|
||||
- name: Extend docker compose file for amb
|
||||
set_fact: composefileoverride="-f docker-compose-amb.yml"
|
||||
when: ORACLE_BRIDGE_MODE == "ARBITRARY_MESSAGE"
|
||||
- name: Set AMB_ORACLE_VALIDATOR_ADDRESS variable
|
||||
set_fact:
|
||||
AMB_ORACLE_VALIDATOR_ADDRESS: "{{ AMBVADDRESS.stdout }}"
|
||||
|
||||
- name: Install .key config
|
||||
template:
|
||||
|
@ -12,12 +12,8 @@
|
||||
owner: "{{ compose_service_user }}"
|
||||
mode: '0640'
|
||||
|
||||
- name: Copy docker-compose files
|
||||
- name: Copy docker-compose file
|
||||
copy:
|
||||
src: ../../../../oracle/{{ item }}
|
||||
dest: "{{ bridge_path }}/oracle/"
|
||||
src: ../../../../oracle/docker-compose-combined.yml
|
||||
dest: "{{ bridge_path }}/oracle/docker-compose.yml"
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- docker-compose.yml
|
||||
- docker-compose-transfer.yml
|
||||
- docker-compose-amb.yml
|
||||
|
@ -1,21 +1,28 @@
|
||||
## General settings
|
||||
ORACLE_BRIDGE_MODE={{ ORACLE_BRIDGE_MODE }}
|
||||
{% if ORACLE_LOG_LEVEL | default('') != '' %}
|
||||
ORACLE_LOG_LEVEL={{ ORACLE_LOG_LEVEL }}
|
||||
{% endif %}
|
||||
|
||||
## Home contract
|
||||
COMMON_HOME_RPC_URL={{ COMMON_HOME_RPC_URL }}
|
||||
COMMON_HOME_BRIDGE_ADDRESS={{ COMMON_HOME_BRIDGE_ADDRESS }}
|
||||
TB_HOME_BRIDGE_ADDRESS={{ TB_HOME_BRIDGE_ADDRESS }}
|
||||
AMB_HOME_BRIDGE_ADDRESS={{ AMB_HOME_BRIDGE_ADDRESS }}
|
||||
ORACLE_HOME_RPC_POLLING_INTERVAL={{ ORACLE_HOME_RPC_POLLING_INTERVAL }}
|
||||
{% if ORACLE_HOME_RPC_BLOCK_POLLING_LIMIT | default('') != '' %}
|
||||
ORACLE_HOME_RPC_BLOCK_POLLING_LIMIT={{ ORACLE_HOME_RPC_BLOCK_POLLING_LIMIT }}
|
||||
{% endif %}
|
||||
|
||||
## Foreign contract
|
||||
COMMON_FOREIGN_RPC_URL={{ COMMON_FOREIGN_RPC_URL }}
|
||||
{% if ORACLE_FOREIGN_ARCHIVE_RPC_URL | default('') != '' %}
|
||||
ORACLE_FOREIGN_ARCHIVE_RPC_URL={{ ORACLE_FOREIGN_ARCHIVE_RPC_URL }}
|
||||
{% endif %}
|
||||
COMMON_FOREIGN_BRIDGE_ADDRESS={{ COMMON_FOREIGN_BRIDGE_ADDRESS }}
|
||||
TB_FOREIGN_BRIDGE_ADDRESS={{ TB_FOREIGN_BRIDGE_ADDRESS }}
|
||||
AMB_FOREIGN_BRIDGE_ADDRESS={{ AMB_FOREIGN_BRIDGE_ADDRESS }}
|
||||
ORACLE_FOREIGN_RPC_POLLING_INTERVAL={{ ORACLE_FOREIGN_RPC_POLLING_INTERVAL }}
|
||||
{% if ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT | default('') != '' %}
|
||||
ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT={{ ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT }}
|
||||
{% endif %}
|
||||
|
||||
{% if ORACLE_TX_REDUNDANCY | default('') != '' %}
|
||||
ORACLE_TX_REDUNDANCY={{ ORACLE_TX_REDUNDANCY }}
|
||||
@ -52,8 +59,10 @@ COMMON_FOREIGN_GAS_PRICE_FACTOR={{ COMMON_FOREIGN_GAS_PRICE_FACTOR }}
|
||||
|
||||
## Transport configuration
|
||||
ORACLE_ALLOW_HTTP_FOR_RPC={{ "yes" if ORACLE_ALLOW_HTTP_FOR_RPC else "no" }}
|
||||
ORACLE_QUEUE_URL={{ ORACLE_QUEUE_URL }}
|
||||
ORACLE_REDIS_URL={{ ORACLE_REDIS_URL }}
|
||||
TB_QUEUE_URL={{ TB_QUEUE_URL }}
|
||||
TB_REDIS_URL={{ TB_REDIS_URL }}
|
||||
AMB_QUEUE_URL={{ AMB_QUEUE_URL }}
|
||||
AMB_REDIS_URL={{ AMB_REDIS_URL }}
|
||||
{% if ORACLE_FOREIGN_TX_RESEND_INTERVAL | default('') != '' %}
|
||||
ORACLE_FOREIGN_TX_RESEND_INTERVAL={{ ORACLE_FOREIGN_TX_RESEND_INTERVAL }}
|
||||
{% endif %}
|
||||
@ -61,26 +70,50 @@ ORACLE_FOREIGN_TX_RESEND_INTERVAL={{ ORACLE_FOREIGN_TX_RESEND_INTERVAL }}
|
||||
ORACLE_HOME_TX_RESEND_INTERVAL={{ ORACLE_HOME_TX_RESEND_INTERVAL }}
|
||||
{% endif %}
|
||||
|
||||
## Emergency shutdown configuration
|
||||
{% if ORACLE_SHUTDOWN_SERVICE_URL | default('') != '' %}
|
||||
ORACLE_SHUTDOWN_SERVICE_URL={{ ORACLE_SHUTDOWN_SERVICE_URL }}
|
||||
## Emergency shutdown configuration for TokenBridge
|
||||
{% if TB_SHUTDOWN_SERVICE_URL | default('') != '' %}
|
||||
TB_SHUTDOWN_SERVICE_URL={{ TB_SHUTDOWN_SERVICE_URL }}
|
||||
{% endif %}
|
||||
{% if ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL | default('') != '' %}
|
||||
ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL={{ ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL }}
|
||||
{% if TB_SHUTDOWN_SERVICE_POLLING_INTERVAL | default('') != '' %}
|
||||
TB_SHUTDOWN_SERVICE_POLLING_INTERVAL={{ TB_SHUTDOWN_SERVICE_POLLING_INTERVAL }}
|
||||
{% endif %}
|
||||
{% if ORACLE_SIDE_RPC_URL | default('') != '' %}
|
||||
ORACLE_SIDE_RPC_URL={{ ORACLE_SIDE_RPC_URL }}
|
||||
{% if TB_SIDE_RPC_URL | default('') != '' %}
|
||||
TB_SIDE_RPC_URL={{ TB_SIDE_RPC_URL }}
|
||||
{% endif %}
|
||||
{% if ORACLE_SHUTDOWN_CONTRACT_ADDRESS | default('') != '' %}
|
||||
ORACLE_SHUTDOWN_CONTRACT_ADDRESS={{ ORACLE_SHUTDOWN_CONTRACT_ADDRESS }}
|
||||
{% if TB_SHUTDOWN_CONTRACT_ADDRESS | default('') != '' %}
|
||||
TB_SHUTDOWN_CONTRACT_ADDRESS={{ TB_SHUTDOWN_CONTRACT_ADDRESS }}
|
||||
{% endif %}
|
||||
{% if ORACLE_SHUTDOWN_CONTRACT_METHOD | default('') != '' %}
|
||||
ORACLE_SHUTDOWN_CONTRACT_METHOD={{ ORACLE_SHUTDOWN_CONTRACT_METHOD }}
|
||||
{% if TB_SHUTDOWN_CONTRACT_METHOD | default('') != '' %}
|
||||
TB_SHUTDOWN_CONTRACT_METHOD={{ TB_SHUTDOWN_CONTRACT_METHOD }}
|
||||
{% endif %}
|
||||
|
||||
{% if ORACLE_HOME_START_BLOCK | default('') != '' %}
|
||||
ORACLE_HOME_START_BLOCK={{ ORACLE_HOME_START_BLOCK }}
|
||||
## Emergency shutdown configuration for AMB
|
||||
{% if AMB_SHUTDOWN_SERVICE_URL | default('') != '' %}
|
||||
AMB_SHUTDOWN_SERVICE_URL={{ AMB_SHUTDOWN_SERVICE_URL }}
|
||||
{% endif %}
|
||||
{% if ORACLE_FOREIGN_START_BLOCK | default('') != '' %}
|
||||
ORACLE_FOREIGN_START_BLOCK={{ ORACLE_FOREIGN_START_BLOCK }}
|
||||
{% if AMB_SHUTDOWN_SERVICE_POLLING_INTERVAL | default('') != '' %}
|
||||
AMB_SHUTDOWN_SERVICE_POLLING_INTERVAL={{ AMB_SHUTDOWN_SERVICE_POLLING_INTERVAL }}
|
||||
{% endif %}
|
||||
{% if AMB_SIDE_RPC_URL | default('') != '' %}
|
||||
AMB_SIDE_RPC_URL={{ AMB_SIDE_RPC_URL }}
|
||||
{% endif %}
|
||||
{% if AMB_SHUTDOWN_CONTRACT_ADDRESS | default('') != '' %}
|
||||
AMB_SHUTDOWN_CONTRACT_ADDRESS={{ AMB_SHUTDOWN_CONTRACT_ADDRESS }}
|
||||
{% endif %}
|
||||
{% if AMB_SHUTDOWN_CONTRACT_METHOD | default('') != '' %}
|
||||
AMB_SHUTDOWN_CONTRACT_METHOD={{ AMB_SHUTDOWN_CONTRACT_METHOD }}
|
||||
{% endif %}
|
||||
|
||||
{% if TB_HOME_START_BLOCK | default('') != '' %}
|
||||
TB_HOME_START_BLOCK={{ TB_HOME_START_BLOCK }}
|
||||
{% endif %}
|
||||
{% if TB_FOREIGN_START_BLOCK | default('') != '' %}
|
||||
TB_FOREIGN_START_BLOCK={{ TB_FOREIGN_START_BLOCK }}
|
||||
{% endif %}
|
||||
|
||||
{% if AMB_HOME_START_BLOCK | default('') != '' %}
|
||||
AMB_HOME_START_BLOCK={{ AMB_HOME_START_BLOCK }}
|
||||
{% endif %}
|
||||
{% if AMB_FOREIGN_START_BLOCK | default('') != '' %}
|
||||
AMB_FOREIGN_START_BLOCK={{ AMB_FOREIGN_START_BLOCK }}
|
||||
{% endif %}
|
@ -1,3 +1,6 @@
|
||||
## Validator-specific options
|
||||
ORACLE_VALIDATOR_ADDRESS={{ ORACLE_VALIDATOR_ADDRESS }}
|
||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY={{ ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY }}
|
||||
TB_ORACLE_VALIDATOR_ADDRESS={{ TB_ORACLE_VALIDATOR_ADDRESS }}
|
||||
TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY={{ TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY }}
|
||||
|
||||
AMB_ORACLE_VALIDATOR_ADDRESS={{ AMB_ORACLE_VALIDATOR_ADDRESS }}
|
||||
AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY={{ AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY }}
|
||||
|
@ -14,19 +14,26 @@ WORKDIR="{{ '/home/' + compose_service_user | default('poadocker') + '/' + bridg
|
||||
|
||||
#Getting path to private key file and variable name for parsing key file
|
||||
keyfile="{{ keyfile_path }}"
|
||||
vaddr="ORACLE_VALIDATOR_ADDRESS="
|
||||
vkey="ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="
|
||||
composefileoverride="{{ composefileoverride | default('') }}"
|
||||
tbvaddr="TB_ORACLE_VALIDATOR_ADDRESS="
|
||||
tbvkey="TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="
|
||||
ambvaddr="AMB_ORACLE_VALIDATOR_ADDRESS="
|
||||
ambvkey="AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="
|
||||
|
||||
#Parsing file content and add key to variable
|
||||
while read -r line
|
||||
do
|
||||
case $line in
|
||||
$vaddr*)
|
||||
vaddr=${line#$vaddr}
|
||||
$tbvaddr*)
|
||||
tbvaddr=${line#$tbvaddr}
|
||||
;;
|
||||
$vkey*)
|
||||
vkey=${line#$vkey}
|
||||
$tbvkey*)
|
||||
tbvkey=${line#$tbvkey}
|
||||
;;
|
||||
$ambvaddr*)
|
||||
ambvaddr=${line#$ambvaddr}
|
||||
;;
|
||||
$ambvkey*)
|
||||
ambvkey=${line#$ambvkey}
|
||||
;;
|
||||
esac
|
||||
done < $keyfile
|
||||
@ -34,22 +41,29 @@ done < $keyfile
|
||||
start(){
|
||||
echo "Starting bridge.."
|
||||
cd $WORKDIR
|
||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride down -v
|
||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride rm -fv
|
||||
sudo -u "{{ compose_service_user }}" ORACLE_VALIDATOR_ADDRESS=$vaddr ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=$vkey /usr/local/bin/docker-compose $composefileoverride up --detach
|
||||
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 }}" \
|
||||
TB_ORACLE_VALIDATOR_ADDRESS=$tbvaddr \
|
||||
TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=$tbvkey \
|
||||
AMB_ORACLE_VALIDATOR_ADDRESS=$ambvaddr \
|
||||
AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=$ambvkey \
|
||||
/usr/local/bin/docker-compose up --detach
|
||||
}
|
||||
|
||||
stop(){
|
||||
echo "Stopping bridge.."
|
||||
cd $WORKDIR
|
||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride down -v
|
||||
sudo -u "{{ compose_service_user }}" \
|
||||
/usr/local/bin/docker-compose down -v
|
||||
sleep 2
|
||||
}
|
||||
|
||||
status(){
|
||||
echo "Bridge status:"
|
||||
cd $WORKDIR
|
||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride ps
|
||||
sudo -u "{{ compose_service_user }}" \
|
||||
/usr/local/bin/docker-compose ps
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
# POA TokenBridge / Oracle
|
||||
An oracle responsible for listening to bridge related events and authorizing asset transfers.
|
||||
Oracle responsible for listening to bridge related events and authorizing asset transfers.
|
||||
|
||||
## Overview
|
||||
Please refer to the [POA TokenBridge](../README.md) overview first of all.
|
||||
|
||||
The oracle is deployed on specified validator nodes (only nodes whose private keys correspond to addresses specified in the smart contracts) in the network. It connects to two chains via a Remote Procedure Call (RPC) and is responsible for:
|
||||
The Oracle is deployed on specified validator nodes (only nodes whose private keys correspond to addresses specified in the smart contracts) in the network. It connects to two chains via a Remote Procedure Call (RPC) and is responsible for:
|
||||
- listening to events related to bridge contracts
|
||||
- sending transactions to authorize asset transfers
|
||||
|
||||
@ -69,7 +69,7 @@ For more information on the Redis/RabbitMQ requirements, see [#90](/../../issues
|
||||
}
|
||||
```
|
||||
|
||||
## Install and configure the oracle
|
||||
## Install and configure the Oracle
|
||||
|
||||
1. [Initialize](../README.md#initializing-the-monorepository) the monorepository.
|
||||
|
||||
|
334
oracle/docker-compose-combined.yml
Normal file
334
oracle/docker-compose-combined.yml
Normal file
@ -0,0 +1,334 @@
|
||||
---
|
||||
version: '2.4'
|
||||
networks:
|
||||
net_db_bridge_green: {driver: bridge}
|
||||
net_db_bridge_red: {driver: bridge}
|
||||
net_rabbit_bridge_green: {driver: bridge}
|
||||
net_rabbit_bridge_red: {driver: bridge}
|
||||
net_ne_bridge_red: {driver: bridge}
|
||||
net_ne_bridge_green: {driver: bridge}
|
||||
net_db_bridge_amb_green: {driver: bridge}
|
||||
net_db_bridge_amb_red: {driver: bridge}
|
||||
net_rabbit_bridge_amb_green: {driver: bridge}
|
||||
net_rabbit_bridge_amb_red: {driver: bridge}
|
||||
net_ne_bridge_amb_red: {driver: bridge}
|
||||
net_ne_bridge_amb_green: {driver: bridge}
|
||||
services:
|
||||
bridge_affirmation:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn watcher:affirmation-request
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ERC_TO_NATIVE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${TB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${TB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${TB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${TB_REDIS_URL}',
|
||||
'ORACLE_FOREIGN_START_BLOCK=${TB_FOREIGN_START_BLOCK}',
|
||||
'ORACLE_VALIDATOR_ADDRESS=${TB_ORACLE_VALIDATOR_ADDRESS}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_green,
|
||||
net_rabbit_bridge_green,
|
||||
net_ne_bridge_green]
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
depends_on:
|
||||
- redis
|
||||
- rabbit
|
||||
bridge_shutdown:
|
||||
cpus: 0.1
|
||||
mem_limit: 500m
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ERC_TO_NATIVE,
|
||||
'ORACLE_REDIS_URL=${TB_REDIS_URL}',
|
||||
'ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL=${TB_SHUTDOWN_SERVICE_POLLING_INTERVAL}',
|
||||
'ORACLE_SIDE_RPC_URL=${TB_SIDE_RPC_URL}',
|
||||
'ORACLE_SHUTDOWN_CONTRACT_ADDRESS=${TB_SHUTDOWN_CONTRACT_ADDRESS}',
|
||||
'ORACLE_SHUTDOWN_CONTRACT_METHOD=${TB_SHUTDOWN_CONTRACT_METHOD}']
|
||||
restart: unless-stopped
|
||||
entrypoint: yarn manager:shutdown
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
networks: [net_db_bridge_green]
|
||||
depends_on:
|
||||
- redis
|
||||
bridge_request:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn watcher:signature-request
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ERC_TO_NATIVE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${TB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${TB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${TB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${TB_REDIS_URL}',
|
||||
'ORACLE_HOME_START_BLOCK=${TB_HOME_START_BLOCK}',
|
||||
'ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=${TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_red,
|
||||
net_rabbit_bridge_red,
|
||||
net_ne_bridge_red]
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis
|
||||
- rabbit
|
||||
bridge_senderhome:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn sender:home
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ERC_TO_NATIVE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${TB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${TB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${TB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${TB_REDIS_URL}',
|
||||
'ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=${TB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_red,
|
||||
net_rabbit_bridge_red,
|
||||
net_ne_bridge_red]
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
depends_on:
|
||||
- redis
|
||||
- rabbit
|
||||
bridge_transfer:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn watcher:transfer
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ERC_TO_NATIVE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${TB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${TB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${TB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${TB_REDIS_URL}',
|
||||
'ORACLE_FOREIGN_START_BLOCK=${TB_FOREIGN_START_BLOCK}',
|
||||
'ORACLE_VALIDATOR_ADDRESS=${TB_ORACLE_VALIDATOR_ADDRESS}']
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_green,
|
||||
net_rabbit_bridge_green,
|
||||
net_ne_bridge_green]
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis
|
||||
- rabbit
|
||||
rabbit:
|
||||
cpus: 0.3
|
||||
environment: [RABBITMQ_NODENAME=node@rabbit]
|
||||
hostname: rabbit
|
||||
image: rabbitmq:3
|
||||
mem_limit: 500m
|
||||
networks: [net_rabbit_bridge_red,
|
||||
net_rabbit_bridge_green]
|
||||
restart: unless-stopped
|
||||
volumes: ['~/bridge_data/rabbitmq:/var/lib/rabbitmq/mnesia']
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
redis:
|
||||
command: [redis-server, --appendonly, 'yes']
|
||||
cpus: 0.1
|
||||
hostname: redis
|
||||
image: redis:4
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_red,
|
||||
net_db_bridge_green]
|
||||
restart: unless-stopped
|
||||
volumes: ['~/bridge_data/redis:/data']
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
|
||||
ne:
|
||||
container_name: ne
|
||||
image: nethermind/nethermind:latest
|
||||
networks: [net_ne_bridge_green,
|
||||
net_ne_bridge_red,
|
||||
net_ne_bridge_amb_green,
|
||||
net_ne_bridge_amb_red]
|
||||
command:
|
||||
--config xdai
|
||||
--baseDbPath /nethermind
|
||||
--JsonRpc.Enabled true
|
||||
--JsonRpc.Host 0.0.0.0
|
||||
--Init.StoreReceipts false
|
||||
--TxPool.Size 8192
|
||||
--Pruning.Mode Hybrid
|
||||
--Pruning.CacheMb 1024
|
||||
--Sync.FastSync true
|
||||
--Sync.FastBlocks true
|
||||
--Sync.DownloadBodiesInFastSync false
|
||||
--Sync.DownloadReceiptsInFastSync false
|
||||
--Sync.DownloadHeadersInFastSync false
|
||||
volumes:
|
||||
- ~/ne-data/logs:/nethermind/logs
|
||||
- ~/ne-data/nethermind_db:/nethermind/nethermind_db
|
||||
expose:
|
||||
- "8545"
|
||||
ports:
|
||||
- "30304:30303/tcp"
|
||||
- "30304:30303/udp"
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "100m"
|
||||
max-file: "1"
|
||||
bridge_amb_affirmation:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn watcher:affirmation-request
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ARBITRARY_MESSAGE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${AMB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${AMB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${AMB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${AMB_REDIS_URL}',
|
||||
'ORACLE_FOREIGN_START_BLOCK=${AMB_FOREIGN_START_BLOCK}',
|
||||
'ORACLE_VALIDATOR_ADDRESS=${AMB_ORACLE_VALIDATOR_ADDRESS}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_amb_green,
|
||||
net_rabbit_bridge_amb_green,
|
||||
net_ne_bridge_amb_green]
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis-amb
|
||||
- rabbit-amb
|
||||
bridge_amb_information:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn watcher:information-request
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ARBITRARY_MESSAGE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${AMB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${AMB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${AMB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${AMB_REDIS_URL}',
|
||||
'ORACLE_HOME_START_BLOCK=${AMB_HOME_START_BLOCK}',
|
||||
'ORACLE_VALIDATOR_ADDRESS=${AMB_ORACLE_VALIDATOR_ADDRESS}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_amb_green,
|
||||
net_rabbit_bridge_amb_green,
|
||||
net_ne_bridge_amb_green]
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis-amb
|
||||
- rabbit-amb
|
||||
bridge_amb_request:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn watcher:signature-request
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ARBITRARY_MESSAGE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${AMB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${AMB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${AMB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${AMB_REDIS_URL}',
|
||||
'ORACLE_HOME_START_BLOCK=${AMB_HOME_START_BLOCK}',
|
||||
'ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=${AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_amb_red,
|
||||
net_rabbit_bridge_amb_red,
|
||||
net_ne_bridge_amb_red]
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis-amb
|
||||
- rabbit-amb
|
||||
bridge_amb_shutdown:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn manager:shutdown
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ARBITRARY_MESSAGE,
|
||||
'ORACLE_REDIS_URL=${AMB_REDIS_URL}',
|
||||
'ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL=${AMB_SHUTDOWN_SERVICE_POLLING_INTERVAL}',
|
||||
'ORACLE_SIDE_RPC_URL=${AMB_SIDE_RPC_URL}',
|
||||
'ORACLE_SHUTDOWN_CONTRACT_ADDRESS=${AMB_SHUTDOWN_CONTRACT_ADDRESS}',
|
||||
'ORACLE_SHUTDOWN_CONTRACT_METHOD=${AMB_SHUTDOWN_CONTRACT_METHOD}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_amb_green]
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis-amb
|
||||
bridge_amb_senderhome:
|
||||
cpus: 0.1
|
||||
entrypoint: yarn sender:home
|
||||
env_file: ./.env
|
||||
environment: [NODE_ENV=production,
|
||||
ORACLE_BRIDGE_MODE=ARBITRARY_MESSAGE,
|
||||
'COMMON_HOME_BRIDGE_ADDRESS=${AMB_HOME_BRIDGE_ADDRESS}',
|
||||
'COMMON_FOREIGN_BRIDGE_ADDRESS=${AMB_FOREIGN_BRIDGE_ADDRESS}',
|
||||
'ORACLE_QUEUE_URL=${AMB_QUEUE_URL}',
|
||||
'ORACLE_REDIS_URL=${AMB_REDIS_URL}',
|
||||
'ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=${AMB_ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY}']
|
||||
image: poanetwork/tokenbridge-oracle:latest
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_amb_red,
|
||||
net_rabbit_bridge_amb_red,
|
||||
net_ne_bridge_amb_red]
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- redis-amb
|
||||
- rabbit-amb
|
||||
rabbit-amb:
|
||||
cpus: 0.3
|
||||
environment: [RABBITMQ_NODENAME=node@rabbit-amb]
|
||||
hostname: rabbit-amb
|
||||
image: rabbitmq:3
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_rabbit_bridge_amb_red,
|
||||
net_rabbit_bridge_amb_green]
|
||||
restart: unless-stopped
|
||||
volumes: ['~/amb_bridge_data/rabbitmq:/var/lib/rabbitmq/mnesia']
|
||||
redis-amb:
|
||||
command: [redis-server, --appendonly, 'yes']
|
||||
cpus: 0.1
|
||||
hostname: redis-amb
|
||||
image: redis:4
|
||||
logging:
|
||||
driver: syslog
|
||||
options: {tag: '{{.Name}}/{{.ID}}'}
|
||||
mem_limit: 500m
|
||||
networks: [net_db_bridge_amb_red,
|
||||
net_db_bridge_amb_green]
|
||||
restart: unless-stopped
|
||||
volumes: ['~/amb_bridge_data/redis:/data']
|
Loading…
Reference in New Issue
Block a user