Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] GethPOAMiddleware on Polygon networks with anvil fork #1791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kx9x
Copy link

@kx9x kx9x commented Aug 31, 2024

What I did

On Polygon networks, anvil in forked development mode doesn't throw ExtraDataLengthError on the first block. So, I changed the GethPOAMiddleware to try both the first block and latest block. This is similar to apeworx implementation here:
ApeWorX/ape-hardhat#133

Related issue: #1762

How I did it

How to verify it

ran anvil locally

anvil --accounts 10 --fork-url <REDACTED> --gas-limit 12000000 --port 8545 --chain-id 137 &

connect web to anvil

web3.connect('http://localhost:8545')

verify we hit the exception on latest block, but not on first block

>>> try:
...     web3.eth.get_block("latest")
... except Exception as e:
...     print(type(e))
... 
eth_getBlockByNumber
<class 'web3.exceptions.ExtraDataLengthError'>
>>> try:
...     web3.eth.get_block(0)
... except Exception as e:
...     print(type(e))
... 
eth_getBlockByNumber
AttributeDict({'hash': HexBytes('0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b'), 'parentHash': HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'), 'sha3Uncles': HexBytes('0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'), 'miner': '0x0000000000000000000000000000000000000000', 'stateRoot': HexBytes('0x654f28d19b44239d1012f27038f1f71b3d4465dc415a382fb2b7009cba1527c8'), 'transactionsRoot': HexBytes('0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'), 'receiptsRoot': HexBytes('0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'), 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'difficulty': 1, 'number': 0, 'gasLimit': 10000000, 'gasUsed': 0, 'timestamp': 1590824836, 'totalDifficulty': 1, 'extraData': HexBytes('0x'), 'mixHash': HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'), 'nonce': HexBytes('0x0000000000000000'), 'uncles': [], 'transactions': [], 'size': 508})

Checklist

  • [X ] I have confirmed that my PR passes all linting checks
  • I have included test cases
  • [N/A] I have updated the documentation
  • I have added an entry to the changelog

@kx9x kx9x changed the title [fix] GethPOAMiddleware on development anvil network [fix] GethPOAMiddleware on Polygon networks with anvil fork Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant