Continue if archival state is not in DB (#5565)

* Continue if archival state is not availble to generate
* Fixed test
* Merge branch 'master' into save-blocks-splitslot
* Merge refs/heads/master into save-blocks-splitslot
This commit is contained in:
terence tsao 2020-04-21 11:18:55 -07:00 committed by GitHub
parent 0f08bd288c
commit 480ddb7c3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 14 deletions

View File

@ -18,7 +18,7 @@ func (s *State) saveColdState(ctx context.Context, blockRoot [32]byte, state *st
defer span.End()
if state.Slot()%s.slotsPerArchivedPoint != 0 {
return errSlotNonArchivedPoint
return nil
}
if err := s.beaconDB.SaveState(ctx, state, blockRoot); err != nil {

View File

@ -25,8 +25,8 @@ func TestSaveColdState_NonArchivedPoint(t *testing.T) {
t.Fatal(err)
}
if err := service.saveColdState(ctx, [32]byte{}, beaconState); err != errSlotNonArchivedPoint {
t.Error("Did not get wanted error")
if err := service.saveColdState(ctx, [32]byte{}, beaconState); err != nil {
t.Error(err)
}
}

View File

@ -56,17 +56,7 @@ func (s *State) MigrateToCold(ctx context.Context, finalizedSlot uint64, finaliz
// Only migrate if current slot is equal to or greater than next archived point slot.
if stateSummary.Slot >= nextArchivedPointSlot {
if !s.beaconDB.HasState(ctx, r) {
recoveredArchivedState, err := s.ComputeStateUpToSlot(ctx, stateSummary.Slot)
if err != nil {
// For whatever reason if node fails to generate archived state of a certain slot,
// a node should just skip that slot rather than fail to whole process block routine.
// Missing an archived point of a certain slot is less of a deal than failing process block.
log.Warnf("Unable to generate archived state: %v", err)
continue
}
if err := s.beaconDB.SaveState(ctx, recoveredArchivedState.Copy(), r); err != nil {
return err
}
continue
}
if err := s.beaconDB.SaveArchivedPointRoot(ctx, r, archivedPointIndex); err != nil {
return err