This repository was archived by the owner on Jul 10, 2026. It is now read-only.
Cache inflight current chain-head requests#357
Merged
Conversation
…et_chain_finalized_head
…ke one single request
…-hashes' into feat/thewhaleking/cache-inflight-hashes
Contributor
Author
|
Fix for flaky bittensor e2e tests: |
basfroman
approved these changes
Jun 1, 2026
basfroman
left a comment
Contributor
There was a problem hiding this comment.
btw, you might not have given it much thought, but this fixes the issue where a result of 0 was previously not cached. Now, it is.
Great!
Contributor
Author
Ha. I totally didn't even realise that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds new functionality to
CachedFetcherthat will not cache the results of a request if specifiedcache_results=False.This may seem to defeat the point, but in fact it does not. This allows using the current request caching, without needing to cache the result.
For example, we wouldn't want to cache
get_block_hash(None)because the block hash changes often. But if we can utilise the same inflight request for two concurrent requests, we can stop writing:and instead write the much simpler:
as both requests internally fetch the chain head, and will utilise the same head fetch request with this new functionality. (See
tests/unit_tests/asyncio_/test_substrate_interface_async_unit.py:test_concurrent_block_hash_none_dedups_chain_head_request)