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

chore(bolt-sidecar): extract compute_diffs() #490

Merged
merged 4 commits into from
Nov 29, 2024
Merged

chore(bolt-sidecar): extract compute_diffs() #490

merged 4 commits into from
Nov 29, 2024

Conversation

estensen
Copy link
Contributor

validate_request() is very long and hard to follow, so breaking it up and adding tests

@estensen estensen marked this pull request as draft November 28, 2024 16:15
Copy link
Contributor

@thedevbirb thedevbirb left a comment

Choose a reason for hiding this comment

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

I like the idea

Comment on lines 634 to 656
let mut block_templates = HashMap::new();
let sender = Address::random();

let mut diffs = HashMap::new();
diffs.insert(sender.clone(), (1, U256::from(2)));

let mut state_diff = StateDiff::default();
state_diff.diffs = diffs.clone();

let block_template = BlockTemplate { state_diff, signed_constraints_list: vec![] };

block_templates.insert(10, block_template);

let (nonce_diff, balance_diff, highest_slot) = compute_diffs(&block_templates, &sender);

assert_eq!(nonce_diff, 1);
assert_eq!(balance_diff, U256::from(2));
assert_eq!(highest_slot, 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add comments for the steps, so that I can read the test without simulating the code in my head?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't run a RISCV VM in your head in 2024? ngmi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

better now?

@estensen estensen marked this pull request as ready for review November 29, 2024 15:01
@estensen estensen merged commit 0c4746c into unstable Nov 29, 2024
4 checks passed
@thedevbirb thedevbirb deleted the extract2 branch November 29, 2024 15:27
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.

3 participants