core/state: return error when storage trie can't be opened (#26350)

This changes the StorageTrie method to return an error when the trie
is not available. It used to return an 'empty trie' in this case, but that's
not possible anymore under PBSS.
This commit is contained in:
rjl493456442
2022-12-21 10:21:21 +01:00
committed by GitHub
parent b818e73ef3
commit 01808421e2
6 changed files with 97 additions and 41 deletions
+4 -1
View File
@@ -417,7 +417,10 @@ func (api *DebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash,
}
defer release()
st := statedb.StorageTrie(contractAddress)
st, err := statedb.StorageTrie(contractAddress)
if err != nil {
return StorageRangeResult{}, err
}
if st == nil {
return StorageRangeResult{}, fmt.Errorf("account %x doesn't exist", contractAddress)
}
+5 -1
View File
@@ -209,7 +209,11 @@ func TestStorageRangeAt(t *testing.T) {
},
}
for _, test := range tests {
result, err := storageRangeAt(state.StorageTrie(addr), test.start, test.limit)
tr, err := state.StorageTrie(addr)
if err != nil {
t.Error(err)
}
result, err := storageRangeAt(tr, test.start, test.limit)
if err != nil {
t.Error(err)
}