Skip to content

State Production: Write-Through Current State Cache #518

@aristidesstaffieri

Description

@aristidesstaffieri

Summary

Implement an in-memory write-through cache for protocol current state during live ingestion, enabling efficient computation of additive state after handoff from migration.

Scope

  • Per-protocol cache: map[protocolID] -> { currentStateCursor, stateData }
  • Empty at start: cache is unpopulated when live ingestion starts
  • Populated from DB: on first successful CAS-advance of current_state_cursor (the handoff moment), read current state from protocol state tables (one-time DB read)
  • Updated per ledger: on each subsequent ledger, update cache in-memory + write through to DB
  • Lost on restart: if live ingestion restarts, cache is repopulated from DB on next current-state production
  • Needed because additive state (e.g., token balances) requires knowing state at N-1 to compute state at N

Dependencies

Reference

docs/feature-design/data-migrations.md (State Production section, line 619+)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions