Skip to content

Cache fast-path quote solutions in the driver - #4678

Open
AryanGodara wants to merge 4 commits into
mainfrom
aryan/be-58-cache-quote-solutions
Open

Cache fast-path quote solutions in the driver#4678
AryanGodara wants to merge 4 commits into
mainfrom
aryan/be-58-cache-quote-solutions

Conversation

@AryanGodara

Copy link
Copy Markdown
Member

Description

Fast-path (out-of-competition) execution reuses a quote's solution to settle the matching order during an exclusivity window instead of running a full auction. For that the driver must keep the solution it computes at quote time (rn /quote discards it). Now we cache the fast-path quote solution in the driver, keyed by (auction_id, solution_id), and usesthose ids on the quote response so a later settle can find it.

Why cache the solution and not a ready Settlement: a quote runs against an unsigned order, so a submittable settlement can't be encoded/simulated until the real signed order exists at settle time. (tried this, goes beyond scope of the PR 🤔 )

Changes

  • add a quote_solutions cache to Competition (CachedQuoteSolution { auction, solution }) + cache_quote_solution(): no simulation, bounded like the settlements deque.
  • /quote caches the solution when the quote is fast-path and the request carries an auctionId, and echoes solutionId + auctionId on the response.
  • /quote request accepts auctionId; the handler now passes the whole Competition to Order::quote (was just &risk_detector) so it can reach the cache — the risk-detector filtering is unchanged.
  • add openApi docs and fix the request flag name fastPathenableFastPath to match the code.

Out of scope / follow-ups:

  • Orderbook allocating auctionId from the shared auctions sequence and sending it in the /quote request (BE-56) — not included; the driver accepts the id but nothing supplies one yet
  • Fast-path settle path: read the cache, re-encode against the real signed order, submit (BE-57 / quote-reuse fork)
  • Observer/accounting for fast-path settlements (BE-61)

Related Issues

BE-58

Follow-ups: BE-56, BE-57, BE-61.

@AryanGodara AryanGodara self-assigned this Jul 28, 2026
@linear-code

linear-code Bot commented Jul 28, 2026

Copy link
Copy Markdown

BE-58

@github-actions

Copy link
Copy Markdown

Reminder: Please consider backward compatibility when modifying the API specification.
If breaking changes are unavoidable, ensure:

  • You explicitly pointed out breaking changes.
  • You communicate the changes to affected teams (at least Frontend team and SAFE team).
  • You provide proper versioning and migration mechanisms.

Caused by:

@AryanGodara
AryanGodara marked this pull request as ready for review July 28, 2026 12:45
@AryanGodara
AryanGodara requested a review from a team as a code owner July 28, 2026 12:45
@claude

claude Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Claude finished @AryanGodara's task in 2m 7s —— View job


PR Review: Cache fast-path quote solutions in the driver

  • Read changed files & understand the change
  • Review domain logic (competition cache, quote.rs)
  • Review API DTOs & openapi
  • Review tests

Overall this is a clean, well-scoped change and the code reads well. Caching the solution (not a Settlement) is the right call given the unsigned quote order, the eviction/locking mirrors the existing settlements deque, the API renaming fastPathenableFastPath is a doc fix (not a real break), and the request/response DTOs, openapi, and tests all line up consistently.

One point worth revisiting — posted inline:

  • Cache eviction bound is mis-sized for quotes (competition/mod.rs:558): reusing max_solutions_to_propose() * MAX_CONCURRENT_AUCTIONS (=5) from the settlements cache doesn't map to quote cadence; a cached fast-path solution could be evicted before its /settle arrives in the exclusivity window. Non-blocking since the settle path (BE-57) isn't wired up yet, but worth sizing against expected fast-path quote volume (or a time-based expiry) before it lands.

Nothing else stood out — the fast-path/auction_id gating in quote.rs, the Quote::try_new borrow change, and the serde skip_serializing_if on the new response fields are all correct.

Comment thread crates/driver/src/domain/competition/mod.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant