core/state: add check after Slot

This commit is contained in:
Gary Rong 2023-08-23 16:27:45 +08:00
parent 44fd10aa98
commit ee5b52de5a

View file

@ -1049,13 +1049,13 @@ func (s *StateDB) fastDeleteStorage(addrHash common.Hash, root common.Hash) (boo
size += common.StorageSize(len(path))
})
for iter.Next() {
if iter.Error() != nil {
return false, 0, nil, nil, err
}
if size > storageDeleteLimit {
return true, size, nil, nil, nil
}
slot := common.CopyBytes(iter.Slot())
if iter.Error() != nil { // error might occur after Slot function
return false, 0, nil, nil, err
}
size += common.StorageSize(common.HashLength + len(slot))
slots[iter.Hash()] = slot
@ -1063,6 +1063,9 @@ func (s *StateDB) fastDeleteStorage(addrHash common.Hash, root common.Hash) (boo
return false, 0, nil, nil, err
}
}
if iter.Error() != nil { // error might occur during iteration
return false, 0, nil, nil, err
}
if stack.Hash() != root {
return false, 0, nil, nil, fmt.Errorf("snapshot is not matched, exp %x, got %x", root, stack.Hash())
}