mirror of https://github.com/nucypher/nucypher.git
Make a call to eth.get_block after establishing an EthereumClient with middlewares to ensure that poa middleware, if needed, works correctly.
parent
eb7ecc844d
commit
43e0dcb941
|
@ -13,7 +13,6 @@ from web3.types import TxReceipt, Wei
|
|||
|
||||
from nucypher.blockchain.eth.constants import (
|
||||
AVERAGE_BLOCK_TIME_IN_SECONDS,
|
||||
POA_CHAINS,
|
||||
PUBLIC_CHAINS,
|
||||
)
|
||||
from nucypher.blockchain.middleware.poa import create_poa_error_redundancy_middleware
|
||||
|
@ -94,14 +93,6 @@ class EthereumClient:
|
|||
self.log.debug("Adding RPC retry middleware to client")
|
||||
self.add_middleware(RetryRequestMiddleware, name="retry")
|
||||
|
||||
# poa middleware
|
||||
chain_id = self.chain_id
|
||||
is_poa = chain_id in POA_CHAINS
|
||||
|
||||
self.log.info(
|
||||
f"Blockchain: {self.chain_name} (chain_id={chain_id}, poa={is_poa})"
|
||||
)
|
||||
|
||||
# add POA middleware irrespective of chain
|
||||
poa_middleware_name = "poa"
|
||||
self.log.info("Injecting POA middleware at layer 0")
|
||||
|
|
|
@ -331,6 +331,13 @@ class BlockchainInterface:
|
|||
# client mutates w3 instance (configures middleware etc.)
|
||||
self.client = EthereumClient(w3=self.w3)
|
||||
|
||||
# log info
|
||||
latest_block_number = self.client.get_block("latest")["number"]
|
||||
chain_id = self.client.chain_id
|
||||
self.log.info(
|
||||
f"Blockchain: {self.client.chain_name} (chain_id={chain_id}, block_num={latest_block_number})"
|
||||
)
|
||||
|
||||
# web3 instance fully configured; share instance with ATxM and respective strategies
|
||||
speedup_strategy = ExponentialSpeedupStrategy(
|
||||
w3=self.w3,
|
||||
|
|
|
@ -51,9 +51,12 @@ class SyncedMockW3Eth:
|
|||
chain_id = hex(CHAIN_ID)
|
||||
block_number = 5
|
||||
|
||||
def getBlock(self, blockNumber):
|
||||
def get_block(self, blockNumber):
|
||||
return {
|
||||
'timestamp': datetime.datetime.timestamp(datetime.datetime.now() - datetime.timedelta(seconds=25))
|
||||
"timestamp": datetime.datetime.timestamp(
|
||||
datetime.datetime.now() - datetime.timedelta(seconds=25)
|
||||
),
|
||||
"number": 123456789,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue