-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
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 like the idea
bolt-sidecar/src/state/execution.rs
Outdated
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); |
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.
Can you add comments for the steps, so that I can read the test without simulating the code in my head?
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.
Can't run a RISCV VM in your head in 2024? ngmi
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.
better now?
validate_request()
is very long and hard to follow, so breaking it up and adding tests