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 csv data source #54

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

feat: add csv data source #54

wants to merge 2 commits into from

Conversation

bertmiller
Copy link
Member

πŸ“ Summary

Adds the ability to load orders from a csv

πŸ’‘ Motivation and Context

For backtesting bundles


βœ… I have completed the following steps:

  • [ x] Run make lint
  • [ x] Run make test
  • Added tests (if applicable)

Copy link

github-actions bot commented Jul 13, 2024

Benchmark results for 6b219c8

Report: https://flashbots-rbuilder-ci-stats.s3.us-east-2.amazonaws.com/benchmark/6b219c8-db634fc/report/index.html

Date (UTC) 2024-07-13T11:11:36+00:00
Commit 6b219c85845d6d99c7e91391feb50f48973998b2
Base SHA db634fcb90a6b2fc484e19f02a59a5b74ffeefa2

Significant changes

None

) -> Order {
let uuid_bytes = uuid_num.to_be_bytes();
let tx_with_blobs = TransactionSignedEcRecoveredWithBlobs::new_no_blobs(tx).unwrap();
let bundle = Bundle {
Copy link
Contributor

Choose a reason for hiding this comment

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

Bundle creation is tricky (didn't have time to correct it :().
You should create it with a dummy hash/uuid (Default::default()) and then call hash_slow().

// The csv datasource is one with 10 batches, where batch is a list of transactions
// Since we don't have full "real" blocks, we'll just use the block number to determine the batch
// Thus the usage of mod 10 is just to determine the batch number that we get transactions from, e.g. block 100 corresponds to 0, 101 to 1, 109 to 9, etc.
let batch_number = block.block_number % 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

this 10 should be a constant.
Maybe also some function like batch_number_from_u64() to isolate the % 10?

let mut reader = Reader::from_reader(file);
let mut batches: HashMap<u64, Vec<TransactionSignedEcRecovered>> = HashMap::new();

for result in reader.records() {
Copy link
Contributor

Choose a reason for hiding this comment

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

result -> record


for result in reader.records() {
let record = result?;
if record.len() != 2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

0,1,and 2 could be constants also documenting the format
eg:
/// col 1 contains bla bla
const COL_RAW_RLP_RX = 1
Is col 0 an arbitrary number? Is this some block number?

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.

2 participants