@@ -212,12 +212,15 @@ const watch = async () => {
212
212
213
213
const veaEpochOutboxClaimableNowOld = veaEpochOutboxClaimableNow ;
214
214
veaEpochOutboxClaimableNow = Math . floor ( timeGnosis / epochPeriod ) - 1 ;
215
- // TODO: sometimes veaEpochOutboxClaimableNow is 1 epoch behind veaEpochOutboxClaimableNowOld
216
- const veaEpochsOutboxClaimableNew : number [ ] = new Array ( veaEpochOutboxClaimableNow - veaEpochOutboxClaimableNowOld )
217
- . fill ( veaEpochOutboxClaimableNowOld + 1 )
218
- . map ( ( el , i ) => el + i ) ;
219
215
220
- veaEpochOutboxCheckClaimsRangeArray . concat ( veaEpochsOutboxClaimableNew ) ;
216
+ if ( veaEpochOutboxClaimableNow > veaEpochOutboxClaimableNowOld ) {
217
+ const veaEpochsOutboxClaimableNew : number [ ] = new Array (
218
+ veaEpochOutboxClaimableNow - veaEpochOutboxClaimableNowOld
219
+ )
220
+ . fill ( veaEpochOutboxClaimableNowOld + 1 )
221
+ . map ( ( el , i ) => el + i ) ;
222
+ veaEpochOutboxCheckClaimsRangeArray . push ( ...veaEpochsOutboxClaimableNew ) ;
223
+ }
221
224
222
225
if ( veaEpochOutboxCheckClaimsRangeArray . length == 0 ) {
223
226
console . log ( "no claims to check" ) ;
@@ -248,7 +251,7 @@ const watch = async () => {
248
251
) ;
249
252
veaEpochOutboxCheckClaimsRangeArray . splice ( index , 1 ) ;
250
253
index -- ;
251
- if ( challenges . has ( index ) ) challenges . delete ( index ) ;
254
+ if ( challenges . has ( veaEpochOutboxCheck ) ) challenges . delete ( veaEpochOutboxCheck ) ;
252
255
continue ;
253
256
} else {
254
257
console . log (
@@ -320,7 +323,7 @@ const watch = async () => {
320
323
continue ;
321
324
}
322
325
console . log ( veaEpochOutboxCheck , "claim found " , { claim } ) ;
323
- const previousProgress = challenges . get ( index ) || ( { } as any ) ;
326
+ const previousProgress = challenges . get ( veaEpochOutboxCheck ) || ( { } as any ) ;
324
327
let challengeProgress = await reconstructChallengeProgress (
325
328
veaEpochOutboxCheck ,
326
329
veaOutbox ,
@@ -333,7 +336,7 @@ const watch = async () => {
333
336
amb ,
334
337
previousProgress
335
338
) ;
336
- challenges . set ( index , challengeProgress ) ;
339
+ challenges . set ( veaEpochOutboxCheck , challengeProgress ) ;
337
340
console . log (
338
341
"challenge progess for epoch " + veaEpochOutboxCheck + " is " + JSON . stringify ( challengeProgress )
339
342
) ;
@@ -347,6 +350,14 @@ const watch = async () => {
347
350
10
348
351
) ) as ContractTransaction ;
349
352
console . log ( "Epoch " + veaEpochOutboxCheck + " challenged with txn " + txnChallenge . hash ) ;
353
+ challengeProgress . challenge = {
354
+ status : "pending" ,
355
+ txHash : txnChallenge . hash ,
356
+ timestamp : 0 ,
357
+ finalized : false ,
358
+ } ;
359
+ challengeProgress . status = "ChallengePending" ;
360
+ challenges . set ( veaEpochOutboxCheck , challengeProgress ) ;
350
361
continue ;
351
362
}
352
363
if ( claim ?. challenger === watcherAddress ) {
@@ -359,6 +370,14 @@ const watch = async () => {
359
370
10
360
371
) ) as ContractTransaction ;
361
372
console . log ( "Epoch " + veaEpochOutboxCheck + " sendSnapshot called with txn " + txnSendSnapshot . hash ) ;
373
+ challengeProgress . snapshot = {
374
+ status : "pending" ,
375
+ txHash : txnSendSnapshot . hash ,
376
+ timestamp : 0 ,
377
+ finalized : false ,
378
+ } ;
379
+ challengeProgress . status = "SnapshotPending" ;
380
+ challenges . set ( veaEpochOutboxCheck , challengeProgress ) ;
362
381
}
363
382
}
364
383
if (
@@ -389,7 +408,7 @@ const watch = async () => {
389
408
finalized : false ,
390
409
} ;
391
410
challengeProgress . status = "WithdrawalPending" ;
392
- challenges . set ( index , challengeProgress ) ;
411
+ challenges . set ( veaEpochOutboxCheck , challengeProgress ) ;
393
412
}
394
413
}
395
414
}
@@ -567,7 +586,9 @@ const ArbBlockToL1Block = async (
567
586
let latestL2BlockNumberOnEth : number ;
568
587
let result = ( await nodeInterface . functions
569
588
. findBatchContainingBlock ( L2Block . number , { blockTag : "latest" } )
570
- . catch ( ( e ) => { } ) ) as [ BigNumber ] & { batch : BigNumber } ;
589
+ . catch ( ( e ) => {
590
+ console . error ( "Error finding batch containing block:" , JSON . parse ( JSON . stringify ( e ) ) . error . body ) ;
591
+ } ) ) as [ BigNumber ] & { batch : BigNumber } ;
571
592
572
593
if ( ! result ) {
573
594
if ( ! fallbackLatest ) {
@@ -676,7 +697,7 @@ async function getClaimForEpoch(
676
697
challenger : constants . AddressZero ,
677
698
} ;
678
699
let other = { } as any ;
679
- let calculatedHash = await retryOperation ( ( ) => veaOutbox . hashClaim ( claim ) , 1000 , 10 ) ;
700
+ let calculatedHash = hashClaim ( claim ) ;
680
701
if ( calculatedHash == claimHash ) return claim ;
681
702
682
703
// Check for Challenged event
@@ -698,7 +719,7 @@ async function getClaimForEpoch(
698
719
other . challengeBlock = challengedEvents [ 0 ] . blockNumber ;
699
720
}
700
721
701
- calculatedHash = await retryOperation ( ( ) => veaOutbox . hashClaim ( claim ) , 1000 , 10 ) ;
722
+ calculatedHash = hashClaim ( claim ) ;
702
723
if ( calculatedHash == claimHash ) return claim ;
703
724
704
725
// Check for VerificationStarted event
@@ -724,13 +745,11 @@ async function getClaimForEpoch(
724
745
claim . challenger = constants . AddressZero ;
725
746
}
726
747
727
- calculatedHash = await retryOperation ( ( ) => veaOutbox . hashClaim ( claim ) , 1000 , 10 ) ;
748
+ calculatedHash = hashClaim ( claim ) ;
728
749
if ( calculatedHash == claimHash ) return claim ;
729
750
730
- const [ claimBridgerHonest , claimChallengerHonest ] = await Promise . all ( [
731
- retryOperation ( ( ) => veaOutbox . hashClaim ( { ...claim , honest : 1 } ) , 1000 , 10 ) as any ,
732
- retryOperation ( ( ) => veaOutbox . hashClaim ( { ...claim , honest : 2 } ) , 1000 , 10 ) as any ,
733
- ] ) ;
751
+ const claimBridgerHonest = hashClaim ( { ...claim , honest : 1 } ) ;
752
+ const claimChallengerHonest = hashClaim ( { ...claim , honest : 2 } ) ;
734
753
735
754
if ( claimBridgerHonest === claimHash ) return { ...claim , honest : 1 } ;
736
755
if ( claimChallengerHonest === claimHash ) return { ...claim , honest : 2 } ;
@@ -1093,6 +1112,21 @@ async function reconstructChallengeProgress(
1093
1112
return challengeProgress ;
1094
1113
}
1095
1114
1115
+ const hashClaim = ( claim ) => {
1116
+ return ethers . utils . solidityKeccak256 (
1117
+ [ "bytes32" , "address" , "uint32" , "uint32" , "uint32" , "uint8" , "address" ] ,
1118
+ [
1119
+ claim . stateRoot ,
1120
+ claim . claimer ,
1121
+ claim . timestampClaimed ,
1122
+ claim . timestampVerification ,
1123
+ claim . blocknumberVerification ,
1124
+ claim . honest ,
1125
+ claim . challenger ,
1126
+ ]
1127
+ ) ;
1128
+ } ;
1129
+
1096
1130
( async ( ) => {
1097
1131
retryOperation ( ( ) => watch ( ) , 1000 , 10 ) ;
1098
1132
} ) ( ) ;
0 commit comments