From 1d02d04b5dc21768dcfa62b9700d636109c9d5e1 Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Tue, 17 Sep 2024 22:03:15 +0800 Subject: [PATCH] feat(scroll-worker): add nil consumption block metrics (#1033) * feat(scroll-worker): add nil consumption block metrics * increase the version --- miner/scroll_worker.go | 7 +++++++ params/version.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 1a2673a80586..31b093bb9733 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -70,6 +70,9 @@ var ( commitReasonCCCCounter = metrics.NewRegisteredCounter("miner/commit_reason_ccc", nil) commitReasonDeadlineCounter = metrics.NewRegisteredCounter("miner/commit_reason_deadline", nil) commitGasCounter = metrics.NewRegisteredCounter("miner/commit_gas", nil) + + missingRCOnRestartCounter = metrics.NewRegisteredCounter("miner/missing_rc_on_restart", nil) + missingAncestorRCCounter = metrics.NewRegisteredCounter("miner/missing_ancestor_rc", nil) ) // prioritizedTransaction represents a single transaction that @@ -306,6 +309,8 @@ func (w *worker) checkHeadRowConsumption() error { block := w.chain.GetBlockByNumber(curBlockNum) // only spawn CCC checkers for blocks with no row consumption data stored in DB if rawdb.ReadBlockRowConsumption(w.chain.Database(), block.Hash()) == nil { + missingRCOnRestartCounter.Inc(1) + if err := w.asyncChecker.Check(block); err != nil { return err } @@ -870,6 +875,8 @@ func (w *worker) commit(reorging bool) (common.Hash, error) { ancestorHeight := currentHeight - maxReorgDepth ancestorHash := w.chain.GetHeaderByNumber(ancestorHeight).Hash() if rawdb.ReadBlockRowConsumption(w.chain.Database(), ancestorHash) == nil { + missingAncestorRCCounter.Inc(1) + // reject committing to a block if its ancestor doesn't have its RC stored in DB yet. // which may either mean that it failed CCC or it is still in the process of being checked return common.Hash{}, retryableCommitError{inner: errors.New("ancestor doesn't have RC yet")} diff --git a/params/version.go b/params/version.go index 7f4b7c582248..db5ab7081c53 100644 --- a/params/version.go +++ b/params/version.go @@ -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 = 15 // Patch version component of the current release + VersionPatch = 16 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )