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

feat: Add a vec of trait datasources to historical data fetcher #13

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

ferranbt
Copy link
Contributor

@ferranbt ferranbt commented Jul 3, 2024

📝 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:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

Copy link

github-actions bot commented Jul 3, 2024

Benchmark results for 5f37b72

Report: https://flashbots-rbuilder-ci-stats.s3.us-east-2.amazonaws.com/benchmark/5f37b72-b2cb717/report/index.html

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.

@metachris metachris changed the title Add a vec of trait datasources to historical data fetcher feat: Add a vec of trait datasources to historical data fetcher Jul 3, 2024
#[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>;
Copy link
Contributor

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)?

Copy link
Contributor Author

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>>

Copy link
Contributor

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 :(.

Copy link
Contributor

@ZanCorDX ZanCorDX left a 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?

@ZanCorDX ZanCorDX merged commit db634fc into develop Jul 10, 2024
2 checks passed
@ZanCorDX ZanCorDX deleted the ferranbt/extract-backtest-datasources branch July 10, 2024 14:37
ferranbt added a commit that referenced this pull request Jul 15, 2024
## 📝 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)
MoeMahhouk pushed a commit that referenced this pull request Jul 29, 2024
## 📝 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)
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.

4 participants