You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please include any of the following that are applicable:
There seems to be an issue with the latest_block_based_cache_middleware implementation. Given the following config:
w3=Web3(HTTPProvider(settings.ETHEREUM_NODE_URL, request_kwargs={"timeout": 8}))
# Set the gas price strategy# https://web3py.readthedocs.io/en/stable/gas_price.html#selecting-the-gas-price-strategy# NOTE - It's recommended to add a cache solution because of how inneficient this gas strategy isw3.eth.setGasPriceStrategy(fast_gas_price_strategy)
w3.middleware_onion.add(middleware.time_based_cache_middleware)
w3.middleware_onion.add(middleware.latest_block_based_cache_middleware)
w3.middleware_onion.add(middleware.simple_cache_middleware)
I'm observing w3.eth.get_block('latest') to always be cached even though it should never be cached.
Digging into the code a bit more, I suspect the issue in in _is_latest_block_number_request fn,
What was wrong?
Please include any of the following that are applicable:
There seems to be an issue with the
latest_block_based_cache_middleware
implementation. Given the following config:I'm observing
w3.eth.get_block('latest')
to always be cached even though it should never be cached.Digging into the code a bit more, I suspect the issue in in
_is_latest_block_number_request
fn,web3.py/web3/middleware/cache.py
Line 317 in 4893947
web3.py/web3/middleware/cache.py
Line 320 in 4893947
I've printed params locally, and it seems that
params[:1]
evaluates to('latest',)
(tuple) and thus the comparison with list fails.How can it be fixed?
Convert params slice to list before comparing?
The text was updated successfully, but these errors were encountered: