Skip to content

Commit 3b95977

Browse files
authored
Merge the develop branch to the master branch, preparation to v3.0.0-rc0
This merge contains the following set of changes: * [Oracle, Improvement] Oracle watcher for AMB async calls (#509), * [Common, Other] Update the contract's submodule to the release 6.0.0-rc0 (#562)
2 parents 9da1d7a + ffbca8b commit 3b95977

File tree

140 files changed

+9193
-3998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+9193
-3998
lines changed

.github/workflows/main.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/setup-node@v1
1717
with:
18-
node-version: 10
18+
node-version: 12
1919
- uses: actions/checkout@v2
2020
with:
2121
submodules: true
@@ -48,7 +48,7 @@ jobs:
4848
steps:
4949
- uses: actions/setup-node@v1
5050
with:
51-
node-version: 10
51+
node-version: 12
5252
- uses: actions/checkout@v2
5353
with:
5454
submodules: true
@@ -70,7 +70,7 @@ jobs:
7070
- name: Evaluate e2e docker images tags
7171
run: |
7272
git submodule status > submodule.status
73-
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}" >> $GITHUB_ENV
73+
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e', 'e2e-commons') }}" >> $GITHUB_ENV
7474
echo "ORACLE_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}" >> $GITHUB_ENV
7575
echo "MONITOR_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}" >> $GITHUB_ENV
7676
echo "ALM_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}" >> $GITHUB_ENV
@@ -81,8 +81,8 @@ jobs:
8181
}
8282
updated=()
8383
if ! check_if_image_exists e2e ${E2E_TAG}; then updated+=("e2e"); fi
84-
if ! check_if_image_exists oracle ${ORACLE_TAG}; then updated+=("oracle"); fi
85-
if ! check_if_image_exists monitor ${MONITOR_TAG}; then updated+=("monitor"); fi
84+
if ! check_if_image_exists oracle ${ORACLE_TAG}; then updated+=("oracle-amb"); fi
85+
if ! check_if_image_exists monitor ${MONITOR_TAG}; then updated+=("monitor-amb"); fi
8686
if ! check_if_image_exists alm ${ALM_TAG}; then updated+=("alm"); fi
8787
if [ ${#updated[@]} -gt 0 ]; then
8888
echo "Updated services: ${updated[@]}"
@@ -133,7 +133,7 @@ jobs:
133133
- name: Evaluate e2e docker images tags
134134
run: |
135135
git submodule status > submodule.status
136-
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}" >> $GITHUB_ENV
136+
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e', 'e2e-commons') }}" >> $GITHUB_ENV
137137
echo "ORACLE_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}" >> $GITHUB_ENV
138138
echo "MONITOR_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}" >> $GITHUB_ENV
139139
echo "ALM_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}" >> $GITHUB_ENV
@@ -176,15 +176,15 @@ jobs:
176176
strategy:
177177
fail-fast: false
178178
matrix:
179-
task: [amb, erc-to-erc, erc-to-native, native-to-erc]
179+
task: [amb, erc-to-native]
180180
steps:
181181
- uses: actions/checkout@v2
182182
with:
183183
submodules: true
184184
- name: Evaluate e2e docker images tags
185185
run: |
186186
git submodule status > submodule.status
187-
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}" >> $GITHUB_ENV
187+
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e', 'e2e-commons') }}" >> $GITHUB_ENV
188188
echo "ORACLE_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}" >> $GITHUB_ENV
189189
echo "MONITOR_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}" >> $GITHUB_ENV
190190
echo "ALM_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}" >> $GITHUB_ENV
@@ -202,7 +202,7 @@ jobs:
202202
run: ${{ steps.cache-repo.outputs.cache-hit }} && e2e-commons/up.sh deploy blocks
203203
- name: Pull e2e oracle image
204204
run: |
205-
docker-compose -f ./e2e-commons/docker-compose.yml pull oracle
205+
docker-compose -f ./e2e-commons/docker-compose.yml pull oracle-amb
206206
docker tag ${DOCKER_IMAGE_BASE}/tokenbridge-e2e-oracle:${ORACLE_TAG} poanetwork/tokenbridge-oracle:latest
207207
- name: Deploy oracle
208208
run: deployment-e2e/molecule.sh ultimate-${{ matrix.task }}

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.22
1+
12.22

CONFIGURATION.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ COMMON_FOREIGN_GAS_PRICE_FACTOR | A value that will multiply the gas price of th
2222

2323
name | description | value
2424
--- | --- | ---
25-
ORACLE_BRIDGE_MODE | The bridge mode. The bridge starts listening to a different set of events based on this parameter. | NATIVE_TO_ERC / ERC_TO_ERC / ERC_TO_NATIVE / ARBITRARY_MESSAGE
25+
ORACLE_BRIDGE_MODE | The bridge mode. The bridge starts listening to a different set of events based on this parameter. | ERC_TO_NATIVE / ARBITRARY_MESSAGE
2626
ORACLE_ALLOW_HTTP_FOR_RPC | **Only use in test environments - must be omitted in production environments.**. If this parameter is specified and set to `yes`, RPC URLs can be specified in form of HTTP links. A warning that the connection is insecure will be written to the logs. | `yes` / `no`
2727
ORACLE_HOME_RPC_POLLING_INTERVAL | The interval in milliseconds used to request the RPC node in the Home network for new blocks. The interval should match the average production time for a new block. | integer
2828
ORACLE_FOREIGN_RPC_POLLING_INTERVAL | The interval in milliseconds used to request the RPC node in the Foreign network for new blocks. The interval should match the average production time for a new block. | integer
@@ -47,6 +47,7 @@ ORACLE_FOREIGN_TX_RESEND_INTERVAL | Interval in milliseconds for automatic resen
4747
ORACLE_SHUTDOWN_SERVICE_URL | Optional external URL to some other service/monitor/configuration manager that controls the remote shutdown process. GET request should return `application/json` message with the following schema: `{ shutdown: true/false }`. | URL
4848
ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL | Optional interval in milliseconds used to request the side RPC node or external shutdown service. Default is 120000. | integer
4949
ORACLE_SIDE_RPC_URL | Optional HTTPS URL(s) for communication with the external shutdown service or side RPC nodes, used for shutdown manager activities. Several URLs can be specified, delimited by spaces. If the connection to one of these nodes is lost the next URL is used for connection. | URL(s)
50+
ORACLE_FOREIGN_ARCHIVE_RPC_URL | Optional HTTPS URL(s) for communication with the archive nodes on the foreign network. Only used in AMB bridge mode for async information request processing. Several URLs can be specified, delimited by spaces. If the connection to one of these nodes is lost the next URL is used for connection. | URL(s)
5051
ORACLE_SHUTDOWN_CONTRACT_ADDRESS | Optional contract address in the side chain accessible through `ORACLE_SIDE_RPC_URL`, where the method passed in `ORACLE_SHUTDOWN_CONTRACT_METHOD` is implemented. | `address`
5152
ORACLE_SHUTDOWN_CONTRACT_METHOD | Method signature to be used in the side chain to identify the current shutdown status. Method should return boolean. Default value is `isShutdown()`. | `function signature`
5253
ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT | Max length for the block range used in `eth_getLogs` requests for polling contract events for the Foreign chain. Infinite, if not provided. | `integer`

Dockerfile.e2e

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:10 as contracts
1+
FROM node:12 as contracts
22

33
WORKDIR /mono
44

@@ -11,7 +11,7 @@ COPY ./contracts/truffle-config.js ./
1111
COPY ./contracts/contracts ./contracts
1212
RUN npm run compile
1313

14-
FROM node:10
14+
FROM node:12
1515

1616
WORKDIR /mono
1717
COPY package.json .

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Additionally there are [Smart Contracts](https://github.com/poanetwork/tokenbrid
5454

5555
The POA TokenBridge provides four operational modes:
5656

57-
- [x] `Native-to-ERC20` **Coins** on a Home network can be converted to ERC20-compatible **tokens** on a Foreign network. Coins are locked on the Home side and the corresponding amount of ERC20 tokens are minted on the Foreign side. When the operation is reversed, tokens are burnt on the Foreign side and unlocked in the Home network. **More Information: [POA-to-POA20 Bridge](https://medium.com/poa-network/introducing-poa-bridge-and-poa20-55d8b78058ac)**
58-
- [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)**
5957
- [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)**
6058
- [x] `Arbitrary-Message`: Transfer arbitrary data between two networks as so the data could be interpreted as an arbitrary contract method invocation.
6159

alm-e2e/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"eslint-plugin-jest": "^23.18.0"
2020
},
2121
"engines": {
22-
"node": ">= 10.18"
22+
"node": ">= 12.22"
2323
}
2424
}

alm-e2e/src/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jest.setTimeout(60000)
66
const statusText = 'Success'
77
const statusSelector = 'label[data-id="status"]'
88

9-
const homeToForeignTxURL = 'http://localhost:3004/77/0x58e7d63368335b9591d4dbb43889084f698fcee93ab7656fd7a39d8c66bc4b60'
10-
const foreignToHomeTxURL = 'http://localhost:3004/42/0x592bf28fc896419d2838f71cd0388775814b692688f1ecd5b1519081566b994a'
9+
const homeToForeignTxURL = 'http://localhost:3004/77/0xbc83d43bdc675a615a2b820e43e52d25857aa5fdd77acf2dd92cd247af2c693c'
10+
const foreignToHomeTxURL = 'http://localhost:3004/42/0x09dfb947dbd17e27bcc117773b6e133829f7cef9646199a93ef019c4f7c0fec6'
1111

1212
describe('ALM', () => {
1313
let browser

alm/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:10 as contracts
1+
FROM node:12 as contracts
22

33
WORKDIR /mono
44

commons/abis.js

+3-66
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,17 @@
1-
const HOME_NATIVE_TO_ERC_ABI = require('../contracts/build/contracts/HomeBridgeNativeToErc').abi
2-
const FOREIGN_NATIVE_TO_ERC_ABI = require('../contracts/build/contracts/ForeignBridgeNativeToErc').abi
3-
const HOME_ERC_TO_ERC_ABI = require('../contracts/build/contracts/HomeBridgeErcToErc').abi
4-
const FOREIGN_ERC_TO_ERC_ABI = require('../contracts/build/contracts/ForeignBridgeErc677ToErc677').abi
51
const HOME_ERC_TO_NATIVE_ABI = require('../contracts/build/contracts/HomeBridgeErcToNative').abi
62
const FOREIGN_ERC_TO_NATIVE_ABI = require('../contracts/build/contracts/ForeignBridgeErcToNative').abi
73
const ERC20_ABI = require('../contracts/build/contracts/ERC20').abi
8-
const ERC677_ABI = require('../contracts/build/contracts/ERC677').abi
9-
const ERC677_BRIDGE_TOKEN_ABI = require('../contracts/build/contracts/ERC677BridgeToken').abi
10-
const BLOCK_REWARD_ABI = require('../contracts/build/contracts/BlockReward').abi
4+
const BLOCK_REWARD_ABI = require('../contracts/build/contracts/BlockRewardMock').abi
115
const BRIDGE_VALIDATORS_ABI = require('../contracts/build/contracts/BridgeValidators').abi
126
const REWARDABLE_VALIDATORS_ABI = require('../contracts/build/contracts/RewardableValidators').abi
137
const HOME_AMB_ABI = require('../contracts/build/contracts/HomeAMB').abi
148
const FOREIGN_AMB_ABI = require('../contracts/build/contracts/ForeignAMB').abi
159
const BOX_ABI = require('../contracts/build/contracts/Box').abi
1610
const HOME_AMB_ERC_TO_ERC_ABI = require('../contracts/build/contracts/HomeAMBErc677ToErc677').abi
1711
const FOREIGN_AMB_ERC_TO_ERC_ABI = require('../contracts/build/contracts/ForeignAMBErc677ToErc677').abi
18-
const HOME_STAKE_ERC_TO_ERC_ABI = require('../contracts/build/contracts/HomeStakeTokenMediator').abi
19-
const FOREIGN_STAKE_ERC_TO_ERC_ABI = require('../contracts/build/contracts/ForeignStakeTokenMediator').abi
2012

21-
const { HOME_V1_ABI, FOREIGN_V1_ABI } = require('./v1Abis')
2213
const { BRIDGE_MODES } = require('./constants')
2314

24-
const ERC20_BYTES32_ABI = [
25-
{
26-
constant: true,
27-
inputs: [],
28-
name: 'name',
29-
outputs: [
30-
{
31-
name: '',
32-
type: 'bytes32'
33-
}
34-
],
35-
payable: false,
36-
stateMutability: 'view',
37-
type: 'function'
38-
},
39-
{
40-
constant: true,
41-
inputs: [],
42-
name: 'symbol',
43-
outputs: [
44-
{
45-
name: '',
46-
type: 'bytes32'
47-
}
48-
],
49-
payable: false,
50-
stateMutability: 'view',
51-
type: 'function'
52-
}
53-
]
54-
5515
const OLD_AMB_USER_REQUEST_FOR_SIGNATURE_ABI = [
5616
{
5717
anonymous: false,
@@ -85,27 +45,15 @@ const OLD_AMB_USER_REQUEST_FOR_AFFIRMATION_ABI = [
8545
function getBridgeABIs(bridgeMode) {
8646
let HOME_ABI = null
8747
let FOREIGN_ABI = null
88-
if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC) {
89-
HOME_ABI = HOME_NATIVE_TO_ERC_ABI
90-
FOREIGN_ABI = FOREIGN_NATIVE_TO_ERC_ABI
91-
} else if (bridgeMode === BRIDGE_MODES.ERC_TO_ERC) {
92-
HOME_ABI = HOME_ERC_TO_ERC_ABI
93-
FOREIGN_ABI = FOREIGN_ERC_TO_ERC_ABI
94-
} else if (bridgeMode === BRIDGE_MODES.ERC_TO_NATIVE) {
48+
if (bridgeMode === BRIDGE_MODES.ERC_TO_NATIVE) {
9549
HOME_ABI = HOME_ERC_TO_NATIVE_ABI
9650
FOREIGN_ABI = FOREIGN_ERC_TO_NATIVE_ABI
97-
} else if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) {
98-
HOME_ABI = HOME_V1_ABI
99-
FOREIGN_ABI = FOREIGN_V1_ABI
10051
} else if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) {
10152
HOME_ABI = HOME_AMB_ABI
10253
FOREIGN_ABI = FOREIGN_AMB_ABI
10354
} else if (bridgeMode === BRIDGE_MODES.AMB_ERC_TO_ERC) {
10455
HOME_ABI = HOME_AMB_ERC_TO_ERC_ABI
10556
FOREIGN_ABI = FOREIGN_AMB_ERC_TO_ERC_ABI
106-
} else if (bridgeMode === BRIDGE_MODES.STAKE_AMB_ERC_TO_ERC) {
107-
HOME_ABI = HOME_STAKE_ERC_TO_ERC_ABI
108-
FOREIGN_ABI = FOREIGN_STAKE_ERC_TO_ERC_ABI
10957
} else {
11058
throw new Error(`Unrecognized bridge mode: ${bridgeMode}`)
11159
}
@@ -115,26 +63,15 @@ function getBridgeABIs(bridgeMode) {
11563

11664
module.exports = {
11765
getBridgeABIs,
118-
HOME_NATIVE_TO_ERC_ABI,
119-
FOREIGN_NATIVE_TO_ERC_ABI,
120-
HOME_ERC_TO_ERC_ABI,
121-
FOREIGN_ERC_TO_ERC_ABI,
12266
HOME_ERC_TO_NATIVE_ABI,
12367
FOREIGN_ERC_TO_NATIVE_ABI,
12468
ERC20_ABI,
125-
ERC677_ABI,
126-
ERC677_BRIDGE_TOKEN_ABI,
12769
BLOCK_REWARD_ABI,
12870
BRIDGE_VALIDATORS_ABI,
12971
REWARDABLE_VALIDATORS_ABI,
130-
HOME_V1_ABI,
131-
FOREIGN_V1_ABI,
132-
ERC20_BYTES32_ABI,
13372
HOME_AMB_ABI,
13473
FOREIGN_AMB_ABI,
13574
OLD_AMB_USER_REQUEST_FOR_AFFIRMATION_ABI,
13675
OLD_AMB_USER_REQUEST_FOR_SIGNATURE_ABI,
137-
BOX_ABI,
138-
HOME_STAKE_ERC_TO_ERC_ABI,
139-
FOREIGN_STAKE_ERC_TO_ERC_ABI
76+
BOX_ABI
14077
}

commons/constants.js

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
11
const BRIDGE_MODES = {
2-
NATIVE_TO_ERC: 'NATIVE_TO_ERC',
3-
ERC_TO_ERC: 'ERC_TO_ERC',
42
ERC_TO_NATIVE: 'ERC_TO_NATIVE',
5-
NATIVE_TO_ERC_V1: 'NATIVE_TO_ERC_V1',
63
ARBITRARY_MESSAGE: 'ARBITRARY_MESSAGE',
7-
AMB_ERC_TO_ERC: 'AMB_ERC_TO_ERC',
8-
STAKE_AMB_ERC_TO_ERC: 'STAKE_AMB_ERC_TO_ERC'
9-
}
10-
11-
const ERC_TYPES = {
12-
ERC20: 'ERC20',
13-
ERC677: 'ERC677'
14-
}
15-
16-
const FEE_MANAGER_MODE = {
17-
ONE_DIRECTION: 'ONE_DIRECTION',
18-
BOTH_DIRECTIONS: 'BOTH_DIRECTIONS',
19-
ONE_DIRECTION_STAKE: 'ONE_DIRECTION_STAKE',
20-
UNDEFINED: 'UNDEFINED'
4+
AMB_ERC_TO_ERC: 'AMB_ERC_TO_ERC'
215
}
226

237
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
248

259
module.exports = {
2610
BRIDGE_MODES,
27-
ERC_TYPES,
28-
FEE_MANAGER_MODE,
2911
ZERO_ADDRESS
3012
}

commons/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"dependencies": {
1111
"gas-price-oracle": "^0.1.5",
12-
"web3-utils": "1.0.0-beta.34"
12+
"web3-utils": "^1.3.0"
1313
},
1414
"devDependencies": {
1515
"bn-chai": "^1.0.1",

commons/test/constants.test.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
const { expect } = require('chai')
2-
const { BRIDGE_MODES, ERC_TYPES } = require('../constants')
2+
const { BRIDGE_MODES } = require('../constants')
33

44
describe('constants', () => {
55
it('should contain correct number of bridge types', () => {
6-
expect(Object.keys(BRIDGE_MODES).length).to.be.equal(7)
7-
})
8-
9-
it('should contain correct number of erc types', () => {
10-
expect(Object.keys(ERC_TYPES).length).to.be.equal(2)
6+
expect(Object.keys(BRIDGE_MODES).length).to.be.equal(3)
117
})
128
})

0 commit comments

Comments
 (0)