feat(indexer): #279 Phase 1a — pair_reserves + resting_limit_orders schema #761
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic!761
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "qa/279-phase1a-state-mirror-schema"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Starting #279 (the 0-LCD solver) — this is Phase 1a, the schema foundation, scoped deliberately small and self-contained. It lands the two Postgres tables + their query layer with full CRUD tests and touches nothing in the live solver/API — so no fidelity risk and nothing to coordinate yet.
Adds:
pair_reserves— current v2 pool state (reserve_0/1, fee_bps, height), one row per pair, upserted per snapshot. Reserves aren't event-sourced today (they only live on-chain behind{pool:{}}), so this is the table the snapshot loop will fill.resting_limit_orders— a materialized current-state book (liveremainingper order), distinct from the append-only placement/cancel/fill logs; indexed for the walk order (price + FIFO).db::queries::pair_reserves(upsert/get; missing ->None= degrade-not-error) anddb::queries::resting_orders(atomic replace-pair-book; get-book ordered best-price-then-FIFO).revert/*.down.sqlfor both; test-DB cleanup truncates the new tables.Tests 3/3: reserves upsert-replace + missing-is-None; resting-book replace + walk ordering (bids DESC, asks ASC, FIFO at equal price).
Subsequent increments (need live fidelity validation, hence not bundled): 1b the
book_snapshotloop that populates these from chain state (modeled on the oracle/tier-sync loops); 1cdb_orderbook_sim(port the pool+book math, reuse the CG/CMC #220 sim) + rewirehybrid_route_opt/best_executionto read DB instead of LCD, keeping the finalmaybe_simulateLCD validation on the winning route as the fidelity-drift guard; then Phase 2 (4-hop bump) and Phase 3 (cache-key — #283 already shipped standalone as !751). The breakingquote_kindrename lands with 1c → coordinate with frontend then. No closing keyword.Security review (automated)
Commit reviewed:
5392f968f9d2e57b5b576efd14b104aa1e77b22bScope: Phase 1a schema foundation —
pair_reserves+resting_limit_ordersmigrations,db::queries::{pair_reserves,resting_orders}, integration tests, test DB cleanup. No HTTP/API/solver wiring in this diff.Outcome:
FINDINGS: 0medium+Inline threads: none (no medium+ findings to anchor)
Summary
Reviewed attacker-controlled input paths and sinks across the added query layer:
$1…$8). Inget_pair_resting_book, the onlyformat!interpolation isprice_dir, constrained to"DESC"or"ASC"viaside == "bid"— not derived from raw caller strings.sideitself is bound as$2.Phase 1c solver fidelity / poisoned-mirror concerns are out of scope for this diff (tables are not read by the live solver yet; MR description defers wiring to later phases with LCD validation guard).
Security review: no medium+ findings on this diff.
mentioned in issue #319
mentioned in commit
8ea4bc1420mentioned in issue #322
mentioned in issue #279