From 12ceadaa6c242354daa453ef0f6840901358a43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Thu, 20 Mar 2025 13:05:38 +0100 Subject: [PATCH] feat: track latest relayed l1 message (#1150) --- core/blockchain.go | 12 ++++++++++++ params/version.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index aa3d74197f..f3b150c4cb 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -53,6 +53,7 @@ var ( headHeaderGauge = metrics.NewRegisteredGauge("chain/head/header", nil) headFastBlockGauge = metrics.NewRegisteredGauge("chain/head/receipt", nil) headTimeGapGauge = metrics.NewRegisteredGauge("chain/head/timegap", nil) + headL1MessageGauge = metrics.NewRegisteredGauge("chain/head/l1msg", nil) l2BaseFeeGauge = metrics.NewRegisteredGauge("chain/fees/l2basefee", nil) @@ -1253,6 +1254,17 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. l2BaseFeeGauge.Update(0) } + // 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 + } + } + parent := bc.GetHeaderByHash(block.ParentHash()) // block.Time is guaranteed to be larger than parent.Time, // and the time gap should fit into int64. diff --git a/params/version.go b/params/version.go index e90b162754..133999bae3 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 = 26 // Patch version component of the current release + VersionPatch = 27 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )