From 12ee67ebb01a07a6f5ce87b0574fa5c425019e41 Mon Sep 17 00:00:00 2001 From: madhurMongia Date: Mon, 25 Nov 2024 16:04:34 +0700 Subject: [PATCH] feat(validtor-bot): review fixes --- .../src/ArbToEth/watcherArbToGnosis.ts | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/validator-cli/src/ArbToEth/watcherArbToGnosis.ts b/validator-cli/src/ArbToEth/watcherArbToGnosis.ts index dae50c7d..b230db35 100644 --- a/validator-cli/src/ArbToEth/watcherArbToGnosis.ts +++ b/validator-cli/src/ArbToEth/watcherArbToGnosis.ts @@ -567,7 +567,9 @@ const ArbBlockToL1Block = async ( let latestL2BlockNumberOnEth: number; let result = (await nodeInterface.functions .findBatchContainingBlock(L2Block.number, { blockTag: "latest" }) - .catch((e) => {})) as [BigNumber] & { batch: BigNumber }; + .catch((e) => { + console.error("Error finding batch containing block:", JSON.parse(JSON.stringify(e)).error.body); + })) as [BigNumber] & { batch: BigNumber }; if (!result) { if (!fallbackLatest) { @@ -676,7 +678,7 @@ async function getClaimForEpoch( challenger: constants.AddressZero, }; let other = {} as any; - let calculatedHash = await retryOperation(() => veaOutbox.hashClaim(claim), 1000, 10); + let calculatedHash = hashClaim(claim); if (calculatedHash == claimHash) return claim; // Check for Challenged event @@ -698,7 +700,7 @@ async function getClaimForEpoch( other.challengeBlock = challengedEvents[0].blockNumber; } - calculatedHash = await retryOperation(() => veaOutbox.hashClaim(claim), 1000, 10); + calculatedHash = hashClaim(claim); if (calculatedHash == claimHash) return claim; // Check for VerificationStarted event @@ -724,13 +726,11 @@ async function getClaimForEpoch( claim.challenger = constants.AddressZero; } - calculatedHash = await retryOperation(() => veaOutbox.hashClaim(claim), 1000, 10); + calculatedHash = hashClaim(claim); if (calculatedHash == claimHash) return claim; - const [claimBridgerHonest, claimChallengerHonest] = await Promise.all([ - retryOperation(() => veaOutbox.hashClaim({ ...claim, honest: 1 }), 1000, 10) as any, - retryOperation(() => veaOutbox.hashClaim({ ...claim, honest: 2 }), 1000, 10) as any, - ]); + const claimBridgerHonest = hashClaim({ ...claim, honest: 1 }); + const claimChallengerHonest = hashClaim({ ...claim, honest: 2 }); if (claimBridgerHonest === claimHash) return { ...claim, honest: 1 }; if (claimChallengerHonest === claimHash) return { ...claim, honest: 2 }; @@ -1093,6 +1093,21 @@ async function reconstructChallengeProgress( return challengeProgress; } +const hashClaim = (claim) => { + return ethers.utils.solidityKeccak256( + ["bytes32", "address", "uint32", "uint32", "uint32", "uint8", "address"], + [ + claim.stateRoot, + claim.claimer, + claim.timestampClaimed, + claim.timestampVerification, + claim.blocknumberVerification, + claim.honest, + claim.challenger, + ] + ); +}; + (async () => { retryOperation(() => watch(), 1000, 10); })();