fix: prevent cross-network disk cache contamination#3
Open
lindsey-comet wants to merge 1 commit intounconst:mainfrom
Open
fix: prevent cross-network disk cache contamination#3lindsey-comet wants to merge 1 commit intounconst:mainfrom
lindsey-comet wants to merge 1 commit intounconst:mainfrom
Conversation
Add network scoping to disk cache keys to prevent wrong-chain data when switching networks (e.g., finney ↔ testnet). Changes: - QueryCache: add network_id field and with_network() constructor - Add scoped_disk_key() method to namespace disk keys by endpoint - Update disk cache operations to use scoped keys - Update Client::connect_once() and Client::reconnect() to use network-scoped cache The URL is sanitized to remove special characters for safe filesystem key usage. Fixes unconst#2
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The disk cache uses hardcoded keys like
all_subnetsandall_dynamic_infowithout any network scoping. This causes cache contamination when users switch between networks (e.g., finney ↔ testnet), where cached data from one network could be incorrectly used for another.Solution
Add network scoping to disk cache keys:
network_idfieldQueryCache::with_network()constructor that accepts an endpoint URLscoped_disk_key()method generates namespaced keys likewss___entrypoint_finney_all_subnetsClient::connect_once()andClient::reconnect()to use network-scoped cacheChanges
src/queries/query_cache.rs: Addednetwork_idfield,with_network()constructor,scoped_disk_key()methodsrc/chain/mod.rs: Updatedconnect_once()andreconnect()to useQueryCache::with_network()Testing
cargo checkcleanFixes
Fixes #2
🤖 Generated via Arbos | Gittensor contributor