Background
In review of #4469, jmg-duarte asked whether we can refactor quoting so it always uses the stream, with the current optimal and fast paths accumulating results and applying their ranking and filters on top. Opening this so we do not lose track of the idea.
Review thread: #4469 (review)
Idea
Make estimate_stream the single base primitive. Rebuild optimal and fast as consumers of that stream: collect the per-solver results as they arrive, then apply ranking, early return, and verification on top, instead of the separate estimate path they run today.
What the persistence layer changes
Since that review, #4579 landed the persistence layer (docs: cowprotocol/docs#638), so the plan should account for it:
- The stream now persists one row per solver, while optimal persists one row (the winner) and fast persists nothing. A unified path has to pick a single persistence model or keep them separate on purpose. Persisting per-solver for every quote would multiply inserts and the expiry deletes on the
quotes table, which already carries heavy index bloat, so that choice should be deliberate.
find already ranks stored quotes by best rate net of fee and prefers verified ones, so an order reuses the best quote no matter which path stored it. Keep that invariant if the paths merge.
Related cleanup from the same review
jmg-duarte also flagged that the streaming quoter is an Option threaded deep into QuoteHandler. He suggested either a StreamQuoteHandler that wraps the regular handler, or a required no-op implementation when streaming is not configured. A unified design probably removes the Option on its own.
Links
Background
In review of #4469, jmg-duarte asked whether we can refactor quoting so it always uses the stream, with the current optimal and fast paths accumulating results and applying their ranking and filters on top. Opening this so we do not lose track of the idea.
Review thread: #4469 (review)
Idea
Make
estimate_streamthe single base primitive. Rebuild optimal and fast as consumers of that stream: collect the per-solver results as they arrive, then apply ranking, early return, and verification on top, instead of the separateestimatepath they run today.What the persistence layer changes
Since that review, #4579 landed the persistence layer (docs: cowprotocol/docs#638), so the plan should account for it:
quotestable, which already carries heavy index bloat, so that choice should be deliberate.findalready ranks stored quotes by best rate net of fee and prefers verified ones, so an order reuses the best quote no matter which path stored it. Keep that invariant if the paths merge.Related cleanup from the same review
jmg-duarte also flagged that the streaming quoter is an
Optionthreaded deep intoQuoteHandler. He suggested either aStreamQuoteHandlerthat wraps the regular handler, or a required no-op implementation when streaming is not configured. A unified design probably removes theOptionon its own.Links