-
Notifications
You must be signed in to change notification settings - Fork 89
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
Driver fetches order's app-data #3242
base: main
Are you sure you want to change the base?
Conversation
} | ||
} | ||
|
||
impl Clone for FetchingError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to satisfy BoxRequestSharing
constraints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and thoughtful implementation. Only couple of comments.
@MartinquaXD what is the most important reason not to make app-data part of the auction (I don't fully understand the argument ☝️)? AFAIS the current solution also has a number of cons:
|
The main concern is that this simply doesn't scale. If we keep tagging more and more data onto the auction we just send tons of duplicated data around most of the time.
That's true. Although eventually I'd love if we could use this approach for more information. Conceptually we could send only the order uids plus fee policies. In that world the driver could fetch the open orders once and subscribe to new orders via websockets. This seems like a reasonable approach given that multiple solvers already query the order endpoint for additional data we didn't want to put into the auction.
They would already have to implement support for the entire flashloan feature anyway. I don't think adding a bit of caching logic would be a huge concern for them. IMO Another nice advantage of offloading this logic to the driver is fewer options to break compatibility. The less data with a stable format we send between autopilot and driver the less churn there would be. The only super important data (signed order data) has been stable for a very long time. Whereas the interface between autopilot and driver changed quite a lot already. |
Description
As part of the flashloans support, the driver needs be able to retrieve the order's full app data in order to send flashloans hints to solvers(#3216). This PR introduces an app-data retriever that works as follows:
BoxRequestSharing
, which helps to avoid request duplication.Order
struct, responses with404 Not Found
are also cached asNone
. There is a small amount of orders with empty full app data in the DB, but they still exist.Implementation details and considerations
app_data
among all the orders, so there is no need for a TTL cache since the cache is expected to be hit for the majority of orders.2000
capacity, approximately equal to ~1.5MB of memory.domain::Order
struct. To avoid creating new order structs, theAppData
is converted into an enum, which gets updated accordingly.Rate limiting
The following is only valid for colocated solvers since the API is not rate-limited for the services within the same k8s cluster.
SQL query
This image represents the following data: The left column shows how many unique app data entries have a single auction, whereas the right shows how many auctions have the corresponding amount of unique app data.
The orderbook API RPS is 5. Only 0.05% of auctions have more than 5 unique app data entries. That means there is at most a 0.05% chance that a driver hits the RPS for a single auction, where the actual probability is even lower since some of the hashes will more likely be already cached. That is why the current implementation doesn't contain a rate-limiting mechanism.
Changes
orderbook-url
.app-data
cache size. The feature is disabled by default.How to test
All the current tests pass. New driver tests can be added only once the driver starts sending the collected data to solvers(#3216).
Related Issues
Fixes #3215