Always inject poa middleware for Web3 instances used for evaluating RPCConditions (and sub-classes).

v7.4.1-hotfix^2
derekpierre 2024-08-28 11:51:52 -04:00
parent 930eaf9b23
commit f692b0650f
No known key found for this signature in database
2 changed files with 4 additions and 6 deletions

View File

@ -102,11 +102,10 @@ class EthereumClient:
f"Blockchain: {self.chain_name} (chain_id={chain_id}, poa={is_poa})"
)
# proof-of-authority blockchain
# add POA middleware irrespective of chain
poa_middleware_name = "poa"
self.log.info("Injecting POA middleware at layer 0")
self.inject_middleware(
# use naming from redundancy middleware
geth_poa_middleware,
layer=0,
name=poa_middleware_name,

View File

@ -18,7 +18,6 @@ from web3.middleware import geth_poa_middleware
from web3.providers import BaseProvider
from web3.types import ABIFunction
from nucypher.blockchain.eth.constants import POA_CHAINS
from nucypher.policy.conditions import STANDARD_ABI_CONTRACT_TYPES, STANDARD_ABIS
from nucypher.policy.conditions.base import AccessControlCondition
from nucypher.policy.conditions.context import (
@ -211,9 +210,9 @@ class RPCCondition(AccessControlCondition):
# Instantiate a local web3 instance
self.provider = provider
w3 = Web3(provider)
if self.chain in POA_CHAINS:
# inject web3 middleware to handle POA chain extra_data field.
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
# inject web3 middleware to handle POA chain extra_data field.
w3.middleware_onion.inject(geth_poa_middleware, layer=0, name="poa")
return w3
def _check_chain_id(self) -> None: