From 82fa156b3494d395f6f91aa2448b7c80d1087a0c Mon Sep 17 00:00:00 2001 From: asyukii Date: Tue, 26 Sep 2023 17:49:42 +0800 Subject: [PATCH] core/state, trie: fix bad block --- core/state/state_object.go | 6 +++++- trie/proof.go | 1 - trie/trie.go | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/state/state_object.go b/core/state/state_object.go index d5979ec837..278815c377 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -800,7 +800,11 @@ func (s *stateObject) fetchExpiredFromRemote(prefixKey []byte, key common.Hash, // if no prefix, query from revive trie, got the newest expired info if resolvePath { - _, err := tr.GetStorage(s.address, key.Bytes()) + val, err := tr.GetStorage(s.address, key.Bytes()) + if val != nil { + s.pendingReviveState[string(crypto.Keccak256(key[:]))] = common.BytesToHash(val) + return val, nil + } enErr, ok := err.(*trie.ExpiredNodeError) if !ok { return nil, fmt.Errorf("cannot find expired state from trie, err: %v", err) diff --git a/trie/proof.go b/trie/proof.go index a88ae6eacb..c67b3d6c3b 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -120,7 +120,6 @@ func (t *StateTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error { // it. func (t *Trie) traverseNodes(tn node, prefixKey, suffixKey []byte, nodes *[]node, epoch types.StateEpoch, updateEpoch bool) (node, error) { for len(suffixKey) > 0 && tn != nil { - log.Info("traverseNodes loop", "prefix", common.Bytes2Hex(prefixKey), "suffix", common.Bytes2Hex(suffixKey), "n", tn.fstring("")) switch n := tn.(type) { case *shortNode: if len(suffixKey) >= len(n.Key) && bytes.Equal(n.Key, suffixKey[:len(n.Key)]) { diff --git a/trie/trie.go b/trie/trie.go index 27ff3134f4..0fbb8f69ac 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -1238,8 +1238,8 @@ func (t *Trie) tryRevive(n node, key []byte, targetPrefixKey []byte, nub MPTProo n1 = n1.copy() n1.Val = newnode n1.flags = t.newFlag() - tryUpdateNodeEpoch(nub.n1, t.currentEpoch) - renew, _, err := t.updateChildNodeEpoch(nub.n1, key, pos, t.currentEpoch) + tryUpdateNodeEpoch(n1, t.currentEpoch) + renew, _, err := t.updateChildNodeEpoch(n1, key, pos, t.currentEpoch) if err != nil { return nil, false, fmt.Errorf("update child node epoch while reviving failed, err: %v", err) }