brownie
brownie copied to clipboard
ExtraDataLengthError when querying polygon-main-fork
Environment information
-
brownie
Version: 1.16.1 -
ganache-cli
Version: 6.12.2 - Python Version: 3.9.5
- OS: osx
What was wrong?
Works:
% brownie console --network polygon-main
Brownie v1.16.1 - Python development framework for Ethereum
No project was loaded.
Brownie environment is ready.
>>> web3.chain_uri
'blockchain://a9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b/block/8d94457c2770162412b9a5eaaf31f086c8f61b7a5437c3bddd87625aa3ccafdc'
Errors:
% brownie console --network polygon-main-fork
Brownie v1.16.1 - Python development framework for Ethereum
No project was loaded.
Launching 'ganache-cli --port 8545 --gasLimit 20000000 --accounts 10 --hardfork istanbul --mnemonic brownie --fork https://matic-mainnet.chainstacklabs.com --chainId 137'...
Brownie environment is ready.
>>> web3.chain_uri
File "<console>", line 1, in <module>
File "/Users/ski/code/brownie/brownie/network/web3.py", line 161, in chain_uri
block_hash = self.eth.get_block(block_number)["hash"].hex()[2:]
File "web3/eth.py", line 532, in get_block
return self._get_block(block_identifier, full_transactions)
File "web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "web3/manager.py", line 186, in request_blocking
response = self._make_request(method, params)
File "web3/manager.py", line 147, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "web3/middleware/gas_price_strategy.py", line 80, in middleware
return make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "web3/middleware/attrdict.py", line 33, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 83, in apply_formatters
formatter(response["result"]),
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "eth_utils/applicators.py", line 72, in apply_formatter_if
return formatter(value)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "eth_utils/functional.py", line 45, in inner
return callback(fn(*args, **kwargs))
File "eth_utils/applicators.py", line 84, in apply_formatters_to_dict
yield key, formatters[key](item)
File "web3/middleware/validation.py", line 71, in check_extradata_length
raise ExtraDataLengthError(
ExtraDataLengthError: The field extraData is 97 bytes, but should be 32. It is quite likely that you are connected to a POA chain. Refer to http://web3py.readthedocs.io/en/stable/middleware.html#geth-style-proof-of-authority for more details. The full extraData is: HexBytes('0xd783010a0383626f7288676f312e31352e35856c696e757800000000000000002a8675bc01dc83dc232a9e3c39359f5c40ffaa5cf26e10d75b5fa76707a7aa0b0e664e90ed605bb256549aa40e39f450496679c0823de2666fe23aa3578869c501')
I beleive some other commands will fail with the same error
How can it be fixed?
I'm not sure. Maybe the suggested middleware will work
I got the same problem on Optimism
I'm a bit confused that this is still happening.
This code should be injecting the middleware automatically: https://github.com/eth-brownie/brownie/blob/4b134d4be9d3dde14f93f389cef9651910c9520e/brownie/network/middlewares/geth_poa.py
Aha! It doesn't happen automatically because if the "latest" block is a local block and not a remote block, it doesn't raise an exception. And it looks like ganache sometimes adds a block for some reason. Not sure why they do that yet.
It is still a problem, and the #1493 is indeed fix that. Why is it not merged for 2 years?