rollback on SaveState error (#14555)

* rollback on SaveState error

* add test
This commit is contained in:
Potuz
2024-10-18 12:51:58 -03:00
committed by GitHub
parent 4aa54107e4
commit 6ac8090599
4 changed files with 11 additions and 0 deletions

View File

@@ -404,6 +404,10 @@ func (s *Service) savePostStateInfo(ctx context.Context, r [32]byte, b interface
return errors.Wrapf(err, "could not save block from slot %d", b.Block().Slot())
}
if err := s.cfg.StateGen.SaveState(ctx, r, st); err != nil {
log.Warnf("Rolling back insertion of block with root %#x", r)
if err := s.cfg.BeaconDB.DeleteBlock(ctx, r); err != nil {
log.WithError(err).Errorf("Could not delete block with block root %#x", r)
}
return errors.Wrap(err, "could not save state")
}
return nil