fix encoding when storage is empty #94

Merged
n0cte merged 14 commits from empty_data_encoder into master 2021-09-28 05:17:43 +00:00
2 changed files with 6 additions and 0 deletions
Showing only changes of commit 70c539c8d7 - Show all commits

View File

@ -709,6 +709,9 @@ 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) { 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) storageVal, err := pea.B.GetStorageByNumberOrHash(ctx, address, common.HexToHash(key), blockNrOrHash)
if storageVal != nil && err == nil { if storageVal != nil && err == nil {
if len(storageVal) == 0 {
return make([]byte, 32), nil
}
var value common.Hash var value common.Hash
_, content, _, err := rlp.Split(storageVal) _, content, _, err := rlp.Split(storageVal)
if err == io.ErrUnexpectedEOF { if err == io.ErrUnexpectedEOF {

View File

@ -1010,6 +1010,9 @@ func (r *Resolver) GetStorageAt(ctx context.Context, args struct {
return nil, err return nil, err
} }
if len(rlpValue) == 0 {
return &StorageResult{value: make([]byte, 32), cid: cid, ipldBlock: ipldBlock}, nil
}
var value interface{} var value interface{}
err = rlp.DecodeBytes(rlpValue, &value) err = rlp.DecodeBytes(rlpValue, &value)