-
Notifications
You must be signed in to change notification settings - Fork 61
blockifier: move logic inside casm_v2hash_resource_estimate #8694
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
base: avivg/blockifier/encode_blake_into_trait
Are you sure you want to change the base?
blockifier: move logic inside casm_v2hash_resource_estimate #8694
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
f01435a
to
9d6cd2b
Compare
a3db1a9
to
7afade2
Compare
9d6cd2b
to
6005d15
Compare
7afade2
to
af6faaa
Compare
6005d15
to
1305fdd
Compare
1305fdd
to
e0cd0c5
Compare
af6faaa
to
511a4db
Compare
511a4db
to
d4ea96b
Compare
e0cd0c5
to
bad4524
Compare
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.
Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion
crates/blockifier/src/execution/casm_hash_estimation.rs
line 276 at r2 (raw file):
.expect("Overflow computing small felt steps"); big_steps.checked_add(small_steps).expect("Overflow computing total felt steps") }
inserted this logic directly to estimate_steps_of_encode_felt252_data_and_calc_blake_hash
and removed redundant "checked arithmetic"
Code quote:
fn base_steps_for_blake_hash(n_u32s: usize) -> usize {
let rem_u32s = n_u32s % FeltSizeCount::U32_WORDS_PER_MESSAGE;
if rem_u32s == 0 {
blake_estimation::BASE_STEPS_FULL_MSG
} else {
// This computation is based on running blake2s with different inputs.
// Note: all inputs expand to an even number of u32s --> `rem_u32s` is always even.
blake_estimation::BASE_STEPS_PARTIAL_MSG
+ (rem_u32s / 2) * blake_estimation::STEPS_PER_2_U32_REMINDER
}
}
fn felts_steps(n_big_felts: usize, n_small_felts: usize) -> usize {
let big_steps = n_big_felts
.checked_mul(blake_estimation::STEPS_BIG_FELT)
.expect("Overflow computing big felt steps");
let small_steps = n_small_felts
.checked_mul(blake_estimation::STEPS_SMALL_FELT)
.expect("Overflow computing small felt steps");
big_steps.checked_add(small_steps).expect("Overflow computing total felt steps")
}
bad4524
to
8aecc8d
Compare
d4ea96b
to
7568ef4
Compare
8aecc8d
to
8a8597d
Compare
0b986ac
to
f12c23e
Compare
68d0b25
to
eda0a31
Compare
71c9104
to
e4ada08
Compare
eda0a31
to
fe41410
Compare
e4ada08
to
8715ec2
Compare
5a100c2
to
7c34d8a
Compare
8715ec2
to
1a5798f
Compare
7c34d8a
to
a11f641
Compare
1a5798f
to
fa4087c
Compare
No description provided.