You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current indexer (indexer/index.mjs) is a prototype: it appends decoded events to a flat events.ndjson with a single cursor and no query layer beyond a CSV dump (export-csv.mjs). There is no database, no derived state, no API, and critically no way to verify that what it recorded matches the chain. For a payments protocol, the off-chain view of "who was paid what, and what is currently escrowed" needs to be queryable, correct, and provably consistent with contract storage.
Proposal
A production event-sourced accounting service:
Ingest contract events into Postgres as an append-only event log (the source of truth for the projection).
Build projections from the log: per-split payout history, per-recipient earnings, current escrow balances per split and token, creator and (once available) recipient indexes.
Expose a query API over the projections.
Add a reconciliation job that reads the same values from the contract (balance, get_split, split_count) and asserts the projection matches on-chain state, alerting on drift.
Reconciliation is the hard, valuable core: proving a derived balance equals the on-chain balance(id, token) across all splits and tokens, continuously, and pinpointing the exact event where drift began when they disagree.
Projections rebuild deterministically from the event log (drop-and-replay yields identical state).
Reconciliation continuously proves projected balances equal on-chain balance for every split and token, and reports the first divergent event on mismatch.
Ingestion is exactly-once and reorg-safe.
The query API serves payout history, per-recipient earnings, and live escrow balances.
Related
Supersedes the ndjson prototype; absorbs or coordinates with #80 (reorgs), #81 (restart durability), #82 (query API), #84 (logging/metrics). Depends on #258 and #267 for correct per-recipient and deposit/routing data.
Difficulty: Expert. Scope: multi-week epic. Backend service.
Problem
The current indexer (
indexer/index.mjs) is a prototype: it appends decoded events to a flatevents.ndjsonwith a single cursor and no query layer beyond a CSV dump (export-csv.mjs). There is no database, no derived state, no API, and critically no way to verify that what it recorded matches the chain. For a payments protocol, the off-chain view of "who was paid what, and what is currently escrowed" needs to be queryable, correct, and provably consistent with contract storage.Proposal
A production event-sourced accounting service:
balance,get_split,split_count) and asserts the projection matches on-chain state, alerting on drift.Why this is hard
balance(id, token)across all splits and tokens, continuously, and pinpointing the exact event where drift began when they disagree.Deliverables
Acceptance criteria
balancefor every split and token, and reports the first divergent event on mismatch.Related
Supersedes the ndjson prototype; absorbs or coordinates with #80 (reorgs), #81 (restart durability), #82 (query API), #84 (logging/metrics). Depends on #258 and #267 for correct per-recipient and deposit/routing data.