Indexer: short-circuit empty-book hybrid grid + stop LCD 500 fan-out on CosmWasm rejects #493
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#493
Loading…
Add table
Add a link
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?
Summary
Follow-ups from production Ember→Coral swap latency on
dex.cl8y.com/indexer.dex.cl8y.com(while still onglobal_v3).Ops note:
ROUTE_SOLVER_DB_HYBRID=1(global_v4) has been enabled on prod and is redeploying — that is the main latency fix (#319). This issue covers two remaining hardening items that still matter under LCD fallback / flaky public LCDs.Related: #485 (distant-pair latency / progress), #491 (prod indexer 503), ADR 0002 /
docs/route-solver.md.Evidence (pre–DB-hybrid redeploy)
Cold
GET /api/v1/route/solvefor mainnet EMBER→CORAL (direct pair exists):global_v3)quote_kind=indexer_pool_lcd,hybrid: null(pool-only)pool_only=trueIndexer log pattern:
estimate_lcd_calls: 17 + 2×17 per hop).Public LCD smart-query samples were ~0.3–0.6s each; sequential grid explains the ~5s cold path.
1) Short-circuit empty-book / pool-winning hops
Problem
optimize_one_hop/optimize_multihop_hybrid_jointalways runs the full 17 book fractions grid, then 2 coordinate passes, even when:book_input = 0after the first pass.Under
global_v3this is dozens of sequential LCDHybridSimulationcalls. Underglobal_v4it is cheaper but still wasted CPU on empty books; LCD fallback paths remain expensive when mirrors are stale/missing.Proposed behavior
Without shrinking documented optimality bounds for hops that do have a live book:
book_input = 0on a 1-hop path, skip further coordinate passes (they re-run the same empty-book grid).solver_version/optimality_scopehonest; document any early-exit inhybrid_notes/ route-solver docs if behavior is user-visible.Code map
indexer/src/api/hybrid_route_opt.rs—optimize_one_hop,optimize_multihop_hybrid_joint,GRID_POINTS=17indexer/src/api/best_execution.rs—estimate_lcd_calls, candidate evaluationindexer/src/api/db_orderbook_sim.rs— mirror / resting orders for DB short-circuitAcceptance
db_hybrid_queries/ actual LCD fallback counters in tests).docs/route-solver.md/ invariants note the short-circuit.2) Stop LCD 500 fan-out on CosmWasm rejects
Problem
In
indexer/src/lcd/mod.rs, only a narrow set of HTTP 500 bodies are treated as deterministic contract rejects (pair not found,unknown variant,error parsing into type). Other CosmWasm 500s:Observed during Ember→Coral quoting when all three endpoints returned 500 on
/cosmwasm/....Proposed behavior
ContractQueryRejected(or equivalent) without trying sibling endpoints.Acceptance
indexer/src/lcd(wiremock) for reject-vs-failover.Out of scope
ROUTE_SOLVER_DB_HYBRIDon prod (already done / in progress).terrausd.usdoracle parse warnings (unrelated to quote path).Test plan
After deploy: cold Ember→CORAL (and an empty-book pair) should not show multi-endpoint 500 WARN storms; hybrid metadata should show far fewer LCD fallbacks when the book is empty.
marked as related to #485
marked as related to #491
mentioned in commit
f959c3ef57mentioned in merge request !1033
mentioned in merge request !1035
mentioned in commit
f03076c215mentioned in commit
5887679ffbmentioned in commit
61162b47d9