fix(indexer): skip zero-reserve path candidates in DB hybrid route solve (#369) #890
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!890
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/indexer-369-skip-zero-reserve-path"
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
InsufficientLiquidity(zero pool reserves) instead of failing the wholeGET /route/solverequest with 502.route_solve_db_hybrid_skips_zero_reserve_path_candidateand document invariant indocs/indexer-invariants.md+skills/AGENTS_INDEXER_HYBRID_BEST_EXECUTION.md.Acceptance checklist
GET /api/v1/route/solveno longer 502s when a candidate path touches a zero-reserve pair but a direct route is viable (DB hybrid)cd indexer && cargo test --test api_route_solve_db_hybrid route_solve_db_hybrid_skips_zero_reserve_path_candidate -- --test-threads=1→ 200, 1-hop direct path, non-zeroestimated_amount_outGET /api/v1/route/solve/bestsame behavior/route/solveand/route/solve/bestcd indexer && cargo test --test api_route_solve --test api_route_solve_db_hybrid --test db_orderbook_mirror -- --test-threads=1→ 31 passedhybrid_sim_gateway_errunchanged for non-InsufficientLiquidityerrors; existingconcurrent_eval_fail_fast_aborts_remaining_tasksunit test retaineddocs/indexer-invariants.md,skills/AGENTS_INDEXER_HYBRID_BEST_EXECUTION.mdTest plan
route_solve_db_hybrid_skips_zero_reserve_path_candidate--test-threads=1)changed the description
changed the description
Security review — MR !890
Commit reviewed:
22384600fb238b9ef4a63adfe097163452715ac6Scope: DB hybrid route solve (
global_v4) — skip path candidates whose Postgres mirror sim returnsInsufficientLiquidity(zero pool reserves) instead of failing the wholeGET /route/solverequest with 502; map all-unviable candidate sets to 404.Method: Traced attacker-controlled inputs (
token_in,token_out,amount_in, optionaltrader/sender) throughevaluate_candidate→optimize_multihop_hybrid_joint→is_unviable_path_sim_err→run_concurrent_candidate_evaluations→merge_candidate_evaluations/apply_fidelity_guard. Verified mirror write paths (pair_reservesvia indexerbook_snapshotloop only, not HTTP).Outcome:
FINDINGS: 0medium+Notes (not findings):
HybridSimError::Db(InsufficientLiquidity)on a fresh mirror when pool leg input is non-zero; stale/missing mirrors still LCD-fallback; LCD and other DB errors remain fail-fast (502).maybe_simulateand existingapply_fidelity_guard— no new quote-inflation path introduced by this diff.Inline threads: none (no medium+ findings).
Prior review comments: none on this MR; nothing to re-report.
added 84 commits
main43853ec6- Merge origin/main into fix/indexer-369-skip-zero-reserve-pathCompare with previous version
Resolved merge conflicts with
mainby adopting main's #369 implementation (PathUnusable,pool_only_or_zero, concurrent candidate skip + fail-fast only when all paths fatal). Dropped duplicate MR-branch regression test helper; kept main'sseed_route_solve_zero_reserve_poisontest.cargo checkpasses on indexer.changed the description
Security review — MR !890
Commit reviewed:
43853ec6a421922a514941af31789f4cce74b8a1Scope: DB hybrid route solve (
global_v4) — skip path candidates whose Postgres mirror sim returnsInsufficientLiquidity(zero pool reserves) instead of failing the wholeGET /route/solvewith 502; return 404 when no viable candidate remains. MR head is tree-identical to base52748e1(merge-only); substantive logic reviewed at HEAD inbest_execution.rs/hybrid_route_opt.rs(commit2238460).Method: Re-traced attacker-controlled inputs (
token_in,token_out,amount_in, optionaltrader/sender) throughevaluate_candidate→optimize_multihop_hybrid_joint→run_concurrent_candidate_evaluations→merge_candidate_evaluations/apply_fidelity_guard/maybe_simulate. Confirmedpair_reservesmirror writes remain indexer-only (book_snapshotloop), not HTTP-writable.Outcome:
FINDINGS: 0medium+Notes (not findings):
HybridSimError::Db(InsufficientLiquidity)andPathUnusable; other DB/LCD errors still surface as 502 when every evaluated candidate fails fatally.maybe_simulateout_u;apply_fidelity_guardstill caps mirror/grid drift — no new quote-inflation sink.MAX_PATH_CANDIDATES= 5, rate-limited/route/solve); continuing past skipped candidates is not an unbounded DoS vector.Inline threads: none (no medium+ findings).
Prior review: commit
2238460review (2026-06-13) — findings still do not apply on current SHA; no new issues introduced.mentioned in commit
bfd30abba9