Skip to content

Commit

Permalink
change add metrics for mt-batcher and mt-challenger
Browse files Browse the repository at this point in the history
  • Loading branch information
guoshijiang committed Jul 6, 2023
1 parent 455094e commit 3d7a265
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bss-core/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ type Base struct {
// tssRollbackSignal indicate tss group force rollback or send signal to rollback l2geth
// due to a fork state root between sequencer and verifier
tssRollbackSignal prometheus.Gauge

// ctcRollupTimeDuration number of sequencer and enqueue rollup time duration
ctcRollupTimeDuration prometheus.Gauge

// sccRollupTimeDuration state root rollup time duration
sccRollupTimeDuration prometheus.Gauge
}

func NewBase(serviceName, subServiceName string) *Base {
Expand Down Expand Up @@ -105,6 +111,16 @@ func NewBase(serviceName, subServiceName string) *Base {
Help: "l2 rollback signal to indicate there is a fork state between sequencer and verifier",
Subsystem: subsystem,
}),
ctcRollupTimeDuration: promauto.NewGauge(prometheus.GaugeOpts{
Name: "ctc_rollup_time_duration",
Help: "",
Subsystem: subsystem,
}),
sccRollupTimeDuration: promauto.NewGauge(prometheus.GaugeOpts{
Name: "scc_rollup_time_duration",
Help: "state root rollup time duration",
Subsystem: subsystem,
}),
}
}

Expand Down Expand Up @@ -166,6 +182,16 @@ func (b *Base) TssRollbackSignal() prometheus.Gauge {
return b.tssRollbackSignal
}

// CtcRollupTimeDuration number of sequencer and enqueue rollup time duration
func (b *Base) CtcRollupTimeDuration() prometheus.Gauge {
return b.ctcRollupTimeDuration
}

// SccRollupTimeDuration state root rollup time duration
func (b *Base) SccRollupTimeDuration() prometheus.Gauge {
return b.sccRollupTimeDuration
}

// MakeSubsystemName builds the subsystem name for a group of metrics, which
// prometheus will use to prefix all metrics in the group. If two non-empty
// strings are provided, they are joined with an underscore. If only one
Expand Down
6 changes: 6 additions & 0 deletions mt-batcher/metrics/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ type MtBatchMetrics interface {
MtBatchNonce() prometheus.Gauge

NumEigenNode() prometheus.Gauge

RollupTimeDuration() prometheus.Gauge

FeeTimeDuration() prometheus.Gauge

CheckerTimeDuration() prometheus.Gauge
}
30 changes: 30 additions & 0 deletions mt-batcher/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type MtBatchBase struct {
mtFeeNonce prometheus.Gauge
mtBatchNonce prometheus.Gauge
numEigenNode prometheus.Gauge
rollupTimeDuration prometheus.Gauge
checkerTimeDuration prometheus.Gauge
feeTimeDuration prometheus.Gauge
}

func NewMtBatchBase() *MtBatchBase {
Expand Down Expand Up @@ -92,6 +95,21 @@ func NewMtBatchBase() *MtBatchBase {
Help: "total eigen layer nodes",
Subsystem: "mtbatcher",
}),
rollupTimeDuration: promauto.NewGauge(prometheus.GaugeOpts{
Name: "rollup_time_duration",
Help: "time duration for da rollup",
Subsystem: "mtbatcher",
}),
checkerTimeDuration: promauto.NewGauge(prometheus.GaugeOpts{
Name: "checker_time_duration",
Help: "time duration for data checker re rollup",
Subsystem: "mtbatcher",
}),
feeTimeDuration: promauto.NewGauge(prometheus.GaugeOpts{
Name: "fee_time_duration",
Help: "time duration for fee submitter",
Subsystem: "mtbatcher",
}),
}
}

Expand Down Expand Up @@ -142,3 +160,15 @@ func (mbb *MtBatchBase) MtBatchNonce() prometheus.Gauge {
func (mbb *MtBatchBase) NumEigenNode() prometheus.Gauge {
return mbb.numEigenNode
}

func (mbb *MtBatchBase) RollupTimeDuration() prometheus.Gauge {
return mbb.rollupTimeDuration
}

func (mbb *MtBatchBase) FeeTimeDuration() prometheus.Gauge {
return mbb.feeTimeDuration
}

func (mbb *MtBatchBase) CheckerTimeDuration() prometheus.Gauge {
return mbb.checkerTimeDuration
}
3 changes: 3 additions & 0 deletions mt-batcher/services/sequencer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,17 +698,20 @@ func (d *Driver) IsMaxPriorityFeePerGasNotFoundError(err error) bool {
func (d *Driver) Start() error {
d.wg.Add(1)
go d.RollupMainWorker()
d.Cfg.Metrics.RollupTimeDuration().Set(float64(d.Cfg.MainWorkerPollInterval))
if d.Cfg.CheckerEnable {
batchIndex, ok := d.LevelDBStore.GetReRollupBatchIndex()
log.Info("get latest batch index", "batchIndex", batchIndex, "ok", ok)
if batchIndex == 0 || !ok {
d.LevelDBStore.SetReRollupBatchIndex(1)
}
d.wg.Add(1)
d.Cfg.Metrics.RollupTimeDuration().Set(float64(d.Cfg.CheckerWorkerPollInterval))
go d.CheckConfirmedWorker()
}
if d.Cfg.FeeModelEnable {
d.wg.Add(1)
d.Cfg.Metrics.RollupTimeDuration().Set(float64(d.Cfg.FeeWorkerPollInterval))
go d.RollUpFeeWorker()
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions mt-challenger/metrics/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ type ChallengerMetrics interface {
ReRollupBatchIndex() prometheus.Gauge

CheckBatchIndex() prometheus.Gauge

DataStoreId() prometheus.Gauge
}
10 changes: 10 additions & 0 deletions mt-challenger/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ChallengerBase struct {
nonceETH prometheus.Gauge
reRollupBatchIndex prometheus.Gauge
checkBatchIndex prometheus.Gauge
dataStoreId prometheus.Gauge
}

func NewChallengerBase() *ChallengerBase {
Expand Down Expand Up @@ -37,6 +38,11 @@ func NewChallengerBase() *ChallengerBase {
Help: "checker batch index for eigen layer",
Subsystem: "challenger",
}),
dataStoreId: promauto.NewGauge(prometheus.GaugeOpts{
Name: "data_store_id",
Help: "current rollup da data_store_id",
Subsystem: "mtbatcher",
}),
}
}

Expand All @@ -55,3 +61,7 @@ func (cb *ChallengerBase) ReRollupBatchIndex() prometheus.Gauge {
func (cb *ChallengerBase) CheckBatchIndex() prometheus.Gauge {
return cb.checkBatchIndex
}

func (cb *ChallengerBase) DataStoreId() prometheus.Gauge {
return cb.dataStoreId
}

0 comments on commit 3d7a265

Please sign in to comment.