diff --git a/trie/trie.go b/trie/trie.go index f8976bd433..d7149b23a5 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -1301,11 +1301,9 @@ func (t *Trie) tryRevive(n node, key []byte, targetPrefixKey []byte, nub MPTProo } if pos == len(targetPrefixKey) { - - // TODO(0xbundler): just revive the path, it may expire or prune by old state - //if !isExpired { - // return nil, false, NewReviveNotExpiredErr(targetPrefixKey[:pos], epoch) - //} + if !t.isExpiredNode(n, targetPrefixKey, epoch, isExpired) { + return nil, false, NewReviveNotExpiredErr(targetPrefixKey[:pos], epoch) + } hn, ok := n.(hashNode) if !ok { return nil, false, fmt.Errorf("not match hashNode stub") @@ -1758,3 +1756,18 @@ func (t *Trie) UpdateRootEpoch(epoch types.StateEpoch) { func (t *Trie) UpdateCurrentEpoch(epoch types.StateEpoch) { t.currentEpoch = epoch } + +// isExpiredNode check if expired or missed, it may prune by old state snap +func (t *Trie) isExpiredNode(n node, targetPrefixKey []byte, epoch types.StateEpoch, expired bool) bool { + if expired { + return true + } + + // check if there miss the trie node + _, err := t.resolve(n, targetPrefixKey, epoch) + if _, ok := err.(*MissingNodeError); ok { + return true + } + + return false +}