From b2334451f8593e4df0aa660334e280dc4c3ef514 Mon Sep 17 00:00:00 2001 From: madhurMongia Date: Thu, 21 Nov 2024 14:47:21 +0700 Subject: [PATCH] feat(validator-bot): review fixes by the rabbit --- relayer-cli/src/devnetRelayExample.ts | 2 +- validator-cli/.env.dist | 2 +- validator-cli/src/ArbToEth/watcherArbToGnosis.ts | 7 +++++-- validator-cli/src/utils/ethers.ts | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/relayer-cli/src/devnetRelayExample.ts b/relayer-cli/src/devnetRelayExample.ts index ec32df82..114b2e22 100644 --- a/relayer-cli/src/devnetRelayExample.ts +++ b/relayer-cli/src/devnetRelayExample.ts @@ -3,7 +3,7 @@ import * as fs from "fs"; // let chain_ids = [5, 10200]; let chain_ids = [10200, 11155111]; -const epochPeriod = 3600; // 30 min +const epochPeriod = 3600; // 1 hour ["SIGINT", "SIGTERM", "SIGQUIT", "EXIT", "MODULE_NOT_FOUND"].forEach((signal) => process.on(signal, async () => { console.log("exit"); diff --git a/validator-cli/.env.dist b/validator-cli/.env.dist index 9d7afc9e..6534e420 100644 --- a/validator-cli/.env.dist +++ b/validator-cli/.env.dist @@ -11,7 +11,7 @@ VEAOUTBOX_ARBSEPOLIA_TO_SEPOLIA_ADDRESS=0x906dE43dBef27639b1688Ac46532a16dc07Ce4 VEAINBOX_ARB_TO_GNOSIS_ADDRESS=0x854374483572FFcD4d0225290346279d0718240b VEAOUTBOX_ARB_TO_GNOSIS_ADDRESS=0x2f1788F7B74e01c4C85578748290467A5f063B0b VEAROUTER_ARB_TO_GNOSIS_ADDRESS=0x5BE03fDE7794Bc188416ba16932510Ed1277b193 -GNO_AMB_ADDRESS=0x8448E15d0e706C0298dECA99F0b4744030e59d7d +GNOSIS_AMB_ADDRESS=0x8448E15d0e706C0298dECA99F0b4744030e59d7d TRANSACTION_BATCHER_CONTRACT_ADDRESS_SEPOLIA=0xe7953da7751063d0a41ba727c32c762d3523ade8 TRANSACTION_BATCHER_CONTRACT_ADDRESS_CHIADO=0xcC0a08D4BCC5f91ee9a1587608f7a2975EA75d73 \ No newline at end of file diff --git a/validator-cli/src/ArbToEth/watcherArbToGnosis.ts b/validator-cli/src/ArbToEth/watcherArbToGnosis.ts index 9f6b702f..dae50c7d 100644 --- a/validator-cli/src/ArbToEth/watcherArbToGnosis.ts +++ b/validator-cli/src/ArbToEth/watcherArbToGnosis.ts @@ -86,6 +86,7 @@ const secondsPerSlotGnosis = 5; const veaOutboxAddress = process.env.VEAOUTBOX_ARB_TO_GNOSIS_ADDRESS; const veaInboxAddress = process.env.VEAINBOX_ARB_TO_GNOSIS_ADDRESS; const veaRouterAddress = process.env.VEAROUTER_ARB_TO_GNOSIS_ADDRESS; +const gnosisAMBAddress = process.env.GNOSIS_AMB_ADDRESS; const challenges = new Map(); @@ -101,7 +102,7 @@ const watch = async () => { const veaOutbox = getVeaOutboxArbToGnosisProvider(veaOutboxAddress, process.env.PRIVATE_KEY, providerGnosis); const veaInbox = getVeaInboxArbToGnosisProvider(veaInboxAddress, process.env.PRIVATE_KEY, providerArb); const veaRouter = getVeaRouterArbToGnosisProvider(veaRouterAddress, process.env.PRIVATE_KEY, providerEth); - const amb = getAMBProvider(process.env.PRIVATE_KEY, providerGnosis); + const amb = getAMBProvider(gnosisAMBAddress, process.env.PRIVATE_KEY, providerGnosis); const wethAddress = (await retryOperation(() => veaOutbox.weth(), 1000, 10)) as string; const weth = getWETHProvider(wethAddress, process.env.PRIVATE_KEY, providerGnosis); @@ -932,7 +933,9 @@ async function reconstructChallengeProgress( retryOperation(() => providerArb.getBlock("latest"), 1000, 10) as any, ]); - const averageArbitrumBlocktime = 0.26; + const blockTimeWindow = 100; // Calculate average over last 100 blocks + const oldBlock = await providerArb.getBlock(arbLatest.number - blockTimeWindow); + const averageArbitrumBlocktime = (arbLatest.timestamp - oldBlock.timestamp) / blockTimeWindow; const estimatedArbBlocks = Math.ceil((arbLatest.timestamp - challengeBlock.timestamp) / averageArbitrumBlocktime); const snapshotSentFilter = veaInbox.filters.SnapshotSent(epoch, null); diff --git a/validator-cli/src/utils/ethers.ts b/validator-cli/src/utils/ethers.ts index 8a057680..7a06cbbf 100644 --- a/validator-cli/src/utils/ethers.ts +++ b/validator-cli/src/utils/ethers.ts @@ -69,8 +69,8 @@ function getVeaRouterArbToGnosisProvider(veaRouterAddress: string, privateKey: s return RouterArbToGnosis__factory.connect(veaRouterAddress, getWalletRPC(privateKey, rpc)); } -function getAMBProvider(privateKey: string, rpc: JsonRpcProvider) { - return IAMB__factory.connect(process.env.GNO_AMB_ADDRESS, getWalletRPC(privateKey, rpc)); +function getAMBProvider(ambAddress: string, privateKey: string, rpc: JsonRpcProvider) { + return IAMB__factory.connect(ambAddress, getWalletRPC(privateKey, rpc)); } export { getVeaOutboxArbToEth,