From a9b4f8b8a0f5650cd4bf48fe9f44c711c63ac2ad Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 30 Apr 2021 12:04:07 +0200 Subject: [PATCH] core/state: log progress during dump --- core/state/dump.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/state/dump.go b/core/state/dump.go index b25da714fd11..2e8e02173ccd 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -19,6 +19,7 @@ package state import ( "encoding/json" "fmt" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -112,11 +113,16 @@ func (d iterativeDump) OnRoot(root common.Hash) { } func (s *StateDB) DumpToCollector(c DumpCollector, excludeCode, excludeStorage, excludeMissingPreimages bool, start []byte, maxResults int) (nextKey []byte) { - missingPreimages := 0 c.OnRoot(s.trie.Hash()) - var count int - it := trie.NewIterator(s.trie.NodeIterator(start)) + var ( + missingPreimages = 0 + count int + it = trie.NewIterator(s.trie.NodeIterator(start)) + logged = time.Now() + startTime = time.Now() + ) + for it.Next() { var data Account if err := rlp.DecodeBytes(it.Value, &data); err != nil { @@ -129,6 +135,12 @@ func (s *StateDB) DumpToCollector(c DumpCollector, excludeCode, excludeStorage, CodeHash: common.Bytes2Hex(data.CodeHash), } addrBytes := s.trie.GetKey(it.Key) + if time.Since(logged) > 10*time.Second { + logged = time.Now() + log.Info("State iteration in progress", + "at", fmt.Sprintf("%x", addrBytes), + "elapsed", common.PrettyDuration(time.Since(startTime))) + } if addrBytes == nil { // Preimage missing missingPreimages++