From 11fa4500836e3ab0ceaf4df6893e24298bb01f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Fri, 21 Mar 2025 14:48:07 +0100 Subject: [PATCH] fix: correctly initialize latest l1msg gauge --- core/blockchain.go | 25 ++++++++++++++++--------- params/version.go | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index f3b150c4cb82..2b881ceed235 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -149,6 +149,18 @@ var defaultCacheConfig = &CacheConfig{ SnapshotWait: true, } +func updateHeadL1msgGauge(block *types.Block) { + for _, tx := range block.Transactions() { + if msg := tx.AsL1MessageTx(); msg != nil { + // Queue index is guaranteed to fit into int64. + headL1MessageGauge.Update(int64(msg.QueueIndex)) + } else { + // No more L1 messages in this block. + break + } + } +} + // BlockChain represents the canonical chain given a database with a genesis // block. The Blockchain manages chain imports, reverts, chain reorganisations. // @@ -423,6 +435,9 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par triedb.SaveCachePeriodically(bc.cacheConfig.TrieCleanJournal, bc.cacheConfig.TrieCleanRejournal, bc.quit) }() } + + updateHeadL1msgGauge(bc.CurrentBlock()) + return bc, nil } @@ -1255,15 +1270,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. } // Note the latest relayed L1 message queue index (if any) - for _, tx := range block.Transactions() { - if msg := tx.AsL1MessageTx(); msg != nil { - // Queue index is guaranteed to fit into int64. - headL1MessageGauge.Update(int64(msg.QueueIndex)) - } else { - // No more L1 messages in this block. - break - } - } + updateHeadL1msgGauge(block) parent := bc.GetHeaderByHash(block.ParentHash()) // block.Time is guaranteed to be larger than parent.Time, diff --git a/params/version.go b/params/version.go index d3e1cbbc5057..2a7eb3c12643 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 = 8 // Minor version component of the current release - VersionPatch = 29 // Patch version component of the current release + VersionPatch = 30 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )