Skip to content

Commit

Permalink
feat(validtor-bot): review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
madhurMongia committed Nov 25, 2024
1 parent b233445 commit 12ee67e
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions validator-cli/src/ArbToEth/watcherArbToGnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 };
Expand Down Expand Up @@ -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);
})();
Expand Down

0 comments on commit 12ee67e

Please sign in to comment.