Skip to content
1 change: 1 addition & 0 deletions op-batcher/batcher/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (c *channel) TxFailed(id string, failoverToEthDA bool) {
// TODO: figure out how to switch to blobs/auto instead. Might need to make
// batcherService.initChannelConfig function stateless so that we can reuse it.
c.cfg.DaType = DaTypeCalldata
c.metr.RecordFailoverToEthDA()
}
c.metr.RecordBatchTxFailed()
}
Expand Down
2 changes: 2 additions & 0 deletions op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txRef
}
// if Alt DA is enabled we post the txdata to the DA Provider and replace it with the commitment.
l.publishToAltDAAndL1(txdata, queue, receiptsCh, daGroup)
l.Metr.RecordBatchDaType(txdata.daType.Name())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the publishToAltDAAndL1() spawns a goroutine that in turn calls the sendTx, but only if the AltDA input can be set correctly.
If you call this here, you get a "confirmation" for sending the tx, even though you could have aborted before the send and recorded a "failedDARequest".

I think I would only add one Metr.RecordBatchDaType call in general and rather do that at the end of the sendTx(), but only if the passed in isCancel==false

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezdac You're right. For Alt DA, it recorded regardless of success or failure. Then I updated codes and now it records when handleReceipt is called.

// we return nil to allow publishStateToL1 to keep processing the next txdata
return nil
case DaTypeBlob:
Expand All @@ -884,6 +885,7 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txRef
}

l.sendTx(txdata, false, candidate, queue, receiptsCh)
l.Metr.RecordBatchDaType(txdata.daType.Name())
return nil
}

Expand Down
13 changes: 13 additions & 0 deletions op-batcher/batcher/tx_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ const (
DaTypeAltDA
)

func (t DaType) Name() string {
switch t {
case DaTypeCalldata:
return "calldata"
case DaTypeBlob:
return "blob"
case DaTypeAltDA:
return "altda"
default:
return "unknown"
}
}

// txData represents the data for a single transaction.
//
// Note: The batcher currently sends exactly one frame per transaction. This
Expand Down
26 changes: 26 additions & 0 deletions op-batcher/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type Metricer interface {

RecordBlobUsedBytes(num int)

RecordBatchDaType(daType string)
RecordFailoverToEthDA()

Document() []opmetrics.DocumentedMetric

PendingDABytes() float64
Expand Down Expand Up @@ -89,6 +92,9 @@ type Metrics struct {
channelOutputBytesTotal prometheus.Counter
channelQueueLength prometheus.Gauge

batchSentDATypeTotal prometheus.CounterVec
altDaFailoverTotal prometheus.Counter

batcherTxEvs opmetrics.EventVec

blobUsedBytes prometheus.Histogram
Expand Down Expand Up @@ -198,6 +204,18 @@ func NewMetrics(procName string) *Metrics {
Name: "channel_queue_length",
Help: "The number of channels currently in memory.",
}),
batchSentDATypeTotal: *factory.NewCounterVec(prometheus.CounterOpts{
Namespace: ns,
Name: "batch_sent_da_type_total",
Help: "Total number of batches sent, categorized by DA type",
},
[]string{"da_type"},
),
altDaFailoverTotal: factory.NewCounter(prometheus.CounterOpts{
Namespace: ns,
Name: "alt_da_failover_total",
Help: "Total number of batches that failed to send to AltDA and were instead sent to L1",
}),
blobUsedBytes: factory.NewHistogram(prometheus.HistogramOpts{
Namespace: ns,
Name: "blob_used_bytes",
Expand Down Expand Up @@ -345,6 +363,14 @@ func (m *Metrics) RecordBlobUsedBytes(num int) {
m.blobUsedBytes.Observe(float64(num))
}

func (m *Metrics) RecordBatchDaType(daType string) {
m.batchSentDATypeTotal.With(prometheus.Labels{"da_type": daType}).Inc()
}

func (m *Metrics) RecordFailoverToEthDA() {
m.altDaFailoverTotal.Inc()
}

func (m *Metrics) RecordChannelQueueLength(len int) {
m.channelQueueLength.Set(float64(len))
}
Expand Down
4 changes: 4 additions & 0 deletions op-batcher/metrics/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (*noopMetrics) RecordBatchTxSubmitted() {}
func (*noopMetrics) RecordBatchTxSuccess() {}
func (*noopMetrics) RecordBatchTxFailed() {}
func (*noopMetrics) RecordBlobUsedBytes(int) {}

func (*noopMetrics) RecordBatchDaType(string) {}
func (*noopMetrics) RecordFailoverToEthDA() {}

func (*noopMetrics) StartBalanceMetrics(log.Logger, *ethclient.Client, common.Address) io.Closer {
return nil
}
Expand Down