forked from cerc-io/plugeth
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:
+4
-1
@@ -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
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user