Skip to content

Commit

Permalink
chore(validator-bot): increased type safety
Browse files Browse the repository at this point in the history
  • Loading branch information
madhurMongia committed Dec 10, 2024
1 parent 0756c69 commit 6295b39
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
22 changes: 10 additions & 12 deletions validator-cli/src/ArbToEth/watcherArbToEth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,18 +441,16 @@ const watch = async () => {
continue;
}
}
const gasEstimate = BigInt(
(await retryOperation(
() =>
veaOutbox["challenge(uint256,(bytes32,address,uint32,uint32,uint32,uint8,address))"].estimateGas(
veaEpochOutboxCheck,
claim,
{ value: deposit }
),
1000,
10
)) as any
);
const gasEstimate = (await retryOperation(
() =>
veaOutbox["challenge(uint256,(bytes32,address,uint32,uint32,uint32,uint8,address))"].estimateGas(
veaEpochOutboxCheck,
claim,
{ value: deposit }
),
1000,
10
)) as bigint;

// Adjust the calculation to ensure maxFeePerGas is reasonable
const maxFeePerGasProfitable = deposit / (gasEstimate * BigInt(6));
Expand Down
2 changes: 1 addition & 1 deletion validator-cli/src/ArbToEth/watcherArbToGnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const watch = async () => {
// get Arb sequencer params
const l2Network = await getArbitrumNetwork(providerArb);
const sequencer = SequencerInbox__factory.connect(l2Network.ethBridge.sequencerInbox, providerEth);
const maxDelaySeconds = Number((await retryOperation(() => sequencer.maxTimeVariation(), 1000, 10))[1] as BigInt);
const maxDelaySeconds = Number((await retryOperation(() => sequencer.maxTimeVariation(), 1000, 10))[1] as bigint);

// get vea outbox params
const deposit = (await retryOperation(() => veaOutbox.deposit(), 1000, 10)) as bigint;
Expand Down
10 changes: 5 additions & 5 deletions validator-cli/src/utils/devnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function initialize(
veaOutboxAddress: string,
veaInboxAddress: string,
outboxRPCUrl: string
): Promise<[VeaInboxArbToEth, number, BigInt, VeaOutboxArbToEthDevnet, BigInt]> {
): Promise<[VeaInboxArbToEth, number, bigint, VeaOutboxArbToEthDevnet, bigint]> {
const outboxProvider = new JsonRpcProvider(outboxRPCUrl);
const veaOutbox = getVeaOutboxArbToEthDevnet(veaOutboxAddress, process.env.PRIVATE_KEY, outboxRPCUrl);

Expand Down Expand Up @@ -41,18 +41,18 @@ async function initialize(
async function happyPath(
veaInbox: VeaInboxArbToEth,
epochPeriod: number,
lastSavedCount: BigInt,
lastSavedCount: bigint,
veaOutbox: VeaOutboxArbToEthDevnet,
deposit: BigInt
): Promise<BigInt> {
deposit: bigint
): Promise<bigint> {
let currentTS = Math.floor(Date.now() / 1000);
let claimableEpoch = Math.floor(currentTS / epochPeriod);
let newCount = lastSavedCount;
const snapshot = await veaInbox.snapshots(claimableEpoch);

if (snapshot == "0x0000000000000000000000000000000000000000000000000000000000000000") {
// check if snapshot should be taken
const inboxCount: BigInt = await veaInbox.count();
const inboxCount: bigint = await veaInbox.count();
if (inboxCount > lastSavedCount) {
// should take snapshot
console.log("inbox updated: taking snapshot. . .");
Expand Down

0 comments on commit 6295b39

Please sign in to comment.