ethereum / eth-tester

Tool suite for testing ethereum applications.
MIT License
367 stars 151 forks source link

AttributeError: 'ConstantinopleState' object has no attribute 'account_db' ` #163

Open ldct opened 5 years ago

ldct commented 5 years ago

What was wrong?

python3 -m venv venv
source venv/bin/activate
pip3 install py-evm
pip3 install eth-tester
pip3 install eth-hash[pysha3]
python3
>>> from eth_tester import EthereumTester
>>> t = EthereumTester()
>>> t.get_balance(t.get_accounts()[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xuanji/gits/cf/py-evm-tester/venv/lib/python3.7/site-packages/eth_tester/main.py", line 225, in get_balance
    raw_balance = self.backend.get_balance(raw_account, raw_block_number)
  File "/Users/xuanji/gits/cf/py-evm-tester/venv/lib/python3.7/site-packages/eth_tester/backends/pyevm/main.py", line 394, in get_balance
    return vm.state.account_db.get_balance(account)
AttributeError: 'ConstantinopleState' object has no attribute 'account_db'

How can it be fixed?

¯\_(ツ)_/¯

carver commented 5 years ago

eth-tester beta 3? You're a good long ways behind... Can you upgrade to beta 39?

ldct commented 5 years ago

I copied and pasted wrongly... the version should be 0.1.0b39. updated.

pipermerriam commented 5 years ago

This already fixed on master.

https://github.com/ethereum/eth-tester/blob/4e199f6586a3c8d629316d945b502a44f0e15c8a/eth_tester/backends/pyevm/main.py#L394

You probably need to do something like pip install eth-tester[py-evm] to get the right versions.

ldct commented 5 years ago

@pipermerriam OK, after reading the setup.py more carefully I see why I triggered this bug. setup.py says it pins py-evm version, but actually this only means that installing eth-tester[py-evm] installs the specified version of py-evm. You can install incompatible versions of eth-tester and py-evm separately.

  1. Can the readme be updated to reflect this?
  2. Can a version check be added at runtime so that installing incompatible versions is not possible?