From 31f517a2a2fb5e36bb9521d3837556d5cafeaff5 Mon Sep 17 00:00:00 2001 From: Liam Horne Date: Mon, 21 Jun 2021 19:56:00 -0400 Subject: [PATCH] refactor: improve logging for batch submission timeout scenarios (#1120) --- .changeset/short-badgers-itch.md | 5 +++++ .../src/batch-submitter/batch-submitter.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/short-badgers-itch.md diff --git a/.changeset/short-badgers-itch.md b/.changeset/short-badgers-itch.md new file mode 100644 index 000000000000..4667285782c7 --- /dev/null +++ b/.changeset/short-badgers-itch.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/batch-submitter': patch +--- + +Improved logging of batch submission timeout logs diff --git a/packages/batch-submitter/src/batch-submitter/batch-submitter.ts b/packages/batch-submitter/src/batch-submitter/batch-submitter.ts index c487d86dfac9..9c82d8212b40 100644 --- a/packages/batch-submitter/src/batch-submitter/batch-submitter.ts +++ b/packages/batch-submitter/src/batch-submitter/batch-submitter.ts @@ -143,15 +143,16 @@ export abstract class BatchSubmitter { protected _shouldSubmitBatch(batchSizeInBytes: number): boolean { const currentTimestamp = Date.now() - const isTimeoutReached = - this.lastBatchSubmissionTimestamp + this.maxBatchSubmissionTime <= - currentTimestamp if (batchSizeInBytes < this.minTxSize) { - if (!isTimeoutReached) { + const timeSinceLastSubmission = + currentTimestamp - this.lastBatchSubmissionTimestamp + if (timeSinceLastSubmission < this.maxBatchSubmissionTime) { this.logger.info( 'Skipping batch submission. Batch too small & max submission timeout not reached.', { batchSizeInBytes, + timeSinceLastSubmission, + maxBatchSubmissionTime: this.maxBatchSubmissionTime, minTxSize: this.minTxSize, lastBatchSubmissionTimestamp: this.lastBatchSubmissionTimestamp, currentTimestamp, @@ -161,6 +162,8 @@ export abstract class BatchSubmitter { } this.logger.info('Timeout reached, proceeding with batch submission.', { batchSizeInBytes, + timeSinceLastSubmission, + maxBatchSubmissionTime: this.maxBatchSubmissionTime, lastBatchSubmissionTimestamp: this.lastBatchSubmissionTimestamp, currentTimestamp, })