Commit bfeb7fba authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

batch-submitter: add `VALIDATE_TX_BATCH` config

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.
parent c38e4b57
---
'@eth-optimism/batch-submitter': patch
---
Add `VALIDATE_TX_BATCH` config option that can disable batch validation
......@@ -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
......@@ -52,6 +53,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
gasThresholdInGwei: number,
transactionSubmitter: TransactionSubmitter,
blockOffset: number,
validateBatch: boolean,
logger: Logger,
metrics: Metrics,
autoFixBatchOptions: AutoFixBatchOptions = {
......@@ -76,6 +78,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
logger,
metrics
)
this.validateBatch = validateBatch
this.autoFixBatchOptions = autoFixBatchOptions
this.gasThresholdInGwei = gasThresholdInGwei
this.transactionSubmitter = transactionSubmitter
......@@ -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
......
......@@ -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
......@@ -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',
......@@ -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
......
......@@ -242,6 +242,7 @@ describe('BatchSubmitter', () => {
GAS_THRESHOLD_IN_GWEI,
txBatchTxSubmitter,
1,
false,
new Logger({ name: TX_BATCH_SUBMITTER_LOG_TAG }),
testMetrics
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment