Skip to content

Commit

Permalink
Continue if archival state is not in DB (#5565)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
terencechain authored Apr 21, 2020
1 parent 0f08bd2 commit 480ddb7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/state/stategen/cold.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/state/stategen/cold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
12 changes: 1 addition & 11 deletions beacon-chain/state/stategen/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 480ddb7

Please sign in to comment.