From dc20f3d72b74aa69366297126a6a61efe536acc7 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 13 May 2020 17:10:36 -0700 Subject: [PATCH] Regen historical using `ArchivedPointRoot` then `State` (#5845) * Regen from ArchivedPointRoot and State * Merge branch 'master' into fix-regen-historical-states --- beacon-chain/db/kv/regen_historical_states.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/beacon-chain/db/kv/regen_historical_states.go b/beacon-chain/db/kv/regen_historical_states.go index 27cfcb38c0..5b79564bd4 100644 --- a/beacon-chain/db/kv/regen_historical_states.go +++ b/beacon-chain/db/kv/regen_historical_states.go @@ -43,18 +43,11 @@ func (kv *Store) regenHistoricalStates(ctx context.Context) error { } if lastArchivedIndex > 0 { archivedIndexStart := lastArchivedIndex - 1 - wantedSlotBelow := archivedIndexStart*slotsPerArchivedPoint + 1 - states, err := kv.HighestSlotStatesBelow(ctx, wantedSlotBelow) + archivedRoot := kv.ArchivedPointRoot(ctx, archivedIndexStart) + currentState, err := kv.State(ctx, archivedRoot) if err != nil { return err } - if len(states) == 0 { - return errors.New("states can't be empty") - } - if states[0] == nil { - return errors.New("nil last state") - } - currentState = states[0] startSlot = currentState.Slot() }