From 4598344918ab1a0e592272d78f1ca5a13d732222 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 10 Feb 2020 10:39:18 -0800 Subject: [PATCH] Clear initial sync state caches after round robin sync (#4817) * Clear initial sync state caches after round robin sync * fix test mock * lint Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/blockchain/testing/mock.go | 3 +++ beacon-chain/sync/initial-sync/round_robin.go | 1 + beacon-chain/sync/initial-sync/service.go | 1 + 3 files changed, 5 insertions(+) diff --git a/beacon-chain/blockchain/testing/mock.go b/beacon-chain/blockchain/testing/mock.go index 0ce7f9c44..0d0cb92e9 100644 --- a/beacon-chain/blockchain/testing/mock.go +++ b/beacon-chain/blockchain/testing/mock.go @@ -231,3 +231,6 @@ func (ms *ChainService) Participation(epoch uint64) *precompute.Balance { func (ms *ChainService) IsValidAttestation(ctx context.Context, att *ethpb.Attestation) bool { return ms.ValidAttestation } + +// ClearCachedStates does nothing. +func (ms *ChainService) ClearCachedStates() {} diff --git a/beacon-chain/sync/initial-sync/round_robin.go b/beacon-chain/sync/initial-sync/round_robin.go index 0632ad069..8f7990f99 100644 --- a/beacon-chain/sync/initial-sync/round_robin.go +++ b/beacon-chain/sync/initial-sync/round_robin.go @@ -43,6 +43,7 @@ const refreshTime = 6 * time.Second func (s *Service) roundRobinSync(genesis time.Time) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + defer s.chain.ClearCachedStates() if cfg := featureconfig.Get(); cfg.EnableSkipSlotsCache { cfg.EnableSkipSlotsCache = false diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index 122822ff8..f485fa881 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -25,6 +25,7 @@ var _ = shared.Service(&Service{}) type blockchainService interface { blockchain.BlockReceiver blockchain.HeadFetcher + ClearCachedStates() } const (