@@ -86,6 +86,7 @@ const secondsPerSlotGnosis = 5;
8686const veaOutboxAddress = process . env . VEAOUTBOX_ARB_TO_GNOSIS_ADDRESS ;
8787const veaInboxAddress = process . env . VEAINBOX_ARB_TO_GNOSIS_ADDRESS ;
8888const veaRouterAddress = process . env . VEAROUTER_ARB_TO_GNOSIS_ADDRESS ;
89+ const gnosisAMBAddress = process . env . GNOSIS_AMB_ADDRESS ;
8990
9091const challenges = new Map < number , ChallengeProgress > ( ) ;
9192
@@ -101,7 +102,7 @@ const watch = async () => {
101102 const veaOutbox = getVeaOutboxArbToGnosisProvider ( veaOutboxAddress , process . env . PRIVATE_KEY , providerGnosis ) ;
102103 const veaInbox = getVeaInboxArbToGnosisProvider ( veaInboxAddress , process . env . PRIVATE_KEY , providerArb ) ;
103104 const veaRouter = getVeaRouterArbToGnosisProvider ( veaRouterAddress , process . env . PRIVATE_KEY , providerEth ) ;
104- const amb = getAMBProvider ( process . env . PRIVATE_KEY , providerGnosis ) ;
105+ const amb = getAMBProvider ( gnosisAMBAddress , process . env . PRIVATE_KEY , providerGnosis ) ;
105106
106107 const wethAddress = ( await retryOperation ( ( ) => veaOutbox . weth ( ) , 1000 , 10 ) ) as string ;
107108 const weth = getWETHProvider ( wethAddress , process . env . PRIVATE_KEY , providerGnosis ) ;
@@ -932,7 +933,9 @@ async function reconstructChallengeProgress(
932933 retryOperation ( ( ) => providerArb . getBlock ( "latest" ) , 1000 , 10 ) as any ,
933934 ] ) ;
934935
935- const averageArbitrumBlocktime = 0.26 ;
936+ const blockTimeWindow = 100 ; // Calculate average over last 100 blocks
937+ const oldBlock = await providerArb . getBlock ( arbLatest . number - blockTimeWindow ) ;
938+ const averageArbitrumBlocktime = ( arbLatest . timestamp - oldBlock . timestamp ) / blockTimeWindow ;
936939 const estimatedArbBlocks = Math . ceil ( ( arbLatest . timestamp - challengeBlock . timestamp ) / averageArbitrumBlocktime ) ;
937940
938941 const snapshotSentFilter = veaInbox . filters . SnapshotSent ( epoch , null ) ;
0 commit comments