From 7ca4ce0f7936fe1810ee78e59b648096a9d8c91b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 12 Oct 2023 13:37:31 +0300 Subject: [PATCH] core: fix race in stateroot initialization error logging Signed-off-by: Anna Shaleva --- pkg/core/stateroot/module.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/core/stateroot/module.go b/pkg/core/stateroot/module.go index 61b1d54db..a20198744 100644 --- a/pkg/core/stateroot/module.go +++ b/pkg/core/stateroot/module.go @@ -203,8 +203,9 @@ func (s *Module) Init(height uint32) error { // outdated MPT data before state sync process can be started. // Note: this method is aimed to be called for genesis block only, an error is returned otherwise. func (s *Module) CleanStorage() error { - if s.localHeight.Load() != 0 { - return fmt.Errorf("can't clean MPT data for non-genesis block: expected local stateroot height 0, got %d", s.localHeight.Load()) + lH := s.localHeight.Load() + if lH != 0 { + return fmt.Errorf("can't clean MPT data for non-genesis block: expected local stateroot height 0, got %d", lH) } b := storage.NewMemCachedStore(s.Store) s.Store.Seek(storage.SeekRange{Prefix: []byte{byte(storage.DataMPT)}}, func(k, _ []byte) bool {