Skip to content

Commit 332a539

Browse files
committed
chore(validator-bot): upgraded arbToEth
1 parent 7ee3740 commit 332a539

File tree

4 files changed

+53
-70
lines changed

4 files changed

+53
-70
lines changed

relayer-cli/src/utils/ethers.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ function getVeaOutboxArbToEthDevnet(veaOutboxAddress: string, privateKey: string
8181
return VeaOutboxArbToEthDevnet__factory.connect(veaOutboxAddress, getWallet(privateKey, web3ProviderURL));
8282
}
8383

84-
function getVeaOutboxArbToGnosisProvider(veaOutboxAddress: string, privateKey: string, rpc: Provider) {
85-
return VeaOutboxArbToGnosisDevnet__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc));
86-
}
87-
88-
function getVeaOutboxArbToGnosis(veaOutboxAddress: string, privateKey: string, web3ProviderURL: string) {
89-
return VeaOutboxArbToGnosisDevnet__factory.connect(veaOutboxAddress, getWallet(privateKey, web3ProviderURL));
90-
}
91-
9284
export {
9385
getWalletRPC,
9486
getVeaOutboxArbToEthDevnetProvider,

validator-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@arbitrum/sdk": "4.0.1",
2121
"@flashbots/ethers-provider-bundle": "^0.6.2",
2222
"@kleros/vea-contracts": "workspace:^",
23-
"@typechain/ethers-v5": "^10.2.0",
23+
"@typechain/ethers-v6": "^0.5.1",
2424
"dotenv": "^16.4.5",
2525
"pm2": "^5.2.2",
2626
"typescript": "^4.9.5",

validator-cli/src/ArbToEth/watcherArbToEth.ts

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getArbitrumNetwork } from "@arbitrum/sdk";
44
import { NODE_INTERFACE_ADDRESS } from "@arbitrum/sdk/dist/lib/dataEntities/constants";
55
import { NodeInterface__factory } from "@arbitrum/sdk/dist/lib/abi/factories/NodeInterface__factory";
66
import { SequencerInbox__factory } from "@arbitrum/sdk/dist/lib/abi/factories/SequencerInbox__factory";
7-
import { BigNumber, ContractTransaction, ethers } from "ethers";
7+
import { ContractTransaction, ContractTransactionResponse, ethers } from "ethers";
88
import { Block, Log, TransactionReceipt } from "@ethersproject/abstract-provider";
99
import { SequencerInbox } from "@arbitrum/sdk/dist/lib/abi/SequencerInbox";
1010
import { NodeInterface } from "@arbitrum/sdk/dist/lib/abi/NodeInterface";
@@ -43,16 +43,12 @@ const watch = async () => {
4343
// get Arb sequencer params
4444
const l2Network = await getArbitrumNetwork(providerArb);
4545
const sequencer = SequencerInbox__factory.connect(l2Network.ethBridge.sequencerInbox, providerEth);
46-
const maxDelaySeconds = (
47-
(await retryOperation(() => sequencer.maxTimeVariation(), 1000, 10))[1] as BigNumber
48-
).toNumber();
46+
const maxDelaySeconds = Number((await retryOperation(() => sequencer.maxTimeVariation(), 1000, 10))[1]);
4947

5048
// get vea outbox params
51-
const deposit = (await retryOperation(() => veaOutbox.deposit(), 1000, 10)) as BigNumber;
52-
const epochPeriod = ((await retryOperation(() => veaOutbox.epochPeriod(), 1000, 10)) as BigNumber).toNumber();
53-
const sequencerDelayLimit = (
54-
(await retryOperation(() => veaOutbox.sequencerDelayLimit(), 1000, 10)) as BigNumber
55-
).toNumber();
49+
const deposit = BigInt((await retryOperation(() => veaOutbox.deposit(), 1000, 10)) as any);
50+
const epochPeriod = Number(await retryOperation(() => veaOutbox.epochPeriod(), 1000, 10));
51+
const sequencerDelayLimit = Number(await retryOperation(() => veaOutbox.sequencerDelayLimit(), 1000, 10));
5652

5753
// *
5854
// calculate epoch range to check claims on Eth
@@ -182,15 +178,14 @@ const watch = async () => {
182178
}
183179

184180
// get claim data
185-
const logClaimed: Log = (
181+
const logClaimed = (
186182
await retryOperation(
187183
() =>
188-
providerEth.getLogs({
189-
address: process.env.VEAOUTBOX_ARB_TO_ETH_ADDRESS,
190-
topics: veaOutbox.filters.Claimed(null, [veaEpochOutboxCheck], null).topics,
191-
fromBlock: blockNumberOutboxLowerBound,
192-
toBlock: blockTagEth,
193-
}),
184+
veaOutbox.queryFilter(
185+
veaOutbox.filters.Claimed(null, veaEpochOutboxCheck, null),
186+
blockNumberOutboxLowerBound,
187+
blockTagEth
188+
),
194189
1000,
195190
10
196191
)
@@ -245,12 +240,11 @@ const watch = async () => {
245240
// check if the claim is in verification or verified
246241
const logVerficiationStarted = (await retryOperation(
247242
() =>
248-
providerEth.getLogs({
249-
address: process.env.VEAOUTBOX_ARB_TO_ETH_ADDRESS,
250-
topics: veaOutbox.filters.VerificationStarted(veaEpochOutboxCheck).topics,
251-
fromBlock: blockNumberOutboxLowerBound,
252-
toBlock: blockTagEth,
253-
}),
243+
veaOutbox.queryFilter(
244+
veaOutbox.filters.VerificationStarted(veaEpochOutboxCheck),
245+
blockNumberOutboxLowerBound,
246+
blockTagEth
247+
),
254248
1000,
255249
10
256250
)) as Log[];
@@ -288,12 +282,11 @@ const watch = async () => {
288282

289283
const logChallenges = (await retryOperation(
290284
() =>
291-
providerEth.getLogs({
292-
address: process.env.VEAOUTBOX_ARB_TO_ETH_ADDRESS,
293-
topics: veaOutbox.filters.Challenged(veaEpochOutboxCheck, null).topics,
294-
fromBlock: blockNumberOutboxLowerBound,
295-
toBlock: blockTagEth,
296-
}),
285+
veaOutbox.queryFilter(
286+
veaOutbox.filters.Challenged(veaEpochOutboxCheck, null),
287+
blockNumberOutboxLowerBound,
288+
blockTagEth
289+
),
297290
1000,
298291
10
299292
)) as Log[];
@@ -319,7 +312,7 @@ const watch = async () => {
319312
() => veaOutbox.withdrawChallengeDeposit(veaEpochOutboxCheck, challengerWinClaim),
320313
1000,
321314
10
322-
)) as ContractTransaction;
315+
)) as ContractTransactionResponse;
323316
console.log(
324317
"Deposit withdrawn by challenger for " +
325318
veaEpochOutboxCheck +
@@ -355,28 +348,25 @@ const watch = async () => {
355348
const fromClaimEpochBlock = Math.ceil(
356349
blockLatestArb.number - (blockLatestArb.timestamp - claimTimestamp) / arbAverageBlockTime
357350
);
351+
358352
const sendSnapshotLogs = (await retryOperation(
359353
() =>
360-
providerArb.getLogs({
361-
address: process.env.VEAINBOX_ARB_TO_ETH_ADDRESS,
362-
topics: veaInbox.filters.SnapshotSent(veaEpochOutboxCheck, null).topics,
363-
fromBlock: fromClaimEpochBlock,
364-
toBlock: blockTagEth,
365-
}),
354+
veaInbox.queryFilter(
355+
veaInbox.filters.SnapshotSent(veaEpochOutboxCheck, null),
356+
fromClaimEpochBlock,
357+
blockTagEth
358+
),
366359
1000,
367360
10
368361
)) as Log[];
369362
if (sendSnapshotLogs.length == 0) {
370363
// No snapshot sent so, send snapshot
371364
try {
372-
const gasEstimate = (await retryOperation(
373-
() =>
374-
veaInbox.estimateGas[
375-
"sendSnapshot(uint256,(bytes32,address,uint32,uint32,uint32,uint8,address))"
376-
](veaEpochOutboxCheck, claim),
365+
const gasEstimate = await retryOperation(
366+
() => veaInbox.sendSnapshot.estimateGas(veaEpochOutboxCheck, claim),
377367
1000,
378368
10
379-
)) as BigNumber;
369+
);
380370

381371
const txnSendSnapshot = (await retryOperation(
382372
() =>
@@ -389,7 +379,7 @@ const watch = async () => {
389379
),
390380
1000,
391381
10
392-
)) as ContractTransaction;
382+
)) as ContractTransactionResponse;
393383
console.log(
394384
"Snapshot message sent for epoch " +
395385
veaEpochOutboxCheck +
@@ -451,26 +441,28 @@ const watch = async () => {
451441
continue;
452442
}
453443
}
454-
const gasEstimate = (await retryOperation(
455-
() =>
456-
veaOutbox.estimateGas["challenge(uint256,(bytes32,address,uint32,uint32,uint32,uint8,address))"](
457-
veaEpochOutboxCheck,
458-
claim,
459-
{ value: deposit }
460-
),
461-
1000,
462-
10
463-
)) as BigNumber;
444+
const gasEstimate = BigInt(
445+
(await retryOperation(
446+
() =>
447+
veaOutbox["challenge(uint256,(bytes32,address,uint32,uint32,uint32,uint8,address))"].estimateGas(
448+
veaEpochOutboxCheck,
449+
claim,
450+
{ value: deposit }
451+
),
452+
1000,
453+
10
454+
)) as any
455+
);
464456

465457
// Adjust the calculation to ensure maxFeePerGas is reasonable
466-
const maxFeePerGasProfitable = deposit.div(gasEstimate.mul(6));
458+
const maxFeePerGasProfitable = deposit / (gasEstimate * BigInt(6));
467459

468460
// Set a reasonable maxPriorityFeePerGas but ensure it's lower than maxFeePerGas
469-
let maxPriorityFeePerGasMEV = BigNumber.from("6667000000000"); // 6667 gwei
461+
let maxPriorityFeePerGasMEV = BigInt(6667000000000); // 6667 gwei
470462
console.log("Transaction Challenge Gas Estimate", gasEstimate.toString());
471463

472464
// Ensure maxPriorityFeePerGas <= maxFeePerGas
473-
if (maxPriorityFeePerGasMEV.gt(maxFeePerGasProfitable)) {
465+
if (maxPriorityFeePerGasMEV > maxFeePerGasProfitable) {
474466
console.warn(
475467
"maxPriorityFeePerGas is higher than maxFeePerGasProfitable, adjusting maxPriorityFeePerGas"
476468
);
@@ -491,7 +483,7 @@ const watch = async () => {
491483
),
492484
1000,
493485
10
494-
)) as ContractTransaction;
486+
)) as ContractTransactionResponse;
495487
// Make wait for receipt and check if the challenge is finalized
496488
console.log("Transaction Challenge Hash", txnChallenge.hash);
497489
// Update local var with the challenge txn hash
@@ -671,7 +663,7 @@ const ArbBlockToL1Block = async (
671663
.catch((e) => {
672664
// If the L2Block is the latest ArbBlock this will always throw an error
673665
console.log("Error finding batch containing block, searching heuristically...");
674-
})) as [BigNumber] & { batch: BigNumber };
666+
})) as any;
675667

676668
if (!result) {
677669
if (!fallbackLatest) {
@@ -729,8 +721,8 @@ const findLatestL2BatchAndBlock = async (
729721
return [result.batch.toNumber(), high];
730722
};
731723

732-
const hashClaim = (claim) => {
733-
return ethers.utils.solidityKeccak256(
724+
const hashClaim = (claim): any => {
725+
return ethers.solidityPackedKeccak256(
734726
["bytes32", "address", "uint32", "uint32", "uint32", "uint8", "address"],
735727
[
736728
claim.stateRoot,

validator-cli/src/utils/ethers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Wallet } from "@ethersproject/wallet";
2-
import { JsonRpcProvider } from "@ethersproject/providers";
1+
import { Wallet, JsonRpcProvider } from "ethers";
32
import {
43
VeaOutboxArbToEth__factory,
54
VeaOutboxArbToGnosis__factory,

0 commit comments

Comments
 (0)