Skip to content

Commit

Permalink
fix storageAt json-rpc endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ramilexe committed Apr 21, 2021
1 parent 39141bd commit cef4b1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,14 @@ func (pea *PublicEthAPI) localGetBalance(ctx context.Context, address common.Add
func (pea *PublicEthAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) {
storageVal, err := pea.B.GetStorageByNumberOrHash(ctx, address, common.HexToHash(key), blockNrOrHash)
if storageVal != nil && err == nil {
return storageVal, nil
var value common.Hash
_, content, _, err := rlp.Split(storageVal)
if err != nil {
return nil, err
}
value.SetBytes(content)

return value[:], nil
}
if pea.rpc != nil {
var res hexutil.Bytes
Expand Down
1 change: 1 addition & 0 deletions pkg/eth/ipld_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ func (r *IPLDRetriever) RetrieveAccountByAddressAndBlockNumber(address common.Ad
func (r *IPLDRetriever) RetrieveStorageAtByAddressAndStorageKeyAndBlockHash(address common.Address, storageLeafKey, hash common.Hash) (string, []byte, error) {
storageResult := new(nodeInfo)
stateLeafKey := crypto.Keccak256Hash(address.Bytes())
storageLeafKey = crypto.Keccak256Hash(storageLeafKey.Bytes())
if err := r.db.Get(storageResult, RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr, stateLeafKey.Hex(), storageLeafKey.Hex(), hash.Hex()); err != nil {
return "", nil, err
}
Expand Down

0 comments on commit cef4b1d

Please sign in to comment.