Skip to content

data: caching layer for contract reads #55

Description

@joelpeace48-cell

Problem

Contract state reads via RPC are slow and rate-limited. A dashboard polling
quotas for a hundred payers will exhaust a public RPC endpoint's budget
immediately, and the failure mode is the whole service degrading rather than
one feature.

What to do

  • Cache contract reads with TTLs chosen per data type: contract metadata is
    effectively immutable, quota balances are not.
  • Invalidate on the corresponding indexer event rather than waiting for TTL
    expiry, so writes are reflected promptly.
  • Serve stale on RPC failure, but label the response as stale with an
    as-of timestamp — silently serving old numbers in a billing product is worse
    than an error.
  • Add request coalescing so a hundred concurrent misses produce one upstream
    call.

Acceptance criteria

  • Per-type TTLs, documented with reasoning
  • Event-driven invalidation
  • Stale responses explicitly labelled with an as-of time
  • Request coalescing verified under concurrent load

Notes

The stale labelling matters commercially. A number without an as-of timestamp
in a billing dispute is not evidence.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSThird CampaignCampaign: Third Campaignarea:dataPersistence, indexing, and cachingdifficulty:mediumFamiliar patterns; touches a few files or conceptspriority:mediumValuable, not blockingtype:choreTooling, CI, dependencies

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions