aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Verkindt <benoit.verkindt@gmail.com>2017-12-06 23:42:16 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-12-06 23:42:16 +0800
commiteab2201f808bbe1ef08a504f86cf41dd03aa979c (patch)
treefe56296ef420ad1b7061f05514caf155b35dcd31
parente85b68ef53e80eb66c7ab394c57e9eb146a60b91 (diff)
downloaddexon-eab2201f808bbe1ef08a504f86cf41dd03aa979c.tar
dexon-eab2201f808bbe1ef08a504f86cf41dd03aa979c.tar.gz
dexon-eab2201f808bbe1ef08a504f86cf41dd03aa979c.tar.bz2
dexon-eab2201f808bbe1ef08a504f86cf41dd03aa979c.tar.lz
dexon-eab2201f808bbe1ef08a504f86cf41dd03aa979c.tar.xz
dexon-eab2201f808bbe1ef08a504f86cf41dd03aa979c.tar.zst
dexon-eab2201f808bbe1ef08a504f86cf41dd03aa979c.zip
eth: return rlp-decoded values from debug_storageRangeAt (#15476)
Fixes #15196
-rw-r--r--eth/api.go12
-rw-r--r--eth/api_test.go5
2 files changed, 12 insertions, 5 deletions
diff --git a/eth/api.go b/eth/api.go
index 12448a6a1..a907c3649 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -615,14 +615,18 @@ func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common
if st == nil {
return StorageRangeResult{}, fmt.Errorf("account %x doesn't exist", contractAddress)
}
- return storageRangeAt(st, keyStart, maxResult), nil
+ return storageRangeAt(st, keyStart, maxResult)
}
-func storageRangeAt(st state.Trie, start []byte, maxResult int) StorageRangeResult {
+func storageRangeAt(st state.Trie, start []byte, maxResult int) (StorageRangeResult, error) {
it := trie.NewIterator(st.NodeIterator(start))
result := StorageRangeResult{Storage: storageMap{}}
for i := 0; i < maxResult && it.Next(); i++ {
- e := storageEntry{Value: common.BytesToHash(it.Value)}
+ _, content, _, err := rlp.Split(it.Value)
+ if err != nil {
+ return StorageRangeResult{}, err
+ }
+ e := storageEntry{Value: common.BytesToHash(content)}
if preimage := st.GetKey(it.Key); preimage != nil {
preimage := common.BytesToHash(preimage)
e.Key = &preimage
@@ -634,7 +638,7 @@ func storageRangeAt(st state.Trie, start []byte, maxResult int) StorageRangeResu
next := common.BytesToHash(it.Key)
result.NextKey = &next
}
- return result
+ return result, nil
}
// GetModifiedAccountsByumber returns all accounts that have changed between the
diff --git a/eth/api_test.go b/eth/api_test.go
index 49ce38688..248bc3ab6 100644
--- a/eth/api_test.go
+++ b/eth/api_test.go
@@ -79,7 +79,10 @@ func TestStorageRangeAt(t *testing.T) {
},
}
for _, test := range tests {
- result := storageRangeAt(state.StorageTrie(addr), test.start, test.limit)
+ result, err := storageRangeAt(state.StorageTrie(addr), test.start, test.limit)
+ if err != nil {
+ t.Error(err)
+ }
if !reflect.DeepEqual(result, test.want) {
t.Fatalf("wrong result for range 0x%x.., limit %d:\ngot %s\nwant %s",
test.start, test.limit, dumper.Sdump(result), dumper.Sdump(&test.want))