From f795e09ecfb0c50a6b2e02380a52514d9c0cab88 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Thu, 22 Feb 2024 10:08:40 +0800 Subject: [PATCH] do not store it (#13637) --- beacon-chain/blockchain/service.go | 5 +++++ beacon-chain/execution/service.go | 7 +++++++ beacon-chain/node/node.go | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/beacon-chain/blockchain/service.go b/beacon-chain/blockchain/service.go index 1e580c683..ec5389693 100644 --- a/beacon-chain/blockchain/service.go +++ b/beacon-chain/blockchain/service.go @@ -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) { diff --git a/beacon-chain/execution/service.go b/beacon-chain/execution/service.go index 68779796c..568156670 100644 --- a/beacon-chain/execution/service.go +++ b/beacon-chain/execution/service.go @@ -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 +} diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index d2acbf8b7..f2400304e 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -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 {