-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat: Add a vec of trait datasources to historical data fetcher #13
Conversation
Benchmark results for
|
Date (UTC) | 2024-07-09T04:28:52+00:00 |
Commit | 5f37b721a20f19fd8a3768848a462cabdc536fb2 |
Base SHA | b2cb71773c8d0c679ff56cd39b79010e6a48ed34 |
Significant changes
Benchmark | Mean | Status |
---|---|---|
MEV-Boost SubmitBlock serialization/JSON encoding | -8.12% | Performance has improved. |
#[async_trait] | ||
pub trait Datasource: std::fmt::Debug { | ||
async fn get_data(&self, block: BlockRef) -> eyre::Result<Vec<OrdersWithTimestamp>>; | ||
fn clone_box(&self) -> Box<dyn Datasource>; |
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.
Why this instead of making Datasource Clonable (the same way it has std::fmt::Debug)?
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.
I tried it but it does not work. Do not have enough context in Rust to know. This was generated by Claude but also a common pattern I found for this use case of storing vec<box>>
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.
dyn can't be used with Clonable since it's Sized :(.
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.
We use Source with S upper case in several places can we call it DataSource?
get_data -> get_orders?
## 📝 Summary Builds on top of #13. This PR moves the initialisation of the mempool dumpster to the mempool dumpster datasource itself. Before, it was on the fetch command. This also enables a unit test that was ignored before. --- ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [x] Added tests (if applicable)
## 📝 Summary Builds on top of #13. This PR moves the initialisation of the mempool dumpster to the mempool dumpster datasource itself. Before, it was on the fetch command. This also enables a unit test that was ignored before. --- ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [x] Added tests (if applicable)
📝 Summary
This PR removes the hardcoded data sources in the HistoricalDataFetcher and replaces them with a dynamic Datasource trait.
💡 Motivation and Context
Before, the two main data sources (mempool dumpster, fb relay) were hardcoded in the HistoricalDataFetcher service. Now, the structure is more flexible and new data sources can be plugged into the HistoricalDataFetcher without any changes to it.
✅ I have completed the following steps:
make lint
make test