@@ -4,7 +4,7 @@ import { getArbitrumNetwork } from "@arbitrum/sdk";
44import { NODE_INTERFACE_ADDRESS } from "@arbitrum/sdk/dist/lib/dataEntities/constants" ;
55import { NodeInterface__factory } from "@arbitrum/sdk/dist/lib/abi/factories/NodeInterface__factory" ;
66import { 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" ;
88import { Block , Log , TransactionReceipt } from "@ethersproject/abstract-provider" ;
99import { SequencerInbox } from "@arbitrum/sdk/dist/lib/abi/SequencerInbox" ;
1010import { 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 ,
0 commit comments