btcrelay-fetchd
btcrelay-fetchd copied to clipboard
rpc error returned: invalid argument 0: hex string has odd length
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"
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.
@ethers After I had fixed param issue, I have stuck into another problem: Empty BlockchainHead returnedEmpty BlockchainHead returned
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
Thank you to @achempion for https://github.com/ConsenSys/btcrelay-fetchd/pull/14