do not store it (#13637)

This commit is contained in:
Nishant Das 2024-02-22 10:08:40 +08:00 committed by GitHub
parent e6a6365bdd
commit f795e09ecf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions

View File

@ -199,6 +199,7 @@ func NewService(ctx context.Context, opts ...Option) (*Service, error) {
// Start a blockchain service's main event loop.
func (s *Service) Start() {
saved := s.cfg.FinalizedStateAtStartUp
defer s.removeStartupState()
if saved != nil && !saved.IsNil() {
if err := s.StartFromSavedState(saved); err != nil {
@ -550,6 +551,10 @@ func (s *Service) hasBlock(ctx context.Context, root [32]byte) bool {
return s.cfg.BeaconDB.HasBlock(ctx, root)
}
func (s *Service) removeStartupState() {
s.cfg.FinalizedStateAtStartUp = nil
}
func spawnCountdownIfPreGenesis(ctx context.Context, genesisTime time.Time, db db.HeadAccessDatabase) {
currentTime := prysmTime.Now()
if currentTime.After(genesisTime) {

View File

@ -583,6 +583,9 @@ func (s *Service) run(done <-chan struct{}) {
s.runError = nil
s.initPOWService()
// Do not keep storing the finalized state as it is
// no longer of use.
s.removeStartupState()
chainstartTicker := time.NewTicker(logPeriod)
defer chainstartTicker.Stop()
@ -910,3 +913,7 @@ func (s *Service) migrateOldDepositTree(eth1DataInDB *ethpb.ETH1ChainData) error
s.depositTrie = newDepositTrie
return nil
}
func (s *Service) removeStartupState() {
s.cfg.finalizedStateAtStartup = nil
}

View File

@ -326,6 +326,10 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco
}
beacon.collector = c
// Do not store the finalized state as it has been provided to the respective services during
// their initialization.
beacon.finalizedStateAtStartUp = nil
return beacon, nil
}
func initSyncWaiter(ctx context.Context, complete chan struct{}) func() error {