@@ -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,11 @@ 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
+ finalizedBlockHeightPtr := rawdb .ReadFinalizedL2BlockNumber (s .db )
143
+ if finalizedBlockHeightPtr != nil {
144
+ finalizedBlockGauge .Update (int64 (* finalizedBlockHeightPtr ))
145
+ }
146
+
138
147
go func () {
139
148
syncTicker := time .NewTicker (defaultSyncInterval )
140
149
defer syncTicker .Stop ()
@@ -321,6 +330,7 @@ func (s *RollupSyncService) updateRollupEvents(daEntries da.Entries) error {
321
330
return fmt .Errorf ("failed to batch write finalized batch meta to database: %w" , err )
322
331
}
323
332
rawdb .WriteFinalizedL2BlockNumber (s .db , highestFinalizedBlockNumber )
333
+ finalizedBlockGauge .Update (int64 (highestFinalizedBlockNumber ))
324
334
rawdb .WriteLastFinalizedBatchIndex (s .db , batchIndex )
325
335
log .Debug ("write finalized l2 block number" , "batch index" , batchIndex , "finalized l2 block height" , highestFinalizedBlockNumber )
326
336
0 commit comments