Skip to content

generate and send new auction_id with fast path quotes - #4713

Open
MartinquaXD wants to merge 2 commits into
link-quotes-to-auctionfrom
send-auction-id-in-quotes
Open

generate and send new auction_id with fast path quotes#4713
MartinquaXD wants to merge 2 commits into
link-quotes-to-auctionfrom
send-auction-id-in-quotes

Conversation

@MartinquaXD

Copy link
Copy Markdown
Contributor

Description

To reuse the existing driver /settle logic we need to send an auction id with fast path quotes. That way the driver can cache solutions and later settle solutions like it normally would when we send /settle?auctionId=1234&solutionId=1.

Changes

  • generate new unique auction id for every fast path quote
  • send that auction id in the /quote request
  • documented in openapi spec

@MartinquaXD
MartinquaXD requested a review from a team as a code owner August 6, 2026 21:11
@MartinquaXD

Copy link
Copy Markdown
Contributor Author

@claude

@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Claude finished @MartinquaXD's task in 3m 39s —— View job


PR Review

Nicely scoped wiring change. The wire is backward-compatible in both directions (skip_serializing_if omits the field for old drivers; #[serde(default)] lets an old orderbook talk to a new driver), the orderbook→driver auctionId casing matches (camelCase on both sides), and the debug_assert_eq!(auction_id.is_some(), self.fast_path) invariant is upheld at both call sites. No correctness issues found.

Two inline comments (both minor / discussion-level):

  • Fast-path latency — a per-quote nextval DB round-trip is now on the latency-critical fast path and can't be parallelized with the estimations. Worth confirming it's acceptable or considering id pre-allocation.
  • Duplicate get_next_auction_id in autopilot — the new trait impl duplicates the existing inherent method; suggest delegating to avoid drift.

One thing to fix outside the diff — the commit message is out of sync with the code:

  • It says "For this step every writer still sets None — no behavior change. Step 4 will mint a real id", but this PR already mints real ids via get_next_auction_id() for fast-path quotes (matching the PR description).
  • It claims "adds a serde smoke test covering both branches of the wire's skip_serializing_if", but no such test is present in the diff. Either add the test or drop the claim.

  • Read the pr-review skill and gather PR diff
  • Analyze changes for bugs, correctness, and design issues
  • Post inline comments for findings
  • Post review summary
    · branch send-auction-id-in-quotes

Comment thread crates/shared/src/order_quoting.rs
Comment thread crates/autopilot/src/database/auction.rs Outdated
@MartinquaXD
MartinquaXD force-pushed the link-quotes-to-auction branch from 576e622 to 5aab4ce Compare August 7, 2026 11:24
MartinquaXD and others added 2 commits August 7, 2026 11:31
Threads an `auction_id: Option<i64>` through `price_estimation::Query`
and both sides of the driver `/quote` wire (orderbook-side request DTO
and driver-side receiver DTO). Field is omitted from the wire when
None, so old drivers keep parsing new requests; `#[serde(default)]` on
the driver side lets an old orderbook keep talking to a new driver.

For this step every writer still sets `None` — no behavior change.
Step 4 will mint a real id in `QuoteParameters::to_price_query`.

Also adds a serde smoke test covering both branches of the wire's
`skip_serializing_if`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MartinquaXD
MartinquaXD force-pushed the send-auction-id-in-quotes branch from 851e5a7 to 23d1393 Compare August 7, 2026 11:31
@github-actions

github-actions Bot commented Aug 7, 2026

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:

@MartinquaXD MartinquaXD changed the title feat(quote-wire): add optional auction_id to /quote request DTOs generate and send new auction_id with fast path quotes Aug 7, 2026
Comment on lines +63 to +65
database::auction::get_next_auction_id(&mut ex)
.await
.context("failed to fetch next auction_id")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the fast path id never collides with the full auction id, but we have other readers, probably like reward payouts, analytics, circuit breaker. I just wanted to ensure this won't cause any issues, since they assume this id is always a full auction.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the sequence would ensure that there are no duplicated auction ids. Will double check with them that this will not cause any issues. 👌

Comment thread crates/driver/openapi.yml
auction that will be associated with this quote competition. Only
populated for fast path orders
schema:
type: number

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be a type: integer with format: int64? IIRC, number allows decimals.

@squadgazzz squadgazzz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, assuming the openapi will be adjusted.

@AryanGodara AryanGodara left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some clarifying questons fo rme. Otherwise looks good 👌🏼

/// auction associated with the quote competition
/// for fast path quotes
#[serde(default)]
auction_id: Option<i64>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't we have this as a u32 (i mean, rn it makes sense, just asking for when we first set auction_id, since it's a natural number always) 👀

pub enable_fast_path: bool,
/// auction associated with the given quote for faciliating
/// fast path execution.
pub auction_id: Option<i64>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this in #4678 already. That's ready to merge, so this'll probably need to be rebased after

Comment thread crates/shared/src/order_quoting.rs
.transpose()
}

async fn get_next_auction_id(&self) -> Result<i64> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any risk of infinite recursion here? If the inside func gets renamed? (ie, the one in crates/orderbook/src/database/quotes.rs)
It works rn ofc, just a rust doubt 😅

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.

3 participants