Skip to content

Add config-driven hot-path read cache for get_market with snapshot invalidation #636

Description

@greatest0fallt1me

Description

get_market is on the hot read path and re-deserializes the full struct. Add an in-instance cache keyed by market_id, invalidated whenever MarketStateManager mutates the market.

Requirements and Context

  • Add MarketReadCache in markets.rs backed by env.storage().instance()
  • Invalidate on every write path through MarketStateManager
  • Document TTL behavior
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b feat/get-market-hot-path-cache
  2. Implement changes
    • contracts/predictify-hybrid/src/markets.rs
    • contracts/predictify-hybrid/src/storage.rs
  3. Test and commit
    • cargo test -p predictify-hybrid markets -- --nocapture
    • Cover edge cases: cache miss, cache hit, cache invalidation
    • Include test output and notes in the PR

Example commit message

feat: hot-path cache for get_market with explicit invalidation

Acceptance Criteria

  • Cache invalidated on every write
  • TTL bumps explicit
  • No unwrap() introduced
  • Benchmarks show read-path improvement

Guidelines

  • Avoid stale reads at all costs
  • Minimum 95% coverage
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox open-source campaign taskMAYBE REWARDEDMay be rewarded under the GrantFox campaignOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveIssues in the Stellar wave programenhancementNew feature or improvementrustRust implementationsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions