Skip to content

Commit

Permalink
feat: add miner idle metric (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak authored Sep 5, 2024
1 parent e0203bf commit bdb1ffb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions miner/scroll_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var (
collectL2Timer = metrics.NewRegisteredTimer("miner/collect_l2_txns", nil)
l2CommitTimer = metrics.NewRegisteredTimer("miner/commit", nil)
cccStallTimer = metrics.NewRegisteredTimer("miner/ccc_stall", nil)
idleTimer = metrics.NewRegisteredTimer("miner/idle", nil)

commitReasonCCCCounter = metrics.NewRegisteredCounter("miner/commit_reason_ccc", nil)
commitReasonDeadlineCounter = metrics.NewRegisteredCounter("miner/commit_reason_deadline", nil)
Expand Down Expand Up @@ -354,8 +355,10 @@ func (w *worker) mainLoop() {
w.current = nil
}

idleStart := time.Now()
select {
case <-w.startCh:
idleTimer.UpdateSince(idleStart)
if w.isRunning() {
if err := w.checkHeadRowConsumption(); err != nil {
log.Error("failed to start head checkers", "err", err)
Expand All @@ -364,17 +367,21 @@ func (w *worker) mainLoop() {
}
_, err = w.tryCommitNewWork(time.Now(), w.chain.CurrentHeader().Hash(), nil)
case trigger := <-w.reorgCh:
idleTimer.UpdateSince(idleStart)
err = w.handleReorg(&trigger)
case chainHead := <-w.chainHeadCh:
idleTimer.UpdateSince(idleStart)
if w.isCanonical(chainHead.Block.Header()) {
_, err = w.tryCommitNewWork(time.Now(), chainHead.Block.Hash(), nil)
}
case <-w.current.deadlineCh():
idleTimer.UpdateSince(idleStart)
w.current.deadlineReached = true
if len(w.current.txs) > 0 {
_, err = w.commit(false)
}
case ev := <-w.txsCh:
idleTimer.UpdateSince(idleStart)
// Apply transactions to the pending state
//
// Note all transactions received may not be continuous with transactions
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 7 // Minor version component of the current release
VersionPatch = 8 // Patch version component of the current release
VersionPatch = 9 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

Expand Down

0 comments on commit bdb1ffb

Please sign in to comment.