From b304abf6e365464b94bdd122b74752501392dea3 Mon Sep 17 00:00:00 2001 From: KarishmaBothara Date: Wed, 3 May 2023 10:55:03 +0400 Subject: [PATCH] Restart pod when event proof is not found --- scripts/subscribeEventProof.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/subscribeEventProof.js b/scripts/subscribeEventProof.js index 295e713..5ac31a4 100644 --- a/scripts/subscribeEventProof.js +++ b/scripts/subscribeEventProof.js @@ -8,7 +8,7 @@ const { EventProcessed } = require('../src/mongo/models'); const ethers = require('ethers'); const bridgeAbi = require("../abi/CENNZnetBridge.json").abi; -const timeoutMs = 20000; +const timeoutMs = 40000; const BUFFER = 1000; // Ignore if validator public key is 0x000.. const IGNORE_KEY = '0x000000000000000000000000000000000000000000000000000000000000000000'; @@ -60,8 +60,9 @@ async function sendSlackNotification(message) { // Submit the event proof on Ethereum Bridge contract async function getEventPoofAndSubmit(api, eventId, bridge, txExecutor, newValidatorSetId, blockHash, provider) { const eventExistsOnEth = await bridge.eventIds(eventId.toString()); + if (eventExistsOnEth) return; // return if event proof already exist on Ethereum const eventProof = await withTimeout(api.derive.ethBridge.eventProof(eventId), timeoutMs); - if (eventProof && !eventExistsOnEth) { + if (eventProof) { const newValidators = await extractNewValidators(api, blockHash); logger.info(`IMP Sending setValidators tx with the account: ${txExecutor.address}`); logger.info(`IMP Parameters :::`); @@ -112,9 +113,11 @@ async function getEventPoofAndSubmit(api, eventId, bridge, txExecutor, newValida on CENNZnets ${process.env.NETWORK} chain`; await sendSlackNotification(message); } - } else if (!eventProof){ + } else { logger.info(`IMP Could not retrieve event proof for event id ${eventId} from derived query api.derive.ethBridge.eventProof at ${timeoutMs} timeout`); + // restart + process.exit(1); } }