Skip to content

Commit 8ecaeec

Browse files
jonastheisThegaram
andauthored
feat(l1 follower): add periodic logs for L1 follower mode sync progress (#1110)
* add periodic logs for L1 follower mode sync progress * print full hex string * bump version --------- Co-authored-by: Péter Garamvölgyi <[email protected]>
1 parent d2f19ff commit 8ecaeec

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 2 // Patch version component of the current release
27+
VersionPatch = 3 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

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/da_syncer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (s *DASyncer) SyncOneBlock(block *da.PartialBlock) error {
4646
}
4747

4848
if s.blockchain.CurrentBlock().Number().Uint64()%1000 == 0 {
49-
log.Info("L1 sync progress", "blockchain height", s.blockchain.CurrentBlock().Number().Uint64(), "block hash", s.blockchain.CurrentBlock().Hash(), "root", s.blockchain.CurrentBlock().Root())
49+
log.Info("L1 sync progress", "blockchain height", s.blockchain.CurrentBlock().Number().Uint64(), "block hash", s.blockchain.CurrentBlock().Hash().Hex(), "root", s.blockchain.CurrentBlock().Root().Hex())
5050
}
5151

5252
return 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().Hex())
165+
} else {
166+
log.Info("L1 sync progress", "blockchain height", currentBlock.Number().Uint64(), "block hash", currentBlock.Hash().Hex())
167+
}
155168
case <-delayedStepCh:
156169
delayedStepCh = nil
157170
reqStep(false)

0 commit comments

Comments
 (0)