Skip to content

Commit

Permalink
batch-submitter: handle error case explicitly
Browse files Browse the repository at this point in the history
It was possible to return from a function directly
into destructuring an array when the return value
was polymorphic in either being an array or undefined.
The undefined case is handled explicitly now and an
error is thrown with a useful error message instead of
something that would require looking at the source code
and knowing nodejs error types to find out what the
problem was.
  • Loading branch information
tynes authored and smartcontracts committed Nov 10, 2021
1 parent a5807cd commit 71f8de9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-buckets-bow.md
@@ -0,0 +1,5 @@
---
'@eth-optimism/batch-submitter': patch
---

Handle error case more explicity when creating invalid batch
Expand Up @@ -195,8 +195,12 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return
}

const [batchParams, wasBatchTruncated] =
await this._generateSequencerBatchParams(startBlock, endBlock)
const params = await this._generateSequencerBatchParams(startBlock, endBlock)
if (!params) {
throw new Error(`Cannot create sequencer batch with params start ${startBlock} and end ${endBlock}`)
}

const [batchParams, wasBatchTruncated] = params
const batchSizeInBytes = encodeAppendSequencerBatch(batchParams).length / 2
this.logger.debug('Sequencer batch generated', {
batchSizeInBytes,
Expand Down

0 comments on commit 71f8de9

Please sign in to comment.