From 93183937db9b1ed610a11da3b63550e6187aa6ce Mon Sep 17 00:00:00 2001 From: Mitja T Date: Mon, 12 Feb 2024 17:59:05 -0800 Subject: [PATCH] analyzer: fast-sync: fix starting from round 0 --- analyzer/runtime/runtime.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/analyzer/runtime/runtime.go b/analyzer/runtime/runtime.go index 0d9c48883..9da9a9c28 100644 --- a/analyzer/runtime/runtime.go +++ b/analyzer/runtime/runtime.go @@ -109,6 +109,9 @@ func (m *processor) PreWork(ctx context.Context) error { } func (m *processor) UpdateHighTrafficAccounts(ctx context.Context, batch *storage.QueryBatch, height int64) error { + if height < 0 { + panic(fmt.Sprintf("negative height: %d", height)) + } for _, addr := range veryHighTrafficAccounts { balance, err := m.source.GetNativeBalance(ctx, uint64(height), nodeapi.Address(addr)) if err != nil { @@ -129,6 +132,12 @@ func (m *processor) UpdateHighTrafficAccounts(ctx context.Context, batch *storag // Implements block.BlockProcessor interface. func (m *processor) FinalizeFastSync(ctx context.Context, lastFastSyncHeight int64) error { + // Runtimes don't have a genesis document. So if we're starting slow sync at the beginning + // of the chain (round 0), there's no pre-work to do. + if lastFastSyncHeight == -1 { + return nil + } + batch := &storage.QueryBatch{} // Recompute the account stats for all runtime accounts. (During slow-sync, these are dead-reckoned.)