Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

rpc error returned: invalid argument 0: hex string has odd length #13

Open
garzon opened this issue May 5, 2017 · 4 comments
Open

rpc error returned: invalid argument 0: hex string has odd length #13

garzon opened this issue May 5, 2017 · 4 comments

Comments

@garzon
Copy link

garzon commented May 5, 2017

I've changed the logging level to DEBUG and got this. I deployed btcrelay on Ropsten at 0x93bee0a583b828631b91d87ec0539654bf04f4ca

$ python fetchd.py -s 0xc8DFE3B90e6FeEA9b93f88b16daf331da1ADc637 -r 0x93bee0a583b828631b91d87ec0539654bf04f4ca --rpcPort 8545 --fetch --gasPrice 200000000000 --feeVTX 1000 -d
fetchd using PyEPM 1.0.2
feeVTX: 1000
feeRecipient: 0xc8DFE3B90e6FeEA9b93f88b16daf331da1ADc637
ABI prefix: 0x9dd0e81
ABI types: ['']
ABI data: []
ABI encoded: 0x9dd0e81
{"params": [], "jsonrpc": "2.0", "id": "4ee8d8b5-05c3-40fb-b4d4-861422eee260", "method": "eth_gasPrice"}
{u'jsonrpc': u'2.0', u'id': u'4ee8d8b5-05c3-40fb-b4d4-861422eee260', u'result': u'0x4a817c800'}
Got gas price: 0x4a817c800
    Gas price: 0.0200 szabo * 1.0000
    Our price: 20,000,000,000
{"params": [{"from": "0xc8DFE3B90e6FeEA9b93f88b16daf331da1ADc637", "gas": "0x186a0", "value": "0x0", "to": "0x93bee0a583b828631b91d87ec0539654bf04f4ca", "data": "0x9dd0e81", "gasPrice": "0x4a817c800"}, "latest"], "jsonrpc": "2.0", "id": "347b686a-c69d-4bdb-a258-1893de6ee0dc", "method": "eth_call"}
{u'jsonrpc': u'2.0', u'id': u'347b686a-c69d-4bdb-a258-1893de6ee0dc', u'error': {u'message': u'invalid argument 0: hex string has odd length', u'code': -32602}}
code=-32602, message="invalid argument 0: hex string has odd length"
@ethers
Copy link
Contributor

ethers commented May 9, 2017

Thank you, this log is very helpful. First the problem:
getBlockchainHead is being called.
The log says that its signature is 0x9dd0e81. But that hex string is odd length, and the client (Geth) wants 0x09dd0e81 (see the extra 0).

A solution is to add the extra 0 when the hex string is an odd length.
It could be fixed in pyepm
https://github.com/etherex/pyepm/blob/master/pyepm/api.py#L23-L24

(Or possibly in serpent https://github.com/etherex/pyepm/blob/master/pyepm/api.py#L17)

I am not sure at the moment where to fix since pyepm unfortunately has no maintainer.

@achempion
Copy link
Contributor

achempion commented Sep 26, 2017

@ethers After I had fixed param issue, I have stuck into another problem: Empty BlockchainHead returnedEmpty BlockchainHead returned

@achempion
Copy link
Contributor

achempion commented Sep 27, 2017

here is new abi_data method that leads us to the new issue: Empty BlockchainHead returned

def abi_data(sig, data):
    prefix = get_prefix(sig)
    data_abi = hex(prefix).rstrip('L')
    logger.debug("ABI prefix: %s" % data_abi)

    types = sig.split(':')[1][1:-1].split(',')
    logger.debug("ABI types: %s" % types)

    for i, s in enumerate(data):
        if isinstance(data[i], (str, unicode)) and data[i][:2] == "0x":
            data[i] = unhex(data[i])
    logger.debug("ABI data: %s" % data)

    data_abi += abi.encode_abi(types, data).encode('hex')
    logger.debug("ABI encoded: %s" % data_abi)
    # FIX here:
    if len(data_abi) % 2 > 0:
        data_abi = data_abi.replace('0x','0x0')

    return data_abi

@ethers
Copy link
Contributor

ethers commented Nov 2, 2017

Thank you to @achempion for #14

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants