Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document solver competition information route #185

Merged
merged 3 commits into from
May 4, 2022
Merged

Conversation

vkgnosis
Copy link
Contributor

@vkgnosis vkgnosis commented May 2, 2022

Part of #127

This is the openapi documentation for the public route showing solver competition information.

Test Plan

CI

@vkgnosis vkgnosis requested a review from a team as a code owner May 2, 2022 11:29
crates/orderbook/openapi.yml Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #185 (6bc1660) into main (3011d69) will increase coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #185      +/-   ##
==========================================
+ Coverage   64.55%   64.57%   +0.02%     
==========================================
  Files         185      185              
  Lines       38602    38602              
==========================================
+ Hits        24920    24928       +8     
+ Misses      13682    13674       -8     

Comment on lines +490 to +494
Returns the settlements submitted by every solver for a specific auction
id. The auction id corresponds to the id external solvers are provided
with. Auction ids are not globally unique, they are reused from time to
time. The backend keeps the competition information for a limited amount
of time.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment by Filius on Discord:

From what I read, auctions (and their solutions) are only stored temporarily on the backend. As a solver developer, the process I would follow to benchmark my solution would be: (i) select an auction ID I would like to benchmark from my own logs, (ii) query solver competition endpoint to obtain maps of solvers -> settlements and (iii) try to understand why the solution with the highest objective value is better than mine. For (iii) I would need to be sure the response I obtained from the endpoint really corresponds to the auction I selected (input -> output). Since auction IDs are not unique, an auction timestamp would help me ensure I am looking at the right auction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to eventually store this information in our database for a long time but it might take a bit longer until we have this implemented. Until then we are planning on using a simple in memory store with some size limit. The auction ids are probably going to be truly unique in the future too but not yet.

Until we have both of that maybe it would reasonable for solver developers to persist the competition information on their own? In their solver implementations they get the auction id and could query the competition info ~a minute after solving and persist it locally.

Copy link

Choose a reason for hiding this comment

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

Agree.

type: number
gas_estimate:
type: number
call_data:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment by Filius on Discord:

With regards to the calldata, I wonder if it would be fair to expose the complete solution provided by solvers. In the information I requested, I explicitly mentioned clearing prices without the actual liquidity sources, so that at least the liquidity sources are kept "hidden". Would it be fair to show everyone what liquidity sources different solvers are using? After all, this is a competition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me it makes sense to treat this as public because if your solution is the winning one it will be public anyway as part of the public transaction on chain.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a very interesting question. Especially solvers with inventory might prefer not to expose their quotes publicly unless they have an upside (winning the batch). I wouldn't want them to not submit a solution if they think their chance of winning is small (but we can also wait and change the model when this happens).

For users however it would definitely be good to see the alternative prices (to highlight the price improvement competition brings) and maybe even simulate and plot the alternative solution. For a solver it might also be helpful to see the full simulation link to debug why the settlement was failing in the driver.

Maybe we start with all public and then adapt if it becomes an issue (winning solver will reveal their logic for sure)?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can start by only exposing name of winning solver while the competition is on-going. This way, other solvers don't have information on:

  • Winning objective value (so they can penny the surplus by making the prices slightly better for the users at the expense of the buffers and their weekly payout - as long as its less than 100 COW - in order to win with a slight advantage)
  • Calldata - the current routes being proposed and liquidity being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It feels like our current goal with this route is to make it easier for external solver creators to get insight into the competition. If that is the goal then we don't need to show anything live. It is enough to only make this information available after a winning settlement has been picked and it has been settled.

If the goal is also to provide information that can be used live for example by the frontend to show a user that their order is part of some solutions or has been picked for the currently settling transaction, then we need to include more information.

I feel that there is little reason to show the competition while we're still collecting solutions from all the solvers. This part only takes 10 seconds. Once the driver has all the settlements and has decided which one the winner is but before waiting for the on chain transaction, we can publish all the information. Since the solutions have been collected there shouldn't be worries about pennying.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the goal is also to provide information that can be used live for example by the frontend to show a user that their order is part of some solutions or has been picked for the currently settling transaction, then we need to include more information.

I think this will eventually be the goal, however I think that we can get around to this once we do it the "right" way (i.e. implement one of your ideas from the discussion #175).

Copy link
Contributor

@nlordell nlordell May 3, 2022

Choose a reason for hiding this comment

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

Created #187 to discuss what the "complete" API can look like for use with the FE (where the current auction status is useful to display some extra information to the user).

Copy link
Contributor

@nlordell nlordell left a comment

Choose a reason for hiding this comment

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

LGTM.

Might also be helpful for us - debugging wise - to include block information of the liquidity_collected_block and competition_simulation_block - but only if its easily accessible. Can also add this later, so approving regardless.

@vkgnosis
Copy link
Contributor Author

vkgnosis commented May 4, 2022

Going to merge now with potentially changing something when I get to the implementation.

@vkgnosis vkgnosis enabled auto-merge (squash) May 4, 2022 10:47
@vkgnosis vkgnosis merged commit c2572ad into main May 4, 2022
@vkgnosis vkgnosis deleted the competition-route branch May 4, 2022 10:50
@github-actions github-actions bot locked and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants