Closed njgheorghita closed 5 years ago
This is almost certainly related to #1212
Likely candidate for when/how this got introduced is to look at https://github.com/ethereum/web3.py/pull/1188 since it touched the middlewares in web3.py that handled some of the normalization steps.
@pipermerriam The problem was with how I was instantiating my class using the PyEVMBackend
.
This is what was broken...
from web3 import Web3
from eth_tester import PyEVMBackend
w3 = Web3(Web3.EthereumTesterProvider(PyEVMBackend()))
This is what I should have been doing / What works fine.
from web3 import Web3
from eth_tester import PyEVMBackend, EthereumTester
w3 = Web3(Web3.EthereumTesterProvider(EthereumTester(PyEVMBackend())))
Basically, the inbound tx normalization happens in the EthereumTester
class and not in PyEVMBackend
- but they share the same methods, so web3's delegator was calling the PyEVMBackend.estimate_gas()
directly instead of EthereumTester.estimate_gas()
which would normalize and then subsequently pass on the normalized tx to PyEVMBackend.estimate_gas()
I'm unsure as to exactly where I saw the first (aka broken) pattern, but it seems to me that maybe the best fix is something in the docs explaining how to instantiate w/ PyEVMBackend
directly - as I think this'll be common now that you can adjust genesis-params in eth-tester.
When @kclowes and I looked over this today I had the thought that we could add a check to EthereumTesterProvider.__init__
which checked if the provided value was an instance of EthereumTester
and errors out if it isn't. Additionally, if the value is a backend it could lazily wrap it in the EthereumTester
class. Either way we can prevent this mistake with some simple value checks.
pip freeze
outputWhat was wrong?
Using
web3.eth.getBlock()
method is broken in v5 alpha - when using aPyEVMBackend
- the same code works fine when usingMockBackend
.The final line breaks with the following error
How can it be fixed?
Not sure, I spent some time digging around
eth-tester
/py-evm
to try and find a solution, but no luck. Though, this is most likely related to update in those dependencies in v5.