Skip to content

Commit

Permalink
polygon/sync: add sync to tip time measurement info log (#11939)
Browse files Browse the repository at this point in the history
  • Loading branch information
taratorio authored Sep 10, 2024
1 parent 4acd212 commit c409588
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion eth/stagedsync/stage_polygon_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ func (e *polygonSyncStageExecutionEngine) insertBlocks(tx kv.RwTx, blocks []*typ
header := block.Header()
body := block.Body()

e.logger.Debug(e.appendLogPrefix("inserting block"), "blockNum", height, "blockHash", header.Hash())
e.logger.Trace(e.appendLogPrefix("inserting block"), "blockNum", height, "blockHash", header.Hash())

metrics.UpdateBlockConsumerHeaderDownloadDelay(header.Time, height, e.logger)
metrics.UpdateBlockConsumerBodyDownloadDelay(header.Time, height, e.logger)
Expand Down
15 changes: 13 additions & 2 deletions polygon/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/core/types"
Expand Down Expand Up @@ -341,12 +343,13 @@ func (s *Sync) Run(ctx context.Context) error {
}

func (s *Sync) syncToTip(ctx context.Context) (*types.Header, error) {
tip, err := s.execution.CurrentHeader(ctx)
startTime := time.Now()
start, err := s.execution.CurrentHeader(ctx)
if err != nil {
return nil, err
}

tip, err = s.syncToTipUsingCheckpoints(ctx, tip)
tip, err := s.syncToTipUsingCheckpoints(ctx, start)
if err != nil {
return nil, err
}
Expand All @@ -356,6 +359,14 @@ func (s *Sync) syncToTip(ctx context.Context) (*types.Header, error) {
return nil, err
}

blocks := tip.Number.Uint64() - start.Number.Uint64()
s.logger.Info(
syncLogPrefix("sync to tip finished"),
"time", common.PrettyAge(startTime),
"blocks", blocks,
"blk/sec", uint64(float64(blocks)/time.Since(startTime).Seconds()),
)

return tip, nil
}

Expand Down

0 comments on commit c409588

Please sign in to comment.