From d24027472f7059e2aa58ee74ef5bf82555d3f874 Mon Sep 17 00:00:00 2001 From: francoisbranciard Date: Wed, 10 Apr 2019 13:56:41 +0200 Subject: [PATCH 1/5] target 2.2.0 bridges contracts instead of 2.1.0 in e2e tests --- e2e/Dockerfile | 2 +- e2e/envs/contracts-deploy.env | 15 +++++++-------- e2e/envs/erc-contracts-deploy.env | 15 +++++++-------- e2e/envs/erc-native-contracts-deploy.env | 14 +++++++------- e2e/scripts/deployERC20.js | 6 ++++-- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/e2e/Dockerfile b/e2e/Dockerfile index ad1a5b0..ef58cdb 100644 --- a/e2e/Dockerfile +++ b/e2e/Dockerfile @@ -12,7 +12,7 @@ RUN mkdir submodules && \ mv poa-bridge-contracts submodules && \ cd submodules/poa-bridge-contracts && \ git fetch && \ - git checkout 2.1.0 + git checkout 2.2.0 RUN npm install --unsafe-perm diff --git a/e2e/envs/contracts-deploy.env b/e2e/envs/contracts-deploy.env index 0a07499..9cada7d 100644 --- a/e2e/envs/contracts-deploy.env +++ b/e2e/envs/contracts-deploy.env @@ -1,7 +1,6 @@ BRIDGE_MODE=NATIVE_TO_ERC -DEPLOYMENT_ACCOUNT_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b DEPLOYMENT_ACCOUNT_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9 -DEPLOYMENT_GAS_LIMIT=4000000 +DEPLOYMENT_GAS_LIMIT=4600000 HOME_DEPLOYMENT_GAS_PRICE=10000000000 FOREIGN_DEPLOYMENT_GAS_PRICE=10000000000 GET_RECEIPT_INTERVAL_IN_MILLISECONDS=50 @@ -11,9 +10,9 @@ BRIDGEABLE_TOKEN_SYMBOL="TEST" BRIDGEABLE_TOKEN_DECIMALS="18" HOME_RPC_URL=http://parity1:8545 -HOME_OWNER_MULTISIG=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -HOME_UPGRADEABLE_ADMIN_VALIDATORS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -HOME_UPGRADEABLE_ADMIN_BRIDGE=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b HOME_DAILY_LIMIT=30000000000000000000000000 HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000 HOME_MIN_AMOUNT_PER_TX=10000000000000000 @@ -21,9 +20,9 @@ HOME_REQUIRED_BLOCK_CONFIRMATIONS=1 HOME_GAS_PRICE=1000000000 FOREIGN_RPC_URL=http://parity2:8545 -FOREIGN_OWNER_MULTISIG=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -FOREIGN_UPGRADEABLE_ADMIN_VALIDATORS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -FOREIGN_UPGRADEABLE_ADMIN_BRIDGE=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b FOREIGN_DAILY_LIMIT=15000000000000000000000000 FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000 FOREIGN_MIN_AMOUNT_PER_TX=10000000000000000 diff --git a/e2e/envs/erc-contracts-deploy.env b/e2e/envs/erc-contracts-deploy.env index 869261e..dc7a7c5 100644 --- a/e2e/envs/erc-contracts-deploy.env +++ b/e2e/envs/erc-contracts-deploy.env @@ -1,7 +1,6 @@ BRIDGE_MODE=ERC_TO_ERC -DEPLOYMENT_ACCOUNT_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b DEPLOYMENT_ACCOUNT_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9 -DEPLOYMENT_GAS_LIMIT=4000000 +DEPLOYMENT_GAS_LIMIT=4600000 HOME_DEPLOYMENT_GAS_PRICE=10000000000 FOREIGN_DEPLOYMENT_GAS_PRICE=10000000000 GET_RECEIPT_INTERVAL_IN_MILLISECONDS=50 @@ -11,9 +10,9 @@ BRIDGEABLE_TOKEN_SYMBOL="TEST" BRIDGEABLE_TOKEN_DECIMALS="18" HOME_RPC_URL=http://parity1:8545 -HOME_OWNER_MULTISIG=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -HOME_UPGRADEABLE_ADMIN_VALIDATORS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -HOME_UPGRADEABLE_ADMIN_BRIDGE=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b HOME_DAILY_LIMIT=30000000000000000000000000 HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000 HOME_MIN_AMOUNT_PER_TX=10000000000000000 @@ -21,9 +20,9 @@ HOME_REQUIRED_BLOCK_CONFIRMATIONS=1 HOME_GAS_PRICE=1000000000 FOREIGN_RPC_URL=http://parity2:8545 -FOREIGN_OWNER_MULTISIG=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -FOREIGN_UPGRADEABLE_ADMIN_VALIDATORS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -FOREIGN_UPGRADEABLE_ADMIN_BRIDGE=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b FOREIGN_DAILY_LIMIT=15000000000000000000000000 FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000 FOREIGN_MIN_AMOUNT_PER_TX=10000000000000000 diff --git a/e2e/envs/erc-native-contracts-deploy.env b/e2e/envs/erc-native-contracts-deploy.env index fd86652..fc1f602 100644 --- a/e2e/envs/erc-native-contracts-deploy.env +++ b/e2e/envs/erc-native-contracts-deploy.env @@ -1,6 +1,6 @@ BRIDGE_MODE=ERC_TO_NATIVE DEPLOYMENT_ACCOUNT_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9 -DEPLOYMENT_GAS_LIMIT=4000000 +DEPLOYMENT_GAS_LIMIT=4600000 HOME_DEPLOYMENT_GAS_PRICE=10000000000 FOREIGN_DEPLOYMENT_GAS_PRICE=10000000000 GET_RECEIPT_INTERVAL_IN_MILLISECONDS=50 @@ -10,9 +10,9 @@ BRIDGEABLE_TOKEN_SYMBOL="TEST" BRIDGEABLE_TOKEN_DECIMALS="18" HOME_RPC_URL=http://parity1:8545 -HOME_OWNER_MULTISIG=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -HOME_UPGRADEABLE_ADMIN_VALIDATORS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -HOME_UPGRADEABLE_ADMIN_BRIDGE=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +HOME_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b HOME_DAILY_LIMIT=30000000000000000000000000 HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000 HOME_MIN_AMOUNT_PER_TX=10000000000000000 @@ -20,9 +20,9 @@ HOME_REQUIRED_BLOCK_CONFIRMATIONS=1 HOME_GAS_PRICE=1000000000 FOREIGN_RPC_URL=http://parity2:8545 -FOREIGN_OWNER_MULTISIG=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -FOREIGN_UPGRADEABLE_ADMIN_VALIDATORS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b -FOREIGN_UPGRADEABLE_ADMIN_BRIDGE=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b +FOREIGN_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b FOREIGN_DAILY_LIMIT=15000000000000000000000000 FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000 FOREIGN_MIN_AMOUNT_PER_TX=10000000000000000 diff --git a/e2e/scripts/deployERC20.js b/e2e/scripts/deployERC20.js index d6a67d8..05f2059 100644 --- a/e2e/scripts/deployERC20.js +++ b/e2e/scripts/deployERC20.js @@ -6,7 +6,8 @@ require('dotenv').config({ const { deployContract, - sendRawTx + sendRawTx, + privateKeyToAddress } = require('../submodules/poa-bridge-contracts/deploy/src/deploymentUtils') const { web3Foreign, @@ -15,7 +16,8 @@ const { const POA20 = require('../submodules/poa-bridge-contracts/build/contracts/ERC677BridgeToken.json') const { user } = require('../constants.json') -const { DEPLOYMENT_ACCOUNT_ADDRESS } = process.env +const { DEPLOYMENT_ACCOUNT_PRIVATE_KEY } = process.env +const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY) async function deployErc20() { try { From 225088a21054f80c5da6db12ef7cd7cf5e89814b Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Fri, 3 May 2019 11:07:14 -0300 Subject: [PATCH 2/5] Add support UserRequestForAffirmation on erc677-to-erc677 --- abis/ERC677BridgeToken.abi.json | 597 ++++++++++++++++ abis/ForeignBridgeErc677ToErc677.abi.json | 699 +++++++++++++++++++ config/affirmation-request-watcher.config.js | 16 +- config/base.config.js | 4 +- scripts/initialChecks.js | 33 + scripts/start-worker.sh | 6 +- src/utils/constants.js | 4 + src/watcher.js | 1 + 8 files changed, 1355 insertions(+), 5 deletions(-) create mode 100644 abis/ERC677BridgeToken.abi.json create mode 100644 abis/ForeignBridgeErc677ToErc677.abi.json create mode 100644 scripts/initialChecks.js diff --git a/abis/ERC677BridgeToken.abi.json b/abis/ERC677BridgeToken.abi.json new file mode 100644 index 0000000..8ba51f9 --- /dev/null +++ b/abis/ERC677BridgeToken.abi.json @@ -0,0 +1,597 @@ +[ + { + "constant": true, + "inputs": [], + "name": "mintingFinished", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_value", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseApproval", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "bridgeContract", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_addedValue", + "type": "uint256" + } + ], + "name": "increaseApproval", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "name": "_name", + "type": "string" + }, + { + "name": "_symbol", + "type": "string" + }, + { + "name": "_decimals", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "from", + "type": "address" + }, + { + "indexed": false, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "ContractFallbackCallFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "amount", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "MintFinished", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "previousOwner", + "type": "address" + } + ], + "name": "OwnershipRenounced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "burner", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "name": "data", + "type": "bytes" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { + "name": "_bridgeContract", + "type": "address" + } + ], + "name": "setBridgeContract", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + }, + { + "name": "_data", + "type": "bytes" + } + ], + "name": "transferAndCall", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getTokenInterfacesVersion", + "outputs": [ + { + "name": "major", + "type": "uint64" + }, + { + "name": "minor", + "type": "uint64" + }, + { + "name": "patch", + "type": "uint64" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "finishMinting", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_token", + "type": "address" + }, + { + "name": "_to", + "type": "address" + } + ], + "name": "claimTokens", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/abis/ForeignBridgeErc677ToErc677.abi.json b/abis/ForeignBridgeErc677ToErc677.abi.json new file mode 100644 index 0000000..43735ae --- /dev/null +++ b/abis/ForeignBridgeErc677ToErc677.abi.json @@ -0,0 +1,699 @@ +[ + { + "constant": true, + "inputs": [], + "name": "erc677token", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_txHash", + "type": "bytes32" + } + ], + "name": "relayedMessages", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "vs", + "type": "uint8[]" + }, + { + "name": "rs", + "type": "bytes32[]" + }, + { + "name": "ss", + "type": "bytes32[]" + }, + { + "name": "message", + "type": "bytes" + } + ], + "name": "executeSignatures", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_day", + "type": "uint256" + } + ], + "name": "totalSpentPerDay", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isInitialized", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_dailyLimit", + "type": "uint256" + } + ], + "name": "setExecutionDailyLimit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getCurrentDay", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "requiredBlockConfirmations", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBridgeMode", + "outputs": [ + { + "name": "_data", + "type": "bytes4" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "executionDailyLimit", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_day", + "type": "uint256" + } + ], + "name": "totalExecutedPerDay", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "dailyLimit", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_token", + "type": "address" + }, + { + "name": "_to", + "type": "address" + } + ], + "name": "claimTokens", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_amount", + "type": "uint256" + } + ], + "name": "withinExecutionLimit", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "executionMaxPerTx", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "requiredSignatures", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "validatorContract", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "deployedAtBlock", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBridgeInterfacesVersion", + "outputs": [ + { + "name": "major", + "type": "uint64" + }, + { + "name": "minor", + "type": "uint64" + }, + { + "name": "patch", + "type": "uint64" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_minPerTx", + "type": "uint256" + } + ], + "name": "setMinPerTx", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + }, + { + "name": "", + "type": "bytes" + } + ], + "name": "onTokenTransfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_blockConfirmations", + "type": "uint256" + } + ], + "name": "setRequiredBlockConfirmations", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_dailyLimit", + "type": "uint256" + } + ], + "name": "setDailyLimit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_gasPrice", + "type": "uint256" + } + ], + "name": "setGasPrice", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_maxPerTx", + "type": "uint256" + } + ], + "name": "setMaxPerTx", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "upgradeabilityAdmin", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "minPerTx", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_amount", + "type": "uint256" + } + ], + "name": "withinLimit", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_maxPerTx", + "type": "uint256" + } + ], + "name": "setExecutionMaxPerTx", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "maxPerTx", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "gasPrice", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "UserRequestForAffirmation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "name": "transactionHash", + "type": "bytes32" + } + ], + "name": "RelayedMessage", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "gasPrice", + "type": "uint256" + } + ], + "name": "GasPriceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "requiredBlockConfirmations", + "type": "uint256" + } + ], + "name": "RequiredBlockConfirmationChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "newLimit", + "type": "uint256" + } + ], + "name": "DailyLimitChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "newLimit", + "type": "uint256" + } + ], + "name": "ExecutionDailyLimitChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "previousOwner", + "type": "address" + }, + { + "indexed": false, + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { + "name": "_validatorContract", + "type": "address" + }, + { + "name": "_erc20token", + "type": "address" + }, + { + "name": "_requiredBlockConfirmations", + "type": "uint256" + }, + { + "name": "_gasPrice", + "type": "uint256" + }, + { + "name": "_dailyLimit", + "type": "uint256" + }, + { + "name": "_maxPerTx", + "type": "uint256" + }, + { + "name": "_minPerTx", + "type": "uint256" + }, + { + "name": "_homeDailyLimit", + "type": "uint256" + }, + { + "name": "_homeMaxPerTx", + "type": "uint256" + }, + { + "name": "_owner", + "type": "address" + } + ], + "name": "initialize", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "erc20token", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/config/affirmation-request-watcher.config.js b/config/affirmation-request-watcher.config.js index 24e770d..d5d7c73 100644 --- a/config/affirmation-request-watcher.config.js +++ b/config/affirmation-request-watcher.config.js @@ -1,11 +1,25 @@ require('dotenv').config() const baseConfig = require('./base.config') const erc20Abi = require('../abis/ERC20.abi') +const { ERC_TYPES } = require('../src/utils/constants') + +const initialChecksJson = process.argv[3] +let initialChecks +try { + initialChecks = JSON.parse(initialChecksJson) +} catch (e) { + throw new Error('Error on decoding values from initial checks.') +} + +if (baseConfig.id === 'erc-erc' && initialChecks.foreignERC === ERC_TYPES.ERC677) { + baseConfig.id = 'erc677-erc677' +} const id = `${baseConfig.id}-affirmation-request` module.exports = - baseConfig.id === 'erc-erc' || baseConfig.id === 'erc-native' + (baseConfig.id === 'erc-erc' && initialChecks.foreignERC === ERC_TYPES.ERC20) || + baseConfig.id === 'erc-native' ? { ...baseConfig.bridgeConfig, ...baseConfig.foreignConfig, diff --git a/config/base.config.js b/config/base.config.js index ed3799d..27b0537 100644 --- a/config/base.config.js +++ b/config/base.config.js @@ -8,7 +8,7 @@ const homeNativeErcAbi = require('../abis/HomeBridgeNativeToErc.abi') const foreignNativeErcAbi = require('../abis/ForeignBridgeNativeToErc.abi') const homeErcErcAbi = require('../abis/HomeBridgeErcToErc.abi') -const foreignErcErcAbi = require('../abis/ForeignBridgeErcToErc.abi') +const foreignErc677Erc677Abi = require('../abis/ForeignBridgeErc677ToErc677.abi') const homeErcNativeAbi = require('../abis/HomeBridgeErcToNative.abi') const foreignErcNativeAbi = require('../abis/ForeignBridgeErcToNative.abi') @@ -27,7 +27,7 @@ switch (process.env.BRIDGE_MODE) { break case 'ERC_TO_ERC': homeAbi = homeErcErcAbi - foreignAbi = foreignErcErcAbi + foreignAbi = foreignErc677Erc677Abi id = 'erc-erc' break case 'ERC_TO_NATIVE': diff --git a/scripts/initialChecks.js b/scripts/initialChecks.js new file mode 100644 index 0000000..12f0b29 --- /dev/null +++ b/scripts/initialChecks.js @@ -0,0 +1,33 @@ +const path = require('path') +require('dotenv').config({ + path: path.join(__dirname, '../.env') +}) +const Web3 = require('web3') +const ERC677BridgeTokenABI = require('../abis/ERC677BridgeToken.abi') +const { ERC_TYPES } = require('../src/utils/constants') + +async function initialChecks() { + const { ERC20_TOKEN_ADDRESS, BRIDGE_MODE, FOREIGN_RPC_URL, FOREIGN_BRIDGE_ADDRESS } = process.env + const result = {} + + if (BRIDGE_MODE === 'ERC_TO_ERC' && process.argv[2].includes('affirmation-request-watcher')) { + const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL)) + const tokenContract = new foreignWeb3.eth.Contract(ERC677BridgeTokenABI, ERC20_TOKEN_ADDRESS) + try { + const bridgeContract = await tokenContract.methods.bridgeContract().call() + if (bridgeContract === FOREIGN_BRIDGE_ADDRESS) { + result.foreignERC = ERC_TYPES.ERC677 + } else { + result.foreignERC = ERC_TYPES.ERC20 + } + } catch (e) { + result.foreignERC = ERC_TYPES.ERC20 + } + } + console.log(JSON.stringify(result)) + return result +} + +initialChecks() + +module.exports = initialChecks diff --git a/scripts/start-worker.sh b/scripts/start-worker.sh index d0c7dec..e705a07 100755 --- a/scripts/start-worker.sh +++ b/scripts/start-worker.sh @@ -9,8 +9,10 @@ WORKER="${WORKERS_DIR}${1}.js" CONFIG="${2}.config.js" LOG="${LOGS_DIR}${2}.txt" +CHECKS=$(node scripts/initialChecks.js "${CONFIG}") + if [ "${NODE_ENV}" = "production" ]; then - exec node "${WORKER}" "${CONFIG}" + exec node "${WORKER}" "${CONFIG}" "$CHECKS" else - node "${WORKER}" "${CONFIG}" | tee -a "${LOG}" | pino-pretty + node "${WORKER}" "${CONFIG}" "$CHECKS" | tee -a "${LOG}" | pino-pretty fi diff --git a/src/utils/constants.js b/src/utils/constants.js index 5351781..55a2861 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -16,5 +16,9 @@ module.exports = { GAS_PRICE_BOUNDARIES: { MIN: 1, MAX: 250 + }, + ERC_TYPES: { + ERC20: 'ERC20', + ERC677: 'ERC677' } } diff --git a/src/watcher.js b/src/watcher.js index dbdfb17..e566c5b 100644 --- a/src/watcher.js +++ b/src/watcher.js @@ -95,6 +95,7 @@ function processEvents(events) { case 'erc-native-collected-signatures': return processCollectedSignatures(events) case 'native-erc-affirmation-request': + case 'erc677-erc677-affirmation-request': return processAffirmationRequests(events) case 'erc-erc-affirmation-request': case 'erc-native-affirmation-request': From c61eadde58550ec6c0d76043b87b9d9ca9e7fef5 Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Fri, 3 May 2019 11:17:41 -0300 Subject: [PATCH 3/5] Update parity version on e2e tests --- e2e/parity/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/parity/Dockerfile b/e2e/parity/Dockerfile index c8589f8..2a61df9 100644 --- a/e2e/parity/Dockerfile +++ b/e2e/parity/Dockerfile @@ -1,4 +1,4 @@ -FROM parity/parity:v2.2.11 +FROM parity/parity:v2.3.3 WORKDIR /stuff From ff56ec992942160009fdc74367dc0e3b178a6c59 Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Fri, 3 May 2019 14:53:14 -0300 Subject: [PATCH 4/5] Check that config receives correct parameters --- config/affirmation-request-watcher.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/affirmation-request-watcher.config.js b/config/affirmation-request-watcher.config.js index d5d7c73..967ba53 100644 --- a/config/affirmation-request-watcher.config.js +++ b/config/affirmation-request-watcher.config.js @@ -4,6 +4,11 @@ const erc20Abi = require('../abis/ERC20.abi') const { ERC_TYPES } = require('../src/utils/constants') const initialChecksJson = process.argv[3] + +if (!initialChecksJson) { + throw new Error('initial check parameter was not provided.') +} + let initialChecks try { initialChecks = JSON.parse(initialChecksJson) From f2610a95161c55007c69f0ff34d3788ac69f22f2 Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Fri, 3 May 2019 14:54:48 -0300 Subject: [PATCH 5/5] Remove specific watcher check on initialChecks --- scripts/initialChecks.js | 2 +- scripts/start-worker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/initialChecks.js b/scripts/initialChecks.js index 12f0b29..0f9940d 100644 --- a/scripts/initialChecks.js +++ b/scripts/initialChecks.js @@ -10,7 +10,7 @@ async function initialChecks() { const { ERC20_TOKEN_ADDRESS, BRIDGE_MODE, FOREIGN_RPC_URL, FOREIGN_BRIDGE_ADDRESS } = process.env const result = {} - if (BRIDGE_MODE === 'ERC_TO_ERC' && process.argv[2].includes('affirmation-request-watcher')) { + if (BRIDGE_MODE === 'ERC_TO_ERC') { const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL)) const tokenContract = new foreignWeb3.eth.Contract(ERC677BridgeTokenABI, ERC20_TOKEN_ADDRESS) try { diff --git a/scripts/start-worker.sh b/scripts/start-worker.sh index e705a07..374e040 100755 --- a/scripts/start-worker.sh +++ b/scripts/start-worker.sh @@ -9,7 +9,7 @@ WORKER="${WORKERS_DIR}${1}.js" CONFIG="${2}.config.js" LOG="${LOGS_DIR}${2}.txt" -CHECKS=$(node scripts/initialChecks.js "${CONFIG}") +CHECKS=$(node scripts/initialChecks.js) if [ "${NODE_ENV}" = "production" ]; then exec node "${WORKER}" "${CONFIG}" "$CHECKS"