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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changes

- Add `sequencer_blocks_synchronized_total` Prometheus counter metric tracking blocks synced by source (DA/P2P) [#3259](https://github.com/evstack/ev-node/pull/3259)
- Make it easier to override `DefaultMaxBlobSize` by ldflags [#3235](https://github.com/evstack/ev-node/pull/3235)
- Add solo sequencer (simple in memory single sequencer without force inclusion) [#3235](https://github.com/evstack/ev-node/pull/3235)
- Improve reaper to sustain txs burst better [#3236](https://github.com/evstack/ev-node/pull/3236)
Expand Down
11 changes: 9 additions & 2 deletions block/internal/common/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ type EventSource string

const (
// SourceDA indicates the event came from the DA layer
SourceDA EventSource = "DA"
SourceDA EventSource = "da"
// SourceP2P indicates the event came from P2P network
SourceP2P EventSource = "P2P"
SourceP2P EventSource = "p2p"
// SourceRaft indicates the event came from Raft consensus recovery
SourceRaft EventSource = "raft"
)

// AllEventSources returns all possible event sources.
func AllEventSources() []EventSource {
return []EventSource{SourceDA, SourceP2P, SourceRaft}
}

// DAHeightEvent represents a DA event for caching
type DAHeightEvent struct {
Header *types.SignedHeader
Expand Down
25 changes: 25 additions & 0 deletions block/internal/common/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type Metrics struct {
// Forced inclusion metrics
ForcedInclusionTxsInGracePeriod metrics.Gauge // Number of forced inclusion txs currently in grace period
ForcedInclusionTxsMalicious metrics.Counter // Total number of forced inclusion txs marked as malicious

// Syncer metrics
BlocksSynchronized map[EventSource]metrics.Counter // Blocks synchronized by source (P2P or DA)
}

// PrometheusMetrics returns Metrics built using Prometheus client library
Expand All @@ -80,6 +83,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
OperationDuration: make(map[string]metrics.Histogram),
DASubmitterFailures: make(map[DASubmitterFailureReason]metrics.Counter),
DASubmitterLastFailure: make(map[DASubmitterFailureReason]metrics.Gauge),
BlocksSynchronized: make(map[EventSource]metrics.Counter),
}

// Original metrics
Expand Down Expand Up @@ -223,6 +227,19 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
}, labels).With(labelsAndValues...)
}

// Syncer metrics
for _, source := range AllEventSources() {
m.BlocksSynchronized[source] = prometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "blocks_synchronized_total",
Help: "Total number of blocks synchronized by source",
ConstLabels: map[string]string{
"source": string(source),
},
}, labels).With(labelsAndValues...)
}

return m
}

Expand Down Expand Up @@ -251,6 +268,9 @@ func NopMetrics() *Metrics {
// Forced inclusion metrics
ForcedInclusionTxsInGracePeriod: discard.NewGauge(),
ForcedInclusionTxsMalicious: discard.NewCounter(),

// Syncer metrics
BlocksSynchronized: make(map[EventSource]metrics.Counter),
}

// Initialize maps with no-op metrics
Expand All @@ -265,5 +285,10 @@ func NopMetrics() *Metrics {
m.DASubmitterLastFailure[reason] = discard.NewGauge()
}

// Initialize syncer no-op metrics
for _, source := range AllEventSources() {
m.BlocksSynchronized[source] = discard.NewCounter()
}

return m
}
5 changes: 4 additions & 1 deletion block/internal/syncing/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ func (s *Syncer) trySyncNextBlockWithState(ctx context.Context, event *common.DA
// Update in-memory state after successful commit
s.SetLastState(newState)
s.metrics.Height.Set(float64(newState.LastBlockHeight))
if counter, ok := s.metrics.BlocksSynchronized[event.Source]; ok {
counter.Add(1)
}

// Mark as seen
s.cache.SetHeaderSeen(headerHash, header.Height())
Expand Down Expand Up @@ -1226,7 +1229,7 @@ func (s *Syncer) RecoverFromRaft(ctx context.Context, raftState *raft.RaftBlockS
event := &common.DAHeightEvent{
Header: &header,
Data: &data,
Source: "",
Source: common.SourceRaft,
}
err := s.trySyncNextBlockWithState(ctx, event, currentState)
if err != nil {
Expand Down
Loading