Skip to content

Commit

Permalink
Restart pod when event proof is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
KarishmaBothara committed May 3, 2023
1 parent 864e866 commit b304abf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/subscribeEventProof.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 :::`);
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b304abf

Please sign in to comment.