From 6f369d3251eea8fa7c2800e7f46e7eff90f6957f Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 7 Oct 2020 19:33:39 -0700 Subject: [PATCH] rollup-core: better batch submission logic --- .../consumers/canonical-chain-batch-submitter.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/rollup-core/src/app/data/consumers/canonical-chain-batch-submitter.ts b/packages/rollup-core/src/app/data/consumers/canonical-chain-batch-submitter.ts index c740af6be90da..c85289c363681 100644 --- a/packages/rollup-core/src/app/data/consumers/canonical-chain-batch-submitter.ts +++ b/packages/rollup-core/src/app/data/consumers/canonical-chain-batch-submitter.ts @@ -170,7 +170,7 @@ export class CanonicalChainBatchSubmitter extends ScheduledTask { // Returns the most recent block number with a L1 to L2 transaction protected async getBatchSubmissionBlockNumber(): Promise { const results = await Promise.all([ - this.dataService.getMaxL1BlockNumber(), + this.getMaxL1BlockNumber(), this.getMaxL1ToL2QueueBlockNumber(), this.getMaxSafetyQueueBlockNumber(), ]) @@ -183,6 +183,10 @@ export class CanonicalChainBatchSubmitter extends ScheduledTask { } } + if (min === Number.MAX_SAFE_INTEGER) { + throw new Error('Unable to fetch batch submission block number') + } + return min } @@ -491,6 +495,14 @@ export class CanonicalChainBatchSubmitter extends ScheduledTask { ) } + private async getMaxL1BlockNumber(): Promise { + try { + return await this.dataService.getMaxL1BlockNumber() + } catch (e) { + return undefined + } + } + private async catchQueueIsEmptyAndReturnUndefined( func: () => Promise ): Promise {