Skip to content

Commit aa72238

Browse files
authored
Merge pull request #115 from poanetwork/develop
Merging the develop branch containing the ERC-TO-NATIVE mode to the master branch
2 parents 8583bf2 + e3b3725 commit aa72238

Some content is hidden

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

50 files changed

+2107
-255
lines changed

.env.example

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ VALIDATOR_ADDRESS_PRIVATE_KEY=
1313

1414
HOME_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
1515
HOME_GAS_PRICE_SPEED_TYPE=standard
16-
HOME_GAS_PRICE_FALLBACK=1
16+
HOME_GAS_PRICE_FALLBACK=1000000000
1717
HOME_GAS_PRICE_UPDATE_INTERVAL=600000
1818

1919
FOREIGN_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
2020
FOREIGN_GAS_PRICE_SPEED_TYPE=standard
21-
FOREIGN_GAS_PRICE_FALLBACK=1
21+
FOREIGN_GAS_PRICE_FALLBACK=1000000000
2222
FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000
2323

2424
QUEUE_URL=amqp://127.0.0.1
@@ -28,9 +28,13 @@ REDIS_LOCK_TTL=1000
2828
HOME_START_BLOCK=
2929
FOREIGN_START_BLOCK=
3030

31+
LOG_LEVEL=debug
32+
MAX_PROCESSING_TIME=20000
33+
3134
#testing accs
3235
USER_ADDRESS=0x59c4474184579b9c31b5e51445b6eef91cebf370
3336
USER_ADDRESS_PRIVATE_KEY=
3437
HOME_MIN_AMOUNT_PER_TX=0.001
3538
FOREIGN_MIN_AMOUNT_PER_TX=0.001
36-
BRIDGEABLE_TOKEN_ADDRESS=
39+
HOME_TEST_TX_GAS_PRICE=1000000000
40+
FOREIGN_TEST_TX_GAS_PRICE=1000000000

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"func-names": "off",
1111
"no-await-in-loop": "off",
1212
"no-console": "off",
13+
"no-else-return": "off",
1314
"no-param-reassign": "off",
1415
"no-plusplus": "off",
1516
"no-restricted-syntax": "off",

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ where the _watcher_ could be one of:
189189

190190
| Variable | Description | Values |
191191
|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|
192-
| `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` |
192+
| `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` |
193193
| `HOME_RPC_URL` | The HTTPS URL(s) used to communicate to the RPC nodes in the Home network. 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) |
194194
| `HOME_BRIDGE_ADDRESS` | The address of the bridge contract address in the Home network. It is used to listen to events from and send validators' transactions to the Home network. | hexidecimal beginning with "0x" |
195195
| `HOME_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 |
@@ -199,11 +199,11 @@ where the _watcher_ could be one of:
199199
| `FOREIGN_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 |
200200
| `HOME_GAS_PRICE_ORACLE_URL` | The URL used to get a JSON response from the gas price prediction oracle for the Home network. The gas price provided by the oracle is used to send the validator's transactions to the RPC node. Since it is assumed that the Home network has a predefined gas price (e.g. the gas price in the Core of POA.Network is `1 GWei`), the gas price oracle parameter can be omitted for such networks. | URL |
201201
| `HOME_GAS_PRICE_SPEED_TYPE` | Assuming the gas price oracle responds with the following JSON structure: `{"fast": 20.0, "block_time": 12.834, "health": true, "standard": 6.0, "block_number": 6470469, "instant": 71.0, "slow": 1.889}`, this parameter specifies the desirable transaction speed. The speed type can be omitted when `HOME_GAS_PRICE_ORACLE_URL` is not used. | `instant` / `fast` / `standard` / `slow` |
202-
| `HOME_GAS_PRICE_FALLBACK` | The gas price (in GWei) that is used if both the oracle and the fall back gas price specified in the Home Bridge contract are not available. | integer |
202+
| `HOME_GAS_PRICE_FALLBACK` | The gas price (in Wei) that is used if both the oracle and the fall back gas price specified in the Home Bridge contract are not available. | integer |
203203
| `HOME_GAS_PRICE_UPDATE_INTERVAL` | An interval in milliseconds used to get the updated gas price value either from the oracle or from the Home Bridge contract. | integer |
204204
| `FOREIGN_GAS_PRICE_ORACLE_URL` | The URL used to get a JSON response from the gas price prediction oracle for the Foreign network. The provided gas price is used to send the validator's transactions to the RPC node. If the Foreign network is Ethereum Foundation mainnet, the oracle URL can be: https://gasprice.poa.network. Otherwise this parameter can be omitted. | URL |
205205
| `FOREIGN_GAS_PRICE_SPEED_TYPE` | Assuming the gas price oracle responds with the following JSON structure: `{"fast": 20.0, "block_time": 12.834, "health": true, "standard": 6.0, "block_number": 6470469, "instant": 71.0, "slow": 1.889}`, this parameter specifies the desirable transaction speed. The speed type can be omitted when `FOREIGN_GAS_PRICE_ORACLE_URL`is not used. | `instant` / `fast` / `standard` / `slow` |
206-
| `FOREIGN_GAS_PRICE_FALLBACK` | The gas price (in GWei) used if both the oracle and fall back gas price specified in the Foreign Bridge contract are not available. | integer |
206+
| `FOREIGN_GAS_PRICE_FALLBACK` | The gas price (in Wei) used if both the oracle and fall back gas price specified in the Foreign Bridge contract are not available. | integer |
207207
| `FOREIGN_GAS_PRICE_UPDATE_INTERVAL` | The interval in milliseconds used to get the updated gas price value either from the oracle or from the Foreign Bridge contract. | integer |
208208
| `VALIDATOR_ADDRESS_PRIVATE_KEY` | The private key of the bridge validator used to sign confirmations before sending transactions to the bridge contracts. The validator account is calculated automatically from the private key. Every bridge instance (set of watchers and senders) must have its own unique private key. The specified private key is used to sign transactions on both sides of the bridge. | hexidecimal without "0x" |
209209
| `HOME_START_BLOCK` | The block number in the Home network used to start watching for events when the bridge instance is run for the first time. Usually this is the same block where the Home Bridge contract is deployed. If a new validator instance is being deployed for an existing set of validators, the block number could be the latest block in the chain. | integer |
@@ -212,6 +212,8 @@ where the _watcher_ could be one of:
212212
| `REDIS_URL` | Redis DB URL used by watchers and senders to communicate to the database. Typically set to: `redis://127.0.0.1:6379`. | local URL |
213213
| `REDIS_LOCK_TTL` | Threshold in milliseconds for locking a resource in the Redis DB. Until the threshold is exceeded, the resource is unlocked. Usually it is `1000`. | integer |
214214
| `ALLOW_HTTP` | **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` |
215+
| `LOG_LEVEL` | Set the level of details in the logs. | `trace` / `debug` / `info` / `warn` / `error` / `fatal` |
216+
| `MAX_PROCESSING_TIME` | The workers processes will be killed if this amount of time (in milliseconds) is ellapsed before they finish processing. It is recommended to set this value to 4 times the value of the longest polling time (set with the `HOME_POLLING_INTERVAL` and `FOREIGN_POLLING_INTERVAL` variables). To disable this, set the time to 0. | integer |
215217

216218
### Useful Commands for Development
217219

@@ -250,15 +252,22 @@ See the [E2E README](/e2e) for instructions.
250252

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

253-
- To send deposits to a home contract run `node scripts/sendUserTxToHome.js <tx num>` (or `docker-compose run bridge node scripts/sendUserTxToHome.js <tx num>`), where `<tx num>` is how many tx will be sent out to deposit.
255+
- 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.
254256

255-
- To send withdrawals to a foreign contract run `node scripts/sendUserTxToForeign.js <tx num>` (or `docker-compose run bridge node scripts/sendUserTxToForeign.js <tx num>`), where `<tx num>` is how many tx will be sent out to withdraw.
257+
- 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.
256258

257259
### ERC20-to-ERC20 Mode Testing
258260

259-
- To deposit from a Foreign to a Home contract run `node scripts/sendUserTxToErcForeign.js <tx num>`.
261+
- To deposit from a Foreign to a Home contract run `node scripts/erc20_to_erc20/sendForeign.js <tx num>`.
262+
263+
- To make withdrawal to Home from a Foreign contract run `node scripts/erc20_to_erc20/sendHome.js <tx num>`.
264+
265+
### ERC20-to-Native Mode Testing
266+
267+
- To deposit from a Foreign to a Home contract run `node scripts/erc20_to_native/sendForeign.js <tx num>`.
268+
269+
- To make withdrawal to Home from a Foreign contract run `node scripts/erc20_to_native/sendHome.js <tx num>`.
260270

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

263272
### Configuration parameters for testing
264273

@@ -270,11 +279,10 @@ When running the processes, the following commands can be used to test functiona
270279
| `USER_ADDRESS_PRIVATE_KEY` | A private key belonging to the account. |
271280
| `HOME_BRIDGE_ADDRESS` | Address of the bridge in the Home network to send transactions. |
272281
| `HOME_MIN_AMOUNT_PER_TX` | Value (in _eth_ or tokens) to be sent in one transaction for the Home network. This should be greater than or equal to the value specified in the `poa-bridge-contracts/deploy/.env` file. The default value in that file is 500000000000000000, which is equivalent to 0.5. |
282+
| `HOME_TEST_TX_GAS_PRICE` | The gas price (in Wei) that is used to send transactions in the Home network . |
273283
| `FOREIGN_BRIDGE_ADDRESS` | Address of the bridge in the Foreign network to send transactions. |
274284
| `FOREIGN_MIN_AMOUNT_PER_TX` | Value (in _eth_ or tokens) to be sent in one transaction for the Foreign network. This should be greater than or equal to the value specified in the `poa-bridge-contracts/deploy/.env` file. The default value in that file is 500000000000000000, which is equivalent to 0.5. |
275-
| `ERC20_TOKEN_ADDRESS` | An address of the token deployed on the Foreign side for `ERC20-to-ERC20` mode. Omit this parameter with other bridge modes. |
276-
| `BRIDGEABLE_TOKEN_ADDRESS` | An address of the token deployed on the Foreign side for `Native-to-ERC20` mode or on the Home side for `ERC20-to-ERC20` (specified as erc677 in the `poa-bridge-contracts/deploy/bridgeDeploymentResults.json` file). |
277-
285+
| `FOREIGN_TEST_TX_GAS_PRICE` | The gas price (in Wei) that is used to send transactions in the Foreign network . |
278286

279287
## Contributing
280288

0 commit comments

Comments
 (0)