From c590fa476ede9c7f405ebbdbf5183fb100b8eb3d Mon Sep 17 00:00:00 2001
From: Giulio rebuffo <giulio.rebuffo@gmail.com>
Date: Sun, 6 Sep 2020 21:57:58 +0200
Subject: [PATCH] Eth get storage at (32 => 256) (#1065)
* added eth_getStorageAt
* used uint32
* now its 256
* incarnation
---
cmd/rpcdaemon/commands/eth_api.go | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/cmd/rpcdaemon/commands/eth_api.go b/cmd/rpcdaemon/commands/eth_api.go
index f6c8b1025c..e83d59e58e 100644
--- a/cmd/rpcdaemon/commands/eth_api.go
+++ b/cmd/rpcdaemon/commands/eth_api.go
@@ -3,7 +3,6 @@ package commands
import (
"context"
"fmt"
- "math/big"
"github.com/ledgerwatch/turbo-geth/eth/filters"
"github.com/ledgerwatch/turbo-geth/turbo/adapter"
@@ -36,7 +35,7 @@ type EthAPI interface {
GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error)
GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error)
GetTransactionByHash(ctx context.Context, hash common.Hash) (map[string]interface{}, error)
- GetStorageAt(ctx context.Context, address common.Address, index *hexutil.Uint64, blockNrOrHash rpc.BlockNumberOrHash) (string, error)
+ GetStorageAt(ctx context.Context, address common.Address, index string, blockNrOrHash rpc.BlockNumberOrHash) (string, error)
}
// APIImpl is implementation of the EthAPI interface based on remote Db access
@@ -142,14 +141,12 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash)
return fields, nil
}
-func (api *APIImpl) GetStorageAt(ctx context.Context, address common.Address, index *hexutil.Uint64, blockNrOrHash rpc.BlockNumberOrHash) (string, error) {
+func (api *APIImpl) GetStorageAt(ctx context.Context, address common.Address, index string, blockNrOrHash rpc.BlockNumberOrHash) (string, error) {
blockNumber, _, err := rpchelper.GetBlockNumber(blockNrOrHash, api.dbReader)
if err != nil {
return "", err
}
- i := uint64(*index)
-
reader := adapter.NewStateReader(api.db, blockNumber)
acc, err := reader.ReadAccountData(address)
if err != nil {
@@ -160,10 +157,9 @@ func (api *APIImpl) GetStorageAt(ctx context.Context, address common.Address, in
return "", fmt.Errorf("account not found")
}
- var location common.Hash
+ location := common.HexToHash(index)
- location.SetBytes(big.NewInt(int64(i)).Bytes())
- res, err := reader.ReadAccountStorage(address, acc.Nonce, &location)
+ res, err := reader.ReadAccountStorage(address, acc.Incarnation, &location)
if err != nil {
return "", err
}
--
GitLab