Skip to content

Commit

Permalink
Merge branch 'develop' into annie/sync-test-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
annieke authored Jun 15, 2021
2 parents fce3129 + 52d02b1 commit fa3eb10
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/olive-planets-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/batch-submitter': patch
---

Add failure metrics to batch submitter
22 changes: 21 additions & 1 deletion packages/batch-submitter/src/batch-submitter/batch-submitter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* External Imports */
import { Contract, Signer, utils, providers } from 'ethers'
import { TransactionReceipt } from '@ethersproject/abstract-provider'
import { Gauge, Histogram } from 'prom-client'
import { Gauge, Histogram, Counter } from 'prom-client'
import * as ynatm from '@eth-optimism/ynatm'
import { RollupInfo } from '@eth-optimism/core-utils'
import { Logger, Metrics } from '@eth-optimism/common-ts'
Expand All @@ -24,6 +24,9 @@ interface BatchSubmitterMetrics {
numTxPerBatch: Histogram<string>
submissionTimestamp: Histogram<string>
submissionGasUsed: Histogram<string>
batchesSubmitted: Counter<string>
failedSubmissions: Counter<string>
malformedBatches: Counter<string>
}

export abstract class BatchSubmitter {
Expand Down Expand Up @@ -240,6 +243,7 @@ export abstract class BatchSubmitter {
this.logger
)
} catch (err) {
this.metrics.failedSubmissions.inc()
if (err.reason) {
this.logger.error(`Transaction invalid: ${err.reason}, aborting`, {
message: err.toString(),
Expand All @@ -259,6 +263,7 @@ export abstract class BatchSubmitter {

this.logger.info('Received transaction receipt', { receipt })
this.logger.info(successMessage)
this.metrics.batchesSubmitted.inc()
this.metrics.submissionGasUsed.observe(receipt.gasUsed.toNumber())
this.metrics.submissionTimestamp.observe(Date.now())
return receipt
Expand Down Expand Up @@ -293,6 +298,21 @@ export abstract class BatchSubmitter {
help: 'Gas used to submit each batch',
registers: [metrics.registry],
}),
batchesSubmitted: new metrics.client.Counter({
name: 'batches_submitted',
help: 'Count of batches submitted',
registers: [metrics.registry],
}),
failedSubmissions: new metrics.client.Counter({
name: 'failed_submissions',
help: 'Count of failed batch submissions',
registers: [metrics.registry],
}),
malformedBatches: new metrics.client.Counter({
name: 'malformed_batches',
help: 'Count of malformed batches',
registers: [metrics.registry],
}),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
// Fix our batches if we are configured to. TODO: Remove this.
batch = await this._fixBatch(batch)
if (!(await this._validateBatch(batch))) {
this.metrics.malformedBatches.inc()
return
}
let sequencerBatchParams = await this._getSequencerBatchParams(
Expand Down

0 comments on commit fa3eb10

Please sign in to comment.