feat: reconcile indexed chain state#93
Conversation
|
Please merge |
EmeditWeb
left a comment
There was a problem hiding this comment.
Review verdict: ✅ APPROVE with notes
Solid reconciliation job. @Cron('0 */15 * * * *') (not BullMQ), overlap guard, no any, tests included (+132). Verified the write paths: reconciliation is chain → DB only and iterates over the authoritative on-chain set, so a failed/empty read is a no-op loop — it never zeroes or corrupts existing rows (safe failure direction). Errors throw rather than silently continue. Transaction status resolution (missing/orphaned/pending) and liquidity/reputation correction all look reasonable.
Notes before merge:
- The financial DB writes (
liquidity_positions.deposited_amount,reputation_cache.score) are only as correct assrc/indexer/authoritative-state.reader.ts. That 114-line reader now drives money/credit-state writes — please give it a focused review (it's the single point of truth for these overwrites). - Reconciliation only writes rows present on-chain; DB rows with no on-chain counterpart are left as-is (conservative — fine, just note it).
- The 30-minute cutoff that marks a pending transaction
orphaned/failed— confirm a slow-but-valid submission can't be prematurely orphaned under network latency.
No blockers; approve once the reader has had a look.
EmeditWeb
left a comment
There was a problem hiding this comment.
Re-audited for merge: the AuthoritativeStateReader reads the indexer's event-sourced tables (loan_index/investments_index/reputation_history/payment_index), not raw RPC — so the reconciliation is DB→DB from indexed truth with no chain-parse risk. Writes are guarded (mismatch-only, chain→DB direction, errors thrown, no zeroing on empty reads), amounts are Number()-converted, @Cron with overlap guard, no any. Build passes, reconciliation tests 4/4. Approving and merging.
# Conflicts: # context/progress-tracker.md
EmeditWeb
left a comment
There was a problem hiding this comment.
Updated the branch with current main (only conflict was a progress-tracker entry, kept both). Build passes, reconciliation tests 4/4. Merging.
Closes #80
What changed
Architecture note
The issue requested BullMQ, but this repository's required architecture explicitly prohibits reintroducing BullMQ after its Redis polling exhausted the Upstash quota. This implementation uses NestJS @Cron with an overlap guard and caught errors, matching the current background-job standard.
The reconciliation path performs no on-chain writes.
Validation
Closes #80