Fix error handling on monitor workers

This commit is contained in:
Gerardo Nardelli 2019-05-30 15:05:36 -03:00
parent 1ab4a0eca8
commit 5ab299089f
7 changed files with 314 additions and 352 deletions

@ -13,13 +13,7 @@ const foreignProvider = new Web3.providers.HttpProvider(FOREIGN_RPC_URL)
const web3Foreign = new Web3(foreignProvider) const web3Foreign = new Web3(foreignProvider)
async function main() { async function main() {
try { const { foreignDeposits, homeDeposits, homeWithdrawals, foreignWithdrawals } = await eventsInfo()
const {
foreignDeposits,
homeDeposits,
homeWithdrawals,
foreignWithdrawals
} = await eventsInfo()
const xSignatures = foreignDeposits.filter(findDifferences(homeDeposits)) const xSignatures = foreignDeposits.filter(findDifferences(homeDeposits))
const xAffirmations = homeWithdrawals.filter(findDifferences(foreignWithdrawals)) const xAffirmations = homeWithdrawals.filter(findDifferences(foreignWithdrawals))
@ -71,10 +65,6 @@ async function main() {
}, },
lastChecked: Math.floor(Date.now() / 1000) lastChecked: Math.floor(Date.now() / 1000)
} }
} catch (e) {
logger.error(e)
throw e
}
} }
/** /**

@ -40,10 +40,8 @@ async function checkWorker() {
JSON.stringify(vBalances, null, 4) JSON.stringify(vBalances, null, 4)
) )
logger.debug('Done') logger.debug('Done')
return status
} catch (e) { } catch (e) {
logger.error(e) logger.error(e)
throw e
} }
} }
checkWorker() checkWorker()

@ -21,10 +21,8 @@ async function checkWorker2() {
JSON.stringify(_alerts, null, 4) JSON.stringify(_alerts, null, 4)
) )
logger.debug('Done x2') logger.debug('Done x2')
return evStats
} catch (e) { } catch (e) {
logger.error('checkWorker2.js', e) logger.error(e)
throw e
} }
} }
checkWorker2() checkWorker2()

@ -57,7 +57,6 @@ function compareTransferForeign(home) {
} }
async function main() { async function main() {
try {
const { const {
foreignDeposits, foreignDeposits,
homeDeposits, homeDeposits,
@ -86,10 +85,6 @@ async function main() {
onlyInForeignWithdrawals, onlyInForeignWithdrawals,
lastChecked: Math.floor(Date.now() / 1000) lastChecked: Math.floor(Date.now() / 1000)
} }
} catch (e) {
logger.error(e)
throw e
}
} }
module.exports = main module.exports = main

@ -26,7 +26,6 @@ const FOREIGN_NATIVE_TO_ERC_ABI = require('../contracts/build/contracts/ForeignB
.abi .abi
async function main(bridgeMode) { async function main(bridgeMode) {
try {
if (bridgeMode === BRIDGE_MODES.ERC_TO_ERC) { if (bridgeMode === BRIDGE_MODES.ERC_TO_ERC) {
const foreignBridge = new web3Foreign.eth.Contract( const foreignBridge = new web3Foreign.eth.Contract(
FOREIGN_ERC_TO_ERC_ABI, FOREIGN_ERC_TO_ERC_ABI,
@ -35,9 +34,7 @@ async function main(bridgeMode) {
const erc20Address = await foreignBridge.methods.erc20token().call() const erc20Address = await foreignBridge.methods.erc20token().call()
const erc20Contract = new web3Foreign.eth.Contract(ERC20_ABI, erc20Address) const erc20Contract = new web3Foreign.eth.Contract(ERC20_ABI, erc20Address)
logger.debug('calling erc20Contract.methods.balanceOf') logger.debug('calling erc20Contract.methods.balanceOf')
const foreignErc20Balance = await erc20Contract.methods const foreignErc20Balance = await erc20Contract.methods.balanceOf(FOREIGN_BRIDGE_ADDRESS).call()
.balanceOf(FOREIGN_BRIDGE_ADDRESS)
.call()
const homeBridge = new web3Home.eth.Contract(HOME_ERC_TO_ERC_ABI, HOME_BRIDGE_ADDRESS) const homeBridge = new web3Home.eth.Contract(HOME_ERC_TO_ERC_ABI, HOME_BRIDGE_ADDRESS)
logger.debug('calling homeBridge.methods.erc677token') logger.debug('calling homeBridge.methods.erc677token')
const tokenAddress = await homeBridge.methods.erc677token().call() const tokenAddress = await homeBridge.methods.erc677token().call()
@ -91,9 +88,7 @@ async function main(bridgeMode) {
const erc20Address = await foreignBridge.methods.erc20token().call() const erc20Address = await foreignBridge.methods.erc20token().call()
const erc20Contract = new web3Foreign.eth.Contract(ERC20_ABI, erc20Address) const erc20Contract = new web3Foreign.eth.Contract(ERC20_ABI, erc20Address)
logger.debug('calling erc20Contract.methods.balanceOf') logger.debug('calling erc20Contract.methods.balanceOf')
const foreignErc20Balance = await erc20Contract.methods const foreignErc20Balance = await erc20Contract.methods.balanceOf(FOREIGN_BRIDGE_ADDRESS).call()
.balanceOf(FOREIGN_BRIDGE_ADDRESS)
.call()
const homeBridge = new web3Home.eth.Contract(HOME_ERC_TO_NATIVE_ABI, HOME_BRIDGE_ADDRESS) const homeBridge = new web3Home.eth.Contract(HOME_ERC_TO_NATIVE_ABI, HOME_BRIDGE_ADDRESS)
logger.debug('calling homeBridge.methods.blockRewardContract') logger.debug('calling homeBridge.methods.blockRewardContract')
@ -124,10 +119,6 @@ async function main(bridgeMode) {
} else { } else {
throw new Error(`Unrecognized bridge mode: '${bridgeMode}'`) throw new Error(`Unrecognized bridge mode: '${bridgeMode}'`)
} }
} catch (e) {
logger.error(e)
throw e
}
} }
module.exports = main module.exports = main

@ -19,7 +19,6 @@ const { getTokenType } = require('./utils/ercUtils')
const { getPastEvents, getBlockNumber } = require('./utils/contract') const { getPastEvents, getBlockNumber } = require('./utils/contract')
async function main(bridgeMode) { async function main(bridgeMode) {
try {
const { HOME_ABI, FOREIGN_ABI } = getBridgeABIs(bridgeMode) const { HOME_ABI, FOREIGN_ABI } = getBridgeABIs(bridgeMode)
const homeBridge = new web3Home.eth.Contract(HOME_ABI, HOME_BRIDGE_ADDRESS) const homeBridge = new web3Home.eth.Contract(HOME_ABI, HOME_BRIDGE_ADDRESS)
const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ABI, FOREIGN_BRIDGE_ADDRESS) const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ABI, FOREIGN_BRIDGE_ADDRESS)
@ -89,9 +88,5 @@ async function main(bridgeMode) {
withdrawals: foreignWithdrawals.length withdrawals: foreignWithdrawals.length
} }
} }
} catch (e) {
logger.error(e)
throw e
}
} }
module.exports = main module.exports = main

@ -47,7 +47,6 @@ async function getGasPrices(type) {
} }
async function main(bridgeMode) { async function main(bridgeMode) {
try {
const { HOME_ABI, FOREIGN_ABI } = getBridgeABIs(bridgeMode) const { HOME_ABI, FOREIGN_ABI } = getBridgeABIs(bridgeMode)
const homeBridge = new web3Home.eth.Contract(HOME_ABI, HOME_BRIDGE_ADDRESS) const homeBridge = new web3Home.eth.Contract(HOME_ABI, HOME_BRIDGE_ADDRESS)
const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ABI, FOREIGN_BRIDGE_ADDRESS) const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ABI, FOREIGN_BRIDGE_ADDRESS)
@ -147,10 +146,6 @@ async function main(bridgeMode) {
validatorsMatch, validatorsMatch,
lastChecked: Math.floor(Date.now() / 1000) lastChecked: Math.floor(Date.now() / 1000)
} }
} catch (e) {
logger.error(e)
throw e
}
} }
module.exports = main module.exports = main