Skip to content

Commit

Permalink
add check that backfill start height is after init height
Browse files Browse the repository at this point in the history
  • Loading branch information
peterargue committed Oct 17, 2024
1 parent 9232c44 commit 378e60f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 13 additions & 0 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ func (b *Bootstrap) StartTraceDownloader(ctx context.Context) error {
return fmt.Errorf("failed to get provided start height %d in db: %w", startHeight, err)
}

cadenceStartHeight, err := b.storages.Blocks.GetCadenceHeight(startHeight)
if err != nil {
return fmt.Errorf("failed to get cadence height for backfill start height %d: %w", startHeight, err)
}

if cadenceStartHeight < b.config.InitCadenceHeight {
b.logger.Warn().
Uint64("evm-start-height", startHeight).
Uint64("cadence-start-height", cadenceStartHeight).
Uint64("init-cadence-height", b.config.InitCadenceHeight).
Msg("backfill start height is before initial cadence height. data may be missing from configured traces bucket")
}

endHeight := b.config.TracesBackfillEndHeight
if endHeight == 0 {
endHeight, err = b.storages.Blocks.LatestEVMHeight()
Expand Down
8 changes: 5 additions & 3 deletions services/traces/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ func (e *Engine) Backfill(start uint64, end uint64) {
return
}

e.logger.Info().Uint64("start", start).Uint64("end", end).Msg("backfilling traces")
lg := e.logger.With().Uint64("start", start).Uint64("end", end).Logger()

lg.Info().Msg("backfilling traces")
for height := start; height <= end; height++ {
select {
case <-e.Done():
Expand All @@ -167,7 +169,7 @@ func (e *Engine) Backfill(start uint64, end uint64) {
default:
}

l := e.logger.With().Uint64("evm-height", height).Logger()
l := lg.With().Uint64("evm-height", height).Logger()

block, err := e.blocks.GetByHeight(height)
if err != nil {
Expand All @@ -187,5 +189,5 @@ func (e *Engine) Backfill(start uint64, end uint64) {

e.indexBlockTraces(block, cadenceID, true)
}
e.logger.Info().Uint64("start", start).Uint64("end", end).Msg("done backfilling traces")
lg.Info().Msg("done backfilling traces")
}

0 comments on commit 378e60f

Please sign in to comment.