Skip to content

Commit

Permalink
batch-submitter: add VALIDATE_TX_BATCH config
Browse files Browse the repository at this point in the history
Add a new config option to the batch submitter that can enable
or disable the transaction batch validation. This can be configured
using `VALIDATE_TX_BATCH` or `BATCH_SUBMITTER_VALIDATE_TX_BATCH`
or `--validate-tx-batch`. It defaults to true.
  • Loading branch information
tynes committed Oct 21, 2021
1 parent c80d411 commit 2b666ad
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-suits-rest.md
@@ -0,0 +1,5 @@
---
'@eth-optimism/batch-submitter': patch
---

Add `VALIDATE_TX_BATCH` config option that can disable batch validation
15 changes: 11 additions & 4 deletions packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts
Expand Up @@ -35,6 +35,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
protected l2ChainId: number
protected syncing: boolean
private autoFixBatchOptions: AutoFixBatchOptions
private validateBatch: boolean
private transactionSubmitter: TransactionSubmitter
private gasThresholdInGwei: number

Expand All @@ -52,6 +53,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
gasThresholdInGwei: number,
transactionSubmitter: TransactionSubmitter,
blockOffset: number,
validateBatch: boolean,
logger: Logger,
metrics: Metrics,
autoFixBatchOptions: AutoFixBatchOptions = {
Expand All @@ -76,6 +78,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
logger,
metrics
)
this.validateBatch = validateBatch
this.autoFixBatchOptions = autoFixBatchOptions
this.gasThresholdInGwei = gasThresholdInGwei
this.transactionSubmitter = transactionSubmitter
Expand Down Expand Up @@ -260,12 +263,16 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
{ concurrency: 100 }
)

// Fix our batches if we are configured to. TODO: Remove this.
// Fix our batches if we are configured to. This will not
// modify the batch unless an autoFixBatchOption is set
batch = await this._fixBatch(batch)
if (!(await this._validateBatch(batch))) {
this.metrics.malformedBatches.inc()
return
if (this.validateBatch) {
if (!(await this._validateBatch(batch))) {
this.metrics.malformedBatches.inc()
return
}
}

let sequencerBatchParams = await this._getSequencerBatchParams(
startBlock,
batch
Expand Down
7 changes: 7 additions & 0 deletions packages/batch-submitter/src/exec/run-batch-submitter.ts
Expand Up @@ -72,6 +72,7 @@ interface RequiredEnvVars {
* SEQUENCER_HD_PATH
* PROPOSER_HD_PATH
* BLOCK_OFFSET
* VALIDATE_TX_BATCH
* USE_HARDHAT
* DEBUG_IMPERSONATE_SEQUENCER_ADDRESS
* DEBUG_IMPERSONATE_PROPOSER_ADDRESS
Expand Down Expand Up @@ -244,6 +245,11 @@ export const run = async () => {
env.PROPOSER_HD_PATH || env.HD_PATH
)

const VALIDATE_TX_BATCH = config.bool(
'validate-tx-batch',
env.VALIDATE_TX_BATCH ? !!env.VALIDATE_TX_BATCH : true
)

// Auto fix batch options -- TODO: Remove this very hacky config
const AUTO_FIX_BATCH_OPTIONS_CONF = config.str(
'auto-fix-batch-conf',
Expand Down Expand Up @@ -387,6 +393,7 @@ export const run = async () => {
GAS_THRESHOLD_IN_GWEI,
txBatchTxSubmitter,
BLOCK_OFFSET,
VALIDATE_TX_BATCH,
logger.child({ name: TX_BATCH_SUBMITTER_LOG_TAG }),
metrics,
autoFixBatchOptions
Expand Down
Expand Up @@ -242,6 +242,7 @@ describe('BatchSubmitter', () => {
GAS_THRESHOLD_IN_GWEI,
txBatchTxSubmitter,
1,
false,
new Logger({ name: TX_BATCH_SUBMITTER_LOG_TAG }),
testMetrics
)
Expand Down

0 comments on commit 2b666ad

Please sign in to comment.