Skip zero-reserve path candidates in DB-hybrid route solve (#369) #878
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!878
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/369-zero-reserve-route-solve-skip"
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
Fixes GitLab #369: under
ROUTE_SOLVER_DB_HYBRID=1,GET /api/v1/route/solveand/bestno longer return 502 "Route mirror simulation failed" when a candidate path touches an unfunded pair (pair_reserves0/0) but a funded direct route exists.MirrorFreshness::EmptyPool(same LCD-fallback bucket as missing/stale mirror).InsufficientLiquidityon a fresh mirror triggers LCD fallback instead of hard-failing the grid point.PathUnusableand are skipped; the best remaining path wins, or 404 when every enumerated path is unusable (no whole-request 502 for this case).Docs/skills updated:
docs/indexer-invariants.md,skills/AGENTS_INDEXER_HYBRID_BEST_EXECUTION.md.Acceptance checklist
cd indexer && cargo test --test api_route_solve_db_hybrid route_solve_db_hybrid_skips_zero_reserve_path_candidate -- --test-threads=1/route/solve/bestsame behaviorcd indexer && cargo test --test api_route_solve_db_hybrid -- --test-threads=1cd indexer && cargo test --test api_route_solve -- --test-threads=1cd indexer && cargo test --lib db_orderbook_sim::tests::zero_reserve_mirror_rejects_pool_legdocs/indexer-invariants.md,skills/AGENTS_INDEXER_HYBRID_BEST_EXECUTION.md8408689Third-party verification
make setup-indexer-postgrescd indexer && cargo test --test api_route_solve_db_hybrid route_solve_db_hybrid_skips_zero_reserve_path_candidate -- --test-threads=1ROUTE_SOLVER_DB_HYBRID=1and zero-reserve pairs inpair_reserves, confirmGET /api/v1/route/solve?token_in=<A>&token_out=<B>&amount_in=1000000returns 200 withsolver_version=global_v4(not 502) when a funded direct pool exists.changed the description
changed the description
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.
Reviewed by Cursor Bugbot for commit
d847275c89. Configure here.Db mirror errors become path skip
Medium Severity
When hop grid search exhausts without a successful candidate, the final
query_pool_only_unifiedfallback maps every non-infra error—includingHybridSimError::Dbfrom mirror simulation—toPathUnusable. That skips the path or yields 404 instead of the documented 502 “Route mirror simulation failed” for indexer mirror/data failures.Additional Locations (1)
indexer/src/api/hybrid_route_opt.rs#L392-L393Reviewed by Cursor Bugbot for commit
d847275c89. Configure here.Security review — MR !878
Commit reviewed:
d847275c8997203b6a2c7447558101ebddc652e2Scope: DB-hybrid route solver changes for GitLab #369 —
EmptyPoolmirror classification, per-hop LCD fallback on zero reserves,PathUnusablepath-candidate skipping, 502→404 when all candidates unusable. Files:best_execution.rs,hybrid_route_opt.rs,db_orderbook_sim.rs, tests/docs.Method: Traced attacker-controlled inputs (
token_in,token_out,amount_in, optionaltrader/sender) through mirror load → hybrid grid → candidate merge → routermaybe_simulate/ fidelity guard. Compared infra vs contract-level LCD error handling and concurrent candidate evaluation behavior.Outcome:
FINDINGS: 0medium+No inline threads (no medium+ findings).
Notes (informational, not findings)
MAX_PATH_CANDIDATES/SOLVE_CONCURRENCY); the winning path still goes through router simulation and, in DB-hybrid mode,apply_fidelity_guarddrift clamping.AllEndpointsFailed,Request) still surface as 502 viais_infra_lcd_error+hybrid_sim_gateway_err; only hop-level “unusable” liquidity (zero pool + failed pool-only fallback) is skipped.pair_reservesare indexer-sourced, not client-writable; zero-reserve topology reflects on-chain pair state, not request injection.Security review: no medium+ findings on this diff.
added 1 commit
24690ae7- fix(indexer): propagate Db mirror errors from pool-only fallbackCompare with previous version
changed the description
resolved all threads
mentioned in commit
d64052c857