From 378e60f86d834fba4bced1f3496cd310cbcef52b Mon Sep 17 00:00:00 2001 From: Peter Argue <89119817+peterargue@users.noreply.github.com> Date: Thu, 17 Oct 2024 08:28:42 -0700 Subject: [PATCH] add check that backfill start height is after init height --- bootstrap/bootstrap.go | 13 +++++++++++++ services/traces/engine.go | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 478f86a95..dbed6f484 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -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() diff --git a/services/traces/engine.go b/services/traces/engine.go index 1cbc99192..a76830c01 100644 --- a/services/traces/engine.go +++ b/services/traces/engine.go @@ -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(): @@ -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 { @@ -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") }