Skip to content

Cross-network disk cache contamination can return wrong-chain data #2

@it-education-md

Description

@it-education-md

Summary

agcli disk cache keys for expensive chain queries are not network/endpoint scoped in affected versions, so cached data from one network can be reused on another network.

This can cause commands to return valid-looking but incorrect data (from a different chain), without errors.

Criticalness

  • Operators and bots frequently switch between local/test/finney/archive on the same machine.
  • Cache TTL is long enough (5 min) to hit cross-run contamination.
  • Output looks normal; no hard failure warns the user.
  • This can drive incorrect staking/operations decisions based on wrong network state.

Reproduction

agcli --network finney view overview --output json > finney.json
agcli --network test view overview --output json > test.json

The second command may reuse cached data from the first network instead of fetching fresh data for testnet.

Root cause

Disk cache keys are global and not namespaced by network/endpoint/chain identity.

Code path:

  • QueryCache reads/writes fixed keys like all_subnets and all_dynamic_info
  • Disk path is ~/.agcli/cache/.json
  • No network scope in key construction

Proposed fix

Scope disk keys by connection context, e.g.:

  • v2_<endpoint_hash>_all_subnets
  • v2_<endpoint_hash>_all_dynamic_info

Chain-id/genesis scoped is also valid; endpoint-scoped can be a clean minimal fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions