Skip to content

Commit

Permalink
feat(validator-bot): review fixes by the rabbit
Browse files Browse the repository at this point in the history
  • Loading branch information
madhurMongia committed Nov 21, 2024
1 parent c0461ef commit b233445
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion relayer-cli/src/devnetRelayExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion validator-cli/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions validator-cli/src/ArbToEth/watcherArbToGnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, ChallengeProgress>();

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions validator-cli/src/utils/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b233445

Please sign in to comment.