fix(indexer): recover provider failures and restore fast executable live routes #1464
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#1464
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Problem and scope
Restore useful, fast production quotes for LUNC→cUSTC, CL8Y→USTR, USTR→cUSTC and ALPHA→CL8Y, and stop transient upstream failures from repeatedly terminating the API process. Bundle provider recovery, reliable quote admission and useful-result latency into this implementation because the observed restarts repeatedly destroy the initialized in-memory quote state.
This is a concrete production defect after the cached quote/feed implementation. Related work: #1452, #1453, #1459, and the existing deployment/acceptance tracker #1456. Keep deployment/history follow-up in #1456; this issue owns the newly reproduced failure and implementation regressions. Do not reopen unrelated accounting/history repair scope here.
Current production evidence
Public, read-only requests on 2026-10-10 UTC confirmed revision
c5cc674f2d32655b1f4ee7521dd5f34aa196a8ab. No wallet context, transaction signing or broadcast was used. All addresses below identify public token contracts, not reporters.The initial corpus returned zero usable quotes in 24 requests:
pool_only=true, matching the frontend.No eligible route within the selected protection. HTTP 503 included both proxyno available serverand applicationLocal execution quote unavailable; refresh after indexed data recovers./healthcan briefly returnstatus=okwith the expected revision while this corpus fails. Liveness/startup success is insufficient trading readiness.Redacted operational diagnostics show repeated exits/restarts:
LCD provider admission deferredat the checkpoint; another restart.Provider failures and process coupling are observed. The exact reason every candidate disappears from quote admission is not yet isolated: do not assert that amount size, a particular provider, tax semantics or contract pins alone explain every 422.
Minimal reproduction
Use
GET https://indexer.dex.cl8y.com/api/v1/route/solve, with exact raw integer amounts:ulunaterra1nap4dxh9tv35v0ynd9m4k6zt6c0dq6weszc4j5m564kjls56hu7qcr56chterra16wtml2q66g82fdkx66tap0qjkahqwp4lwq3ngtygacg5q0kzycgqvhpax3terra1vy3kc0swag2rhn7jz6n72jp0l2ns0p6r6ez5grxq5uhj2rvs97fqfsetxvterra1x6e64es6yhauhvs3prvpdg2gkqdtfru840wgnhs935x8axr7zxkqzysuxzSubstitute the other public identities and raw amounts from the corpus. Pace probes below API limits; include first connections and reused connections, and record status plus useful output rather than response completion alone.
Current codebase and why changes are needed
Reviewed the deployed revision above as well as local source revision
736be444100ba84887a6619336c83d2848258884; do not confuse local passing tests with deployed acceptance.LcdClientclones share endpoint health, rate/concurrency admission and circuit state. It distinguishesAdmissionDeferred, attempted upstream failures, malformed contract-local responses and historical-height failures. Quote ingestion uses additional paced background admission; investigate fairness between checkpoint reads, reserves, books, configuration, token/wallet policy and independent reference workers, including permits held while awaiting pacing.poller.rsalready retries a failed latest-height read. In contrast, errors fromverify_checkpoint_unchangedreturn from the indexer task, and block retry exhaustion also returns.block_indexer.rspreserves the checkpoint on failure, but treats several error classes through the same attempt/exhaustion path.main.rs::run_serverselects between indexer completion and API completion. When the indexer returns, the process logs shutdown and exits, interrupting an otherwise running API and resetting local snapshots/caches on restart.20261009145300. That migration was applied through a standalone job, with original history preserved. Re-running startup migrations or widening runtime privileges is not a solution to these later failures.Existing source-level provider/local quote tests pass, yet production cannot supply a trade. Recovery must preserve the API and allow scheduled ingestion to rebuild eligible data, without hiding accounting failures, accepting stale quotes or bypassing constraints. Speed work must measure useful output under actual socket/browser transport, not fast 422/503 responses.
Relevant files
indexer/src/main.rs,indexer/src/indexer/poller.rs,block_indexer.rs,parser.rs,indexer/src/db/queries/state.rs.indexer/src/lcd/mod.rs,provider_pool.rs,chain_identity.rs,pair_discovery_state.rs,indexer/src/config.rs.indexer/src/indexer/book_snapshot.rs,indexer/src/db/queries/pair_reserves.rs,indexer/src/api/local_quote/admission.rs,ingestion.rs,actor_inventory.rs,tax.rs,local_hook_pricing.rs,local_wrapper_quote.rs,local_reference_quote.rs.indexer/src/api/local_quote.rs,local_quote/skeletons.rs,modes.rs,reverse.rs,route_solver.rs,route_solve_progress.rs,mod.rs.frontend-dapp/src/services/indexer/client.ts,utils/cw20RouteSolveQuote.ts,localRouteQuote.ts,quoteDebounce.ts,pages/SwapPage.tsx,components/trade/TradeMarketOrderPanel.tsx.indexer/tests/indexer_ingestion_hardening.rs,book_snapshot_loop.rs,route_local_quotes_1452.rs,api_route_solve.rs,api_route_exact_output.rs,api_route_tax_funding1381.rs,api_health.rs;scripts/qa/browser-local-quotes-1452.cjs.docs/route-solver.md,docs/runbooks/indexer-database-isolation.md,skills/AGENTS_LOCAL_SWAP_QUOTES.md,AGENTS_LIQUIDITY_FEED.md,AGENTS_PAIR_DISCOVERY_CACHE.md,AGENTS_CHAIN_ATTESTATION.md.Recommended direction
Constraints and guardrails
Acceptance criteria
/best, POST, progress, reference, refresh and reviewed-route preparation; zero request-triggered upstream calls. Background cadence is bounded and cannot be accelerated by request traffic.Functional test plan: all paths
/best, POST, progress, receive-targetUse deterministic mocked providers and clocks, real disposable Postgres/socket fixtures, and funded LocalTerra execution for quote/settlement parity. Production verification stays read-only; do not broadcast mainnet transactions for reproduction.
Attack, hack and abuse test plan
Verification criteria and completed investigation
Completed before filing:
fjsearches.736be444100ba84887a6619336c83d2848258884:cargo test --locked --manifest-path indexer/Cargo.toml --lib lcd:: -- --test-threads=1— 55 passed, 0 failed, 1 ignored. The ignored benchmark was executed separately withcargo test --locked --manifest-path indexer/Cargo.toml --lib lcd::pair_discovery_state::tests::pair_discovery_cache_benchmark -- --ignored --nocapture --test-threads=1: 1 passed, 0 failed. Its cache microbenchmark does not measure useful API quote latency.api::local_quote— 45 passed, 0 failed. These are existing baseline tests, not regression proof for this defect or the newer deployed revision.Implementation verification must run the new focused verifier and applicable
make verify-issue-1452,verify-issue-1453,verify-issue-1394,verify-issue-1392andverify-issue-1396checks. Record exact revision, UTC times, commands, counts, original observation ages/generations, checkpoint/hash, bounded provider/cache/job counters and latency distributions/maxima. Count actual upstream calls; verify browser/socket useful output and settlement parity rather than status codes alone.Complete feasible checks first. Unavailable deployment, history, device or fixture checks may be explicit SKIP with the precise missing evidence and remaining scope; they do not block issue creation or implementation review. Executed failures remain FAIL until corrected and successfully rerun. Passing local tests, liveness or one successful quote never establish sustained deployed trading acceptance. Publish sanitized technical findings only; no conversation or reporter data is part of this issue.
The 2026-10-15 repository reconciliation recovered the remaining local branch history and inspected the stale worktrees/stash. The browser lifecycle and execution-readiness merge commits introduce no new product changes relative to current main; newer policies and issue links are retained. The route-discovery stash is already incorporated by
1536631292and subsequent actor-inventory safety corrections, so the stale snapshot was not reapplied.Four differing historical QA records are preserved separately in docs/qa/merge-reconciliation-2026-10-15/recovered, with provenance/checksums in recovery-manifest.json. Current canonical receipts and artifact checksum lists remain in place. Private ignored configuration/artifacts and original recovery files were saved outside Git before the merged worktrees/branches/stash were removed. No production or shared database was reset, and no deployment/settlement claims are added. This completed implementation issue remains closed; outstanding live implementation work stays in its existing follow-up issues.
Final local verifiers passed: #1489 = 20 PASS / 0 FAIL / 2 explicit acceptance SKIP; #1483 = 21 PASS / 0 FAIL / 2 explicit acceptance SKIP. The first runs retained stale-database PoolTimedOut failures; complete reruns on a fresh owned fixture passed. The fixture was removed afterward. CI was explicitly skipped; details are in docs/qa/merge-reconciliation-2026-10-15/verification.json.