From a638412cb31cc6cb054c1664d8dc4cb9bf3abb1e Mon Sep 17 00:00:00 2001 From: nicholaspai Date: Thu, 5 Dec 2024 15:32:43 -0500 Subject: [PATCH] Refactor blockRangesAreInvalid to internal helper func --- src/dataworker/Dataworker.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/dataworker/Dataworker.ts b/src/dataworker/Dataworker.ts index 5d433748f..573359fad 100644 --- a/src/dataworker/Dataworker.ts +++ b/src/dataworker/Dataworker.ts @@ -311,7 +311,7 @@ export class Dataworker { // Exit early if spoke pool clients don't have early enough event data to satisfy block ranges for the // potential proposal - const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients( + const blockRangesAreInvalid = await this._validateBlockRanges( spokePoolClients, blockRangesForProposal, chainIds, @@ -833,7 +833,7 @@ export class Dataworker { // Exit early if spoke pool clients don't have early enough event data to satisfy block ranges for the // pending proposal. Log an error loudly so that user knows that disputer needs to increase its lookback. - const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients( + const blockRangesAreInvalid = await this._validateBlockRanges( spokePoolClients, blockRangesImpliedByBundleEndBlocks, chainIds, @@ -1067,7 +1067,7 @@ export class Dataworker { ); const mainnetBlockRange = blockNumberRanges[0]; const chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(mainnetBlockRange[0]); - const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients( + const blockRangesAreInvalid = await this._validateBlockRanges( spokePoolClients, blockNumberRanges, chainIds, @@ -2022,7 +2022,7 @@ export class Dataworker { const blockNumberRanges = getImpliedBundleBlockRanges(hubPoolClient, configStoreClient, matchingRootBundle); const mainnetBlockRanges = blockNumberRanges[0]; const chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(mainnetBlockRanges[0]); - const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients( + const blockRangesAreInvalid = await this._validateBlockRanges( spokePoolClients, blockNumberRanges, chainIds, @@ -2445,4 +2445,20 @@ export class Dataworker { this.clients.configStoreClient.getEnabledChains(mainnetBundleStartBlock) ); } + + async _validateBlockRanges( + spokePoolClients: SpokePoolClientsByChain, + blockRanges: number[][], + chainIds: number[], + earliestBlocksInSpokePoolClients: { [chainId: number]: number }, + isV3: boolean + ): Promise> { + return await blockRangesAreInvalidForSpokeClients( + spokePoolClients, + blockRanges, + chainIds, + earliestBlocksInSpokePoolClients, + isV3 + ); + } }