core/state: skip handleDestruction in hash based mode (#1908)

This commit is contained in:
Nathan 2023-10-08 18:55:30 +08:00 committed by GitHub
parent 44b2f4a787
commit f8439514e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

@ -51,6 +51,9 @@ issues:
- path: core/state/metrics.go - path: core/state/metrics.go
linters: linters:
- unused - unused
- path: core/state/statedb_fuzz_test.go
linters:
- unused
- path: core/txpool/legacypool/list.go - path: core/txpool/legacypool/list.go
linters: linters:
- staticcheck - staticcheck

@ -1422,7 +1422,13 @@ func (s *StateDB) deleteStorage(addr common.Address, addrHash common.Hash, root
// In case (d), **original** account along with its storages should be deleted, // In case (d), **original** account along with its storages should be deleted,
// with their values be tracked as original value. // with their values be tracked as original value.
func (s *StateDB) handleDestruction(nodes *trienode.MergedNodeSet) (map[common.Address]struct{}, error) { func (s *StateDB) handleDestruction(nodes *trienode.MergedNodeSet) (map[common.Address]struct{}, error) {
// Short circuit if geth is running with hash mode. This procedure can consume
// considerable time and storage deletion isn't supported in hash mode, thus
// preemptively avoiding unnecessary expenses.
incomplete := make(map[common.Address]struct{}) incomplete := make(map[common.Address]struct{})
if s.db.TrieDB().Scheme() == rawdb.HashScheme {
return incomplete, nil
}
for addr, prev := range s.stateObjectsDestruct { for addr, prev := range s.stateObjectsDestruct {
// The original account was non-existing, and it's marked as destructed // The original account was non-existing, and it's marked as destructed
// in the scope of block. It can be case (a) or (b). // in the scope of block. It can be case (a) or (b).

@ -365,7 +365,8 @@ func (test *stateTest) verify(root common.Hash, next common.Hash, db *trie.Datab
return nil return nil
} }
func TestStateChanges(t *testing.T) { // TODO(Nathan): enable this case after enabling pbss
func testStateChanges(t *testing.T) {
config := &quick.Config{MaxCount: 1000} config := &quick.Config{MaxCount: 1000}
err := quick.Check((*stateTest).run, config) err := quick.Check((*stateTest).run, config)
if cerr, ok := err.(*quick.CheckError); ok { if cerr, ok := err.(*quick.CheckError); ok {