ApeWorX / ape-polygon

Polygon ecosystem plugin for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
5 stars 9 forks source link

Missing Middleware for Proof-of-Authority Chains in Ape Polygon Plugin #33

Open moses966 opened 4 days ago

moses966 commented 4 days ago

Description:

I encountered an error while trying to use the ApeWorx Polygon plugin. The error message suggests that the plugin is not handling Proof-of-Authority (POA) chains properly due to missing middleware.

Error Details:

(BlockNotFoundError) Missing latest block. 
Reason: The field extraData is 100 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#proof-of-authority

The error seems to indicate that the necessary middleware for handling POA chains has not been injected correctly.

Steps to Reproduce:

  1. Install the ApeWorx Polygon plugin using pip install ape-polygon.
  2. Attempt to connect to the Polygon network using the plugin by running: ape run deploy --network polygon:amoy:alchemy
  3. Observe the error when fetching the latest block.

Expected Behavior:

The plugin should inject the necessary middleware to handle POA chains, similar to what Web3.py’s middleware does for POA networks.

Actual Behavior:

The plugin fails with a BlockNotFoundError due to the extraData field being 100 bytes instead of the expected 32 bytes, indicating missing middleware support for POA chains.

Environment:

Additional Context:

The error occurs when interacting with a Proof-of-Authority chain like Polygon. According to the Web3.py documentation, the missing middleware should handle the extraData field for POA networks by adjusting its size appropriately.

Thank you for looking into this!


linear[bot] commented 4 days ago

APE-1836 Missing Middleware for Proof-of-Authority Chains in Ape Polygon Plugin

bitwise-constructs commented 4 days ago

Might need to wait on 0.9 as this requires web3.py v7

moses966 commented 4 days ago

Hi @bitwise-constructs , Did you mean waiting on eth-ape version 0.9 from the current version of 0.8.15?

bitwise-constructs commented 4 days ago

@moses966 correct, the current 0.9 branch raises a lot of pins including web3 https://github.com/ApeWorX/ape/tree/feat/0-9

antazoey commented 3 days ago

The issue is actually in the provider (ape-alchemy):

https://github.com/ApeWorX/ape-alchemy/blob/main/ape_alchemy/provider.py#L116-L122

antazoey commented 3 days ago

amoy's chain ID just needs to be added to that list.

antazoey commented 3 days ago

Also, we should make ape-alchemy behave like ape-node where if it encounters this error, it will automatically add the middleware as well:

https://github.com/ApeWorX/ape/blob/main/src/ape_ethereum/provider.py#L1511-L1530

moses966 commented 2 days ago

The issue is actually in the provider (ape-alchemy):

https://github.com/ApeWorX/ape-alchemy/blob/main/ape_alchemy/provider.py#L116-L122

Quicknode too