ethereum / web3.py

A python interface for interacting with the Ethereum blockchain and ecosystem.
http://web3py.readthedocs.io
MIT License
5.01k stars 1.71k forks source link

ValueError: \x\y\z "is not in list" #687

Closed cgarvie closed 6 years ago

cgarvie commented 6 years ago

my code:

import web3

w3 = web3.Web3(web3.TestRPCProvider())

w3.eth.defaultAccount = '0xaddress1' # This private key file is saved as ~/.ethereum/keystore/UTC-etc...

w3.eth.sendTransaction({'to':'0xaddress2','gas':21000})

The result:

/usr/local/lib/python2.7/dist-packages/eth_utils/string.py:22: DeprecationWarning: The `force_obj_to_text` function has been deprecated and will be removed in a subsequent release of the eth-utils library. UTF8 cannot encode some byte values in the 0-255 range which makes naive coersion between bytes and text representations impossible without explicitly declared encodings.
  "declared encodings.".format(fn.__name__)
/usr/local/lib/python2.7/dist-packages/eth_utils/string.py:22: DeprecationWarning: The `force_text` function has been deprecated and will be removed in a subsequent release of the eth-utils library. UTF8 cannot encode some byte values in the 0-255 range which makes naive coersion between bytes and text representations impossible without explicitly declared encodings.
  "declared encodings.".format(fn.__name__)
/usr/local/lib/python2.7/dist-packages/eth_utils/formatting.py:20: DeprecationWarning: The `is_prefixed` function has been deprecated and will be removed in a subsequent release of the eth-utils library. Now that eth-utils is compatible with Python3, we encourage developers to use stdlib functions where possible.
  "functions where possible.".format(fn.__name__)
No handlers could be found for logger "jsonrpc.manager"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/web3/eth.py", line 221, in sendTransaction
    [transaction],
  File "/usr/local/lib/python2.7/dist-packages/web3/manager.py", line 96, in request_blocking
    raise ValueError(response["error"])
ValueError: {u'message': u'Server error', u'code': -32000, u'data': {u'message': u"'D\\xc4\\xb4\\x1f\\x02d\\x9d|\\xd2\\xbas\\xf7\\xc9\\x9bG\\xe4\\xb8\\x8e\\x18\\xd8' is not in list", u'args': [u"'D\\xc4\\xb4\\x1f\\x02d\\x9d|\\xd2\\xbas\\xf7\\xc9\\x9bG\\xe4\\xb8\\x8e\\x18\\xd8' is not in list"], u'type': u'ValueError'}}

Any idea how to fix this? Google returns nothing for error 32000, "is not in list", etc...

pipermerriam commented 6 years ago

@cgarvie can you provide an exact version. latest can be a bit ambiguous.

cgarvie commented 6 years ago

I ran pip install web3

root@ubuntu-geth:~# pip show web3
---
Metadata-Version: 2.0
Name: web3
Version: 3.16.5
Summary: Web3.py
Home-page: https://github.com/ethereum/web3.py
Author: Piper Merriam
Author-email: EMAIL@gmail.com
Installer: pip
License: MIT
Location: /usr/local/lib/python2.7/dist-packages
Requires: rlp, eth-tester, requests, pysha3, toolz, lru-dict, eth-utils, eth-abi, cytoolz
Classifiers:
  Development Status :: 2 - Pre-Alpha
  Intended Audience :: Developers
  License :: OSI Approved :: MIT License
  Natural Language :: English
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Thanks for your help Piper

boneyard93501 commented 6 years ago

-32000 is the json-rpc spec, see 5.1, server error catch all and the rpc client's just passing that on. my encoding/decoding prowess sucks but just looking at the codec, it looks like turkish or thai to me. using TIS-620, i get ฤดd|าบs๗ษ›GไธŽุ which ol' google seems to think stands for i'm sorry. does that make any sense? well, at the very least, we now know that we're dealing with a worldly, polite, yet misunderstood rpc backend. looks like the github editor can't display that either ... try below to see the actual output in your editor/terminal:

# accounting for utf-8 wrapping/mangling TIS-620, you get a clean representation
>>> fixed_bstr = b'\xc4\xb4\x1f\x02d\x9d|\xd2\xbas\xf7\xc9\x9bG\xe4\xb8\x8e\x18\xd8'
>>> print(fixed_bstr.decode('TIS-620'))

is it possible that the encoding of the account strings, or your ide/editor, wasn't utf-8 ?

cgarvie commented 6 years ago

hmmm... I am indeed in Thailand and that is indeed Thai (it's gibberish though) but the server I am running this on is a digitalocean droplet rented in Singapore. Very strange. My full code is in the OP, and I'm not using any IDE. I'm just typing in the python2 terminal/console over ssh. The geth node is running on the same box (localhost).

What's the standard client that most people use web3py with? Is it geth? Should I be running geth with any special flags in order to expose the interface?

pipermerriam commented 6 years ago

I'd recommend upgrading to use the v4 beta pip install --pre -U web3 which may fix some of the encoding issues. Prior to v4 we had some weird character encoding issues and inconsistencies that have largely been resolved.

cgarvie commented 6 years ago

I updated to the latest version using the command you gave, and I'm now using python3. same error.

No worries.

What is the 'reference implementation' .. What setup should this work on easily?

(py3env) root@ubuntu-geth:~# pip show web3
Name: web3
Version: 4.0.0b11
...
(py3env) root@ubuntu-geth:~# python --version
Python 3.5.2
pipermerriam commented 6 years ago

sorry for initially mis-reading your issue.

It looks like you are trying to transaction from an account that testrpc doesn't know about. You generally will need to use an account fromweb3.eth.accounts with testrpc.

pipermerriam commented 6 years ago

And by the way. eth-testrpc-py has been deprecated. You should look into switching over to the EthereumTesterProvider which is backed by eth-tester which is in active development.