Skip to content

Commit 4af30a4

Browse files
committed
add periodic logs for L1 follower mode sync progress
1 parent d2f19ff commit 4af30a4

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

rollup/da_syncer/da/calldata_blob_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (ds *CalldataBlobSource) L1Height() uint64 {
8585
return ds.l1Height
8686
}
8787

88+
func (ds *CalldataBlobSource) L1Finalized() uint64 {
89+
return ds.l1Finalized
90+
}
91+
8892
func (ds *CalldataBlobSource) processRollupEventsToDA(rollupEvents l1.RollupEvents) (Entries, error) {
8993
var entries Entries
9094
var entry Entry

rollup/da_syncer/da_queue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ func (dq *DAQueue) getNextData(ctx context.Context) error {
6969
return err
7070
}
7171

72+
func (dq *DAQueue) DataSource() DataSource {
73+
return dq.dataSource
74+
}
75+
7276
func (dq *DAQueue) Reset(height uint64) {
7377
dq.l1height = height
7478
dq.dataSource = nil

rollup/da_syncer/data_source.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
type DataSource interface {
1515
NextData() (da.Entries, error)
1616
L1Height() uint64
17+
L1Finalized() uint64
1718
}
1819

1920
type DataSourceFactory struct {

rollup/da_syncer/syncing_pipeline.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type SyncingPipeline struct {
3939
blockchain *core.BlockChain
4040
blockQueue *BlockQueue
4141
daSyncer *DASyncer
42+
daQueue *DAQueue
4243
}
4344

4445
func NewSyncingPipeline(ctx context.Context, blockchain *core.BlockChain, genesisConfig *params.ChainConfig, db ethdb.Database, ethClient l1.Client, l1DeploymentBlock uint64, config Config) (*SyncingPipeline, error) {
@@ -92,6 +93,7 @@ func NewSyncingPipeline(ctx context.Context, blockchain *core.BlockChain, genesi
9293
blockchain: blockchain,
9394
blockQueue: blockQueue,
9495
daSyncer: daSyncer,
96+
daQueue: daQueue,
9597
}, nil
9698
}
9799

@@ -115,6 +117,9 @@ func (s *SyncingPipeline) Start() {
115117
}
116118

117119
func (s *SyncingPipeline) mainLoop() {
120+
progressTicker := time.NewTicker(1 * time.Minute)
121+
defer progressTicker.Stop()
122+
118123
stepCh := make(chan struct{}, 1)
119124
var delayedStepCh <-chan time.Time
120125
var resetCounter int
@@ -152,6 +157,14 @@ func (s *SyncingPipeline) mainLoop() {
152157
select {
153158
case <-s.ctx.Done():
154159
return
160+
case <-progressTicker.C:
161+
currentBlock := s.blockchain.CurrentBlock()
162+
dataSource := s.daQueue.DataSource()
163+
if dataSource != nil {
164+
log.Info("L1 sync progress", "L1 processed", dataSource.L1Height(), "L1 finalized", dataSource.L1Finalized(), "progress(%)", float64(dataSource.L1Height())/float64(dataSource.L1Finalized())*100, "L2 height", currentBlock.Number().Uint64(), "L2 hash", currentBlock.Hash())
165+
} else {
166+
log.Info("L1 sync progress", "blockchain height", currentBlock.Number().Uint64(), "block hash", currentBlock.Hash())
167+
}
155168
case <-delayedStepCh:
156169
delayedStepCh = nil
157170
reqStep(false)

0 commit comments

Comments
 (0)