Indexer hybrid route optimizer: pass book_start_hint for first live-side order (#332) #816
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!816
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "cursor/gitlab-issue-workflow-0541"
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
Implements GitLab #332 (follow-up to #289).
The
global_v2hybrid route optimizer now resolves the first live resting order on the taker's match side from a fresh Postgres mirror and forwards thatorder_idasbook_start_hintthrough:simulate_hybrid_from_mirror(book walk starts at hinted order when valid same-side)HybridSimulationqueries during optimization (when mirror fresh)HybridHopJson/router_operationswhenbook_input > 0Stale or missing mirror → hint omitted (
null); LCD fallback grid never emits hints. Pool-only hops →null. Wrong-side corrupt mirror rows are skipped.Acceptance checklist
optimize_hop_hybridsetsbook_start_hintto first live-side order id when book leg > 0 and mirror freshcargo test --test api_route_solve_db_hybrid route_solve_db_hybrid_book_start_hint_paths(live head + expired-head scenarios)HybridSimulationqueries use same hint as output opshybrid_sim_query+optimize_one_hopshare resolved hint; integration test asserts router op hint matchesbook_start_hint: nullfirst_live_book_start_hintunit testsapi_route_solvetests updatedroute_solve_db_hybrid_book_start_hint_paths; existingapi_route_solvesuite greendocs/route-solver.mdglossary + skills updatedcargo test --test api_route_solvegreencd indexer && cargo test --test api_route_solve --test api_route_solve_db_hybrid -- --test-threads=1POST /route/solvenon-null hintVerification for third parties
Related docs
docs/route-solver.md—book_start_hintglossary entryskills/AGENTS_INDEXER_HYBRID_BEST_EXECUTION.mdskills/AGENTS_BOOK_MATCH_HINT_SECURITY.mdchanged the description
changed the description
mentioned in issue #332
changed the description
Security review (automated)
Commit reviewed:
63640f1c746b9adbaacf4a299eeef69f345b2c91Scope: MR !816 — indexer
global_v2hybrid route optimizer:book_start_hintresolution from fresh Postgres mirror, mirror book-walk slicing, LCDHybridSimulationhint forwarding (fresh mirror only), docs/skills/tests.Outcome:
FINDINGS: 0(no medium, high, or critical issues on this diff)Inline threads: none (no findings to anchor)
Summary
Reviewed added/modified logic in
indexer/src/api/db_orderbook_sim.rs,indexer/src/api/hybrid_route_opt.rs, and related tests/docs. Traced attacker-controlled inputs onGET|POST /api/v1/route/solveto sinks.Controls observed (adequate for this change):
book_start_hintis derived from indexer-owned mirror rows (resting_limit_orders/HopMirror), not from route-solve query/body parameters. Clients can still supply hints via existingPOST hybrid_by_hop(unchanged by this MR).first_live_book_start_hintandbook_orders_from_hintrequireorder.side == expected_sideon the correct bid/ask list; wrong-side mirror rows are skipped. Matches on-chainresolve_match_start_hint/order_on_match_side(#272).MirrorFreshness != Fresh; LCD fallback grid explicitly passesNonefor hints.router_operationshints are advisory; contract L17 remains authoritative — invalid/wrong-side/stale hints fall back to head without cross-side escrow debit (existing contract tests).u64order id in JSON LCD queries; no new user-controlled strings, endpoints, or LCD budget expansion beyond existing hybrid grid.Not reported (out of scope / below bar): governance trust in mirror freshness, quote-vs-execute drift from indexing lag (mitigated by staleness gates + on-chain validation), and pre-existing POST
hybrid_by_hopclient-supplied hints.Security review: no medium+ findings on this diff.
mentioned in commit
8edf0509e5mentioned in commit
eaa159e0b4mentioned in commit
9dff5487b1