@@ -17,6 +17,7 @@ import (
17
17
"github.com/scroll-tech/go-ethereum/core/rawdb"
18
18
"github.com/scroll-tech/go-ethereum/ethdb"
19
19
"github.com/scroll-tech/go-ethereum/log"
20
+ "github.com/scroll-tech/go-ethereum/metrics"
20
21
"github.com/scroll-tech/go-ethereum/node"
21
22
"github.com/scroll-tech/go-ethereum/params"
22
23
"github.com/scroll-tech/go-ethereum/rollup/da_syncer"
@@ -43,7 +44,10 @@ const (
43
44
defaultLogInterval = 5 * time .Minute
44
45
)
45
46
46
- var ErrShouldResetSyncHeight = errors .New ("ErrShouldResetSyncHeight" )
47
+ var (
48
+ finalizedBlockGauge = metrics .NewRegisteredGauge ("chain/head/finalized" , nil )
49
+ ErrShouldResetSyncHeight = errors .New ("ErrShouldResetSyncHeight" )
50
+ )
47
51
48
52
// RollupSyncService collects ScrollChain batch commit/revert/finalize events and stores metadata into db.
49
53
type RollupSyncService struct {
@@ -135,6 +139,13 @@ func (s *RollupSyncService) Start() {
135
139
136
140
log .Info ("Starting rollup event sync background service" , "latest processed block" , s .callDataBlobSource .L1Height ())
137
141
142
+
143
+
144
+ finalizedBlockHeightPtr := rawdb .ReadFinalizedL2BlockNumber (s .db )
145
+ if finalizedBlockHeightPtr != nil {
146
+ finalizedBlockGauge .Update (int64 (* finalizedBlockHeightPtr ))
147
+ }
148
+
138
149
go func () {
139
150
syncTicker := time .NewTicker (defaultSyncInterval )
140
151
defer syncTicker .Stop ()
@@ -321,6 +332,7 @@ func (s *RollupSyncService) updateRollupEvents(daEntries da.Entries) error {
321
332
return fmt .Errorf ("failed to batch write finalized batch meta to database: %w" , err )
322
333
}
323
334
rawdb .WriteFinalizedL2BlockNumber (s .db , highestFinalizedBlockNumber )
335
+ finalizedBlockGauge .Update (int64 (highestFinalizedBlockNumber ))
324
336
rawdb .WriteLastFinalizedBatchIndex (s .db , batchIndex )
325
337
log .Debug ("write finalized l2 block number" , "batch index" , batchIndex , "finalized l2 block height" , highestFinalizedBlockNumber )
326
338
0 commit comments