From de76a1aaadec9c47e6de6d556155258e0ccfc246 Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Tue, 29 Oct 2019 18:24:38 +0300 Subject: [PATCH] Eth watcher should now work on ci env --- .circleci/config.yml | 25 ++++++------------------- src/oracle/ethWatcher/ethWatcher.js | 13 ++----------- src/oracle/proxy/index.js | 4 ++-- 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ab69ae..0da713c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,15 +27,12 @@ orbs: - run: name: "Backup blockchains data using temporary container" command: | - mkdir -p ./workspace + mkdir -p ./workspace/ganache_side_data + mkdir -p ./workspace/ganache_home_data docker run --rm -v "ganache_side_data:/ganache_side_data" -v "ganache_home_data:/ganache_home_data" -itd --name tmp alpine:3.9.4 - docker cp "tmp:/ganache_side_data" "./workspace/ganache_side_data" - docker cp "tmp:/ganache_home_data" "./workspace/ganache_home_data" + docker cp "tmp:/ganache_side_data/." "./workspace/ganache_side_data" + docker cp "tmp:/ganache_home_data/." "./workspace/ganache_home_data" docker kill tmp - du -sh ./workspace/ganache_side_data - du -sh ./workspace/ganache_home_data - ls ./workspace/ganache_side_data - ls ./workspace/ganache_home_data - persist_to_workspace: root: ./workspace paths: @@ -47,15 +44,11 @@ orbs: - run: name: "Restore blockchains data from backup using temporary container" command: | - du -sh ./workspace/ganache_side_data - du -sh ./workspace/ganache_home_data - ls ./workspace/ganache_side_data - ls ./workspace/ganache_home_data docker volume create ganache_side_data docker volume create ganache_home_data docker run --rm -v "ganache_side_data:/ganache_side_data" -v "ganache_home_data:/ganache_home_data" -itd --name tmp alpine:3.9.4 - docker cp "./workspace/ganache_side_data" "tmp:/ganache_side_data" - docker cp "./workspace/ganache_home_data" "tmp:/ganache_home_data" + docker cp "./workspace/ganache_side_data/." "tmp:/ganache_side_data" + docker cp "./workspace/ganache_home_data/." "tmp:/ganache_home_data" docker kill tmp restore_tss_image: description: "Restores tss image from cache" @@ -159,9 +152,6 @@ jobs: command: | BLOCK_TIME=3 ./demo/start-environment.sh cat ./tests/config.json | jq .users[].ethAddress | xargs -I {} ./src/test-services/ethereumSend/run.sh {} 100 - - run: - name: "Get bridge deployed code" - command: docker run --network blockchain_home --entrypoint ash appropriate/curl:latest -c "curl -X POST --data \{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\":[\"0x44c158FE850821ae69DaF37AADF5c539e9d0025B\",\"latest\"],\"id\":1\} http://ganache_home:8545" - run: name: "Stop dev environment" command: docker kill ganache_side ganache_home @@ -188,9 +178,6 @@ jobs: N=2 ./demo/validator-demo.sh -d N=3 ./demo/validator-demo.sh -d docker ps - - run: - name: "Get bridge deployed code" - command: docker run --network blockchain_home --entrypoint ash appropriate/curl:latest -c "curl -X POST --data \{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\":[\"0x44c158FE850821ae69DaF37AADF5c539e9d0025B\",\"latest\"],\"id\":1\} http://ganache_home:8545" - run: name: "Wait until validator nodes are ready" command: | diff --git a/src/oracle/ethWatcher/ethWatcher.js b/src/oracle/ethWatcher/ethWatcher.js index b87f100..aec54e3 100644 --- a/src/oracle/ethWatcher/ethWatcher.js +++ b/src/oracle/ethWatcher/ethWatcher.js @@ -103,16 +103,7 @@ async function initialize () { foreignNonce[epoch] = parseInt(await redis.get(`foreignNonce${epoch}`)) || 0 } logger.debug('Checking if current validator') - let currentValidators = [] - try { - logger.debug('1') - currentValidators = await bridge.methods.getValidators().call() - logger.debug('2') - logger.debug('%o', currentValidators) - } catch (e) { - logger.debug('%o', e) - } - isCurrentValidator = (currentValidators).includes(validatorAddress) + isCurrentValidator = (await bridge.methods.getValidators().call()).includes(validatorAddress) logger.debug(`${isCurrentValidator}`) if (isCurrentValidator) { logger.info(`${validatorAddress} is a current validator`) @@ -183,7 +174,7 @@ initialize().then(async () => { while (true) { await main() } -}) +}, e => logger.warn('Initialization failed %o', e)) async function sendKeygen (event) { const newEpoch = event.returnValues.newEpoch.toNumber() diff --git a/src/oracle/proxy/index.js b/src/oracle/proxy/index.js index 00eba0c..8fb3454 100644 --- a/src/oracle/proxy/index.js +++ b/src/oracle/proxy/index.js @@ -358,10 +358,10 @@ async function info (req, res) { votesForCancelKeygen, confirmationsForFundsTransfer } - logger.debug('%o', msg) + logger.trace('%o', msg) res.send(msg) } catch (e) { - logger.debug('%o', { message: 'Something went wrong, resend request', error: e }) + logger.debug('%o', e) res.send({ message: 'Something went wrong, resend request', error: e }) } logger.debug('Info end')