Skip to content

Commit

Permalink
core/state, trie: fix bad block
Browse files Browse the repository at this point in the history
add TODO
  • Loading branch information
asyukii committed Sep 27, 2023
1 parent 10efce7 commit 062004b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,12 @@ 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())
// TODO(asyukii): temporary fix snap expired, but trie not expire, may investigate more later.
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)
Expand Down
1 change: 0 additions & 1 deletion trie/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)]) {
Expand Down
4 changes: 2 additions & 2 deletions trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 062004b

Please sign in to comment.