Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions op-node/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Metricer interface {
RecordRPCClientRequest(method string) func(err error)
RecordRPCClientResponse(method string, err error)
SetDerivationIdle(status bool)
SetSequencerState(active bool)
RecordPipelineReset()
RecordSequencingError()
RecordPublishingError()
Expand All @@ -48,7 +49,7 @@ type Metricer interface {
RecordL2Ref(name string, ref eth.L2BlockRef)
RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)
RecordDerivedBatches(batchType string)
CountSequencedTxs(count int)
CountSequencedTxsInBlock(txns int, deposits int)
RecordL1ReorgDepth(d uint64)
RecordSequencerInconsistentL1Origin(from eth.BlockID, to eth.BlockID)
RecordSequencerReset()
Expand Down Expand Up @@ -94,6 +95,7 @@ type Metrics struct {
DerivationErrors *metrics.Event
SequencingErrors *metrics.Event
PublishingErrors *metrics.Event
SequencerActive prometheus.Gauge

EmittedEvents *prometheus.CounterVec
ProcessedEvents *prometheus.CounterVec
Expand Down Expand Up @@ -133,7 +135,7 @@ type Metrics struct {

L1ReorgDepth prometheus.Histogram

TransactionsSequencedTotal prometheus.Counter
TransactionsSequencedTotal *prometheus.CounterVec

AltDAMetrics altda.Metricer

Expand Down Expand Up @@ -209,6 +211,11 @@ func NewMetrics(procName string) *Metrics {
DerivationErrors: metrics.NewEvent(factory, ns, "", "derivation_errors", "derivation errors"),
SequencingErrors: metrics.NewEvent(factory, ns, "", "sequencing_errors", "sequencing errors"),
PublishingErrors: metrics.NewEvent(factory, ns, "", "publishing_errors", "p2p publishing errors"),
SequencerActive: factory.NewGauge(prometheus.GaugeOpts{
Namespace: ns,
Name: "sequencer_active",
Help: "1 if sequencer active, 0 otherwise",
}),

EmittedEvents: factory.NewCounterVec(
prometheus.CounterOpts{
Expand Down Expand Up @@ -261,12 +268,11 @@ func NewMetrics(procName string) *Metrics {
Help: "Histogram of L1 Reorg Depths",
}),

TransactionsSequencedTotal: factory.NewGauge(prometheus.GaugeOpts{
TransactionsSequencedTotal: factory.NewCounterVec(prometheus.CounterOpts{
Namespace: ns,
Name: "transactions_sequenced_total",
Help: "Count of total transactions sequenced",
}),

}, []string{"type"}),
PeerCount: factory.NewGauge(prometheus.GaugeOpts{
Namespace: ns,
Subsystem: "p2p",
Expand Down Expand Up @@ -470,6 +476,14 @@ func (m *Metrics) SetDerivationIdle(status bool) {
m.DerivationIdle.Set(val)
}

func (m *Metrics) SetSequencerState(active bool) {
var val float64
if active {
val = 1
}
m.SequencerActive.Set(val)
}

func (m *Metrics) RecordPipelineReset() {
m.PipelineResets.Record()
}
Expand Down Expand Up @@ -516,8 +530,9 @@ func (m *Metrics) RecordDerivedBatches(batchType string) {
m.DerivedBatches.Record(batchType)
}

func (m *Metrics) CountSequencedTxs(count int) {
m.TransactionsSequencedTotal.Add(float64(count))
func (m *Metrics) CountSequencedTxsInBlock(txns int, deposits int) {
m.TransactionsSequencedTotal.WithLabelValues("deposits").Add(float64(deposits))
m.TransactionsSequencedTotal.WithLabelValues("txns").Add(float64(txns - deposits))
}

func (m *Metrics) RecordL1ReorgDepth(d uint64) {
Expand Down Expand Up @@ -686,6 +701,9 @@ func (n *noopMetricer) RecordUp() {
func (n *noopMetricer) SetDerivationIdle(status bool) {
}

func (m *noopMetricer) SetSequencerState(active bool) {
}

func (n *noopMetricer) RecordPipelineReset() {
}

Expand Down Expand Up @@ -725,7 +743,7 @@ func (n *noopMetricer) RecordUnsafePayloadsBuffer(length uint64, memSize uint64,
func (n *noopMetricer) RecordDerivedBatches(batchType string) {
}

func (n *noopMetricer) CountSequencedTxs(count int) {
func (n *noopMetricer) CountSequencedTxsInBlock(txns int, deposits int) {
}

func (n *noopMetricer) RecordL1ReorgDepth(d uint64) {
Expand Down
1 change: 1 addition & 0 deletions op-node/node/config_persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (p *ActiveConfigPersistence) SequencerStopped() error {
func (p *ActiveConfigPersistence) persist(sequencerStarted bool) error {
p.lock.Lock()
defer p.lock.Unlock()

data, err := json.Marshal(persistedState{SequencerStarted: &sequencerStarted})
if err != nil {
return fmt.Errorf("marshall new config: %w", err)
Expand Down
1 change: 1 addition & 0 deletions op-node/rollup/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Metrics interface {
RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)

SetDerivationIdle(idle bool)
SetSequencerState(active bool)

RecordL1ReorgDepth(d uint64)

Expand Down
5 changes: 3 additions & 2 deletions op-node/rollup/engine/build_seal.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) {
eq.metrics.RecordSequencerBuildingDiffTime(buildTime - time.Duration(eq.cfg.BlockTime)*time.Second)

txnCount := len(envelope.ExecutionPayload.Transactions)
eq.metrics.CountSequencedTxs(txnCount)
depositCount, _ := lastDeposit(envelope.ExecutionPayload.Transactions)
eq.metrics.CountSequencedTxsInBlock(txnCount, depositCount)

eq.log.Debug("Processed new L2 block", "l2_unsafe", ref, "l1_origin", ref.L1Origin,
"txs", txnCount, "time", ref.Time, "seal_time", sealTime, "build_time", buildTime)
"txs", txnCount, "deposits", depositCount, "time", ref.Time, "seal_time", sealTime, "build_time", buildTime)

eq.emitter.Emit(BuildSealedEvent{
Concluding: ev.Concluding,
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/engine/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

type Metrics interface {
CountSequencedTxs(count int)
CountSequencedTxsInBlock(txns int, deposits int)

RecordSequencerBuildingDiffTime(duration time.Duration)
RecordSequencerSealingTime(duration time.Duration)
Expand Down
4 changes: 4 additions & 0 deletions op-node/rollup/sequencing/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type L1OriginSelectorIface interface {
}

type Metrics interface {
SetSequencerState(active bool)
RecordSequencerInconsistentL1Origin(from eth.BlockID, to eth.BlockID)
RecordSequencerReset()
RecordSequencingError()
Expand Down Expand Up @@ -619,6 +620,7 @@ func (d *Sequencer) Init(ctx context.Context, active bool) error {
if active {
return d.forceStart()
} else {
d.metrics.SetSequencerState(false)
if err := d.listener.SequencerStopped(); err != nil {
return fmt.Errorf("failed to notify sequencer-state listener of initial stopped state: %w", err)
}
Expand Down Expand Up @@ -652,6 +654,7 @@ func (d *Sequencer) forceStart() error {
d.nextActionOK = true
d.nextAction = d.timeNow()
d.active.Store(true)
d.metrics.SetSequencerState(true)
d.log.Info("Sequencer has been started", "next action", d.nextAction)
return nil
}
Expand Down Expand Up @@ -697,6 +700,7 @@ func (d *Sequencer) Stop(ctx context.Context) (common.Hash, error) {

d.nextActionOK = false
d.active.Store(false)
d.metrics.SetSequencerState(false)
d.log.Info("Sequencer has been stopped")
return d.latestHead.Hash, nil
}
Expand Down
2 changes: 1 addition & 1 deletion op-service/testutils/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type TestDerivationMetrics struct {
FnRecordChannelTimedOut func()
}

func (t *TestDerivationMetrics) CountSequencedTxs(count int) {
func (t *TestDerivationMetrics) CountSequencedTxsInBlock(txns int, deposits int) {
}

func (t *TestDerivationMetrics) RecordSequencerBuildingDiffTime(duration time.Duration) {
Expand Down