-
Notifications
You must be signed in to change notification settings - Fork 58
blockifier: update blake estimation for empty input #8323
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
blockifier: update blake estimation for empty input #8323
Conversation
d4ad56b
to
889351d
Compare
b99fe38
to
0c14c35
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.
Reviewed 3 of 3 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @noaov1)
crates/blockifier/src/execution/execution_utils_test.rs
line 34 at r2 (raw file):
#[test] fn test_zero_inputs() { // TODO(AvivG): Re-check this case in VM — input 0 was previously invalid when this estimation
Can you remove it now?
Code quote:
// TODO(AvivG): Re-check this case in VM — input 0 was previously invalid when this estimation
crates/blockifier/src/execution/execution_utils.rs
line 449 at r2 (raw file):
if total_u32s == 0 { return blake_estimation::STEPS_EMPTY_INPUT; }
if total_u32s == 0 {
return blake_estimation::STEPS_EMPTY_INPUT;
}
Suggestion:
if total_u32s == 0 {
// The empty input case is a special case.
return blake_estimation::STEPS_EMPTY_INPUT;
}
crates/blockifier/src/execution/execution_utils.rs
line 472 at r2 (raw file):
let n_felts = n_big_felts.checked_add(n_small_felts).expect("Overflow computing total number of felts"); let builtin_instance_counter = if n_felts == 0 {
Personally, I prefer match here (non-blocking)
crates/blockifier/src/execution/execution_utils.rs
line 473 at r2 (raw file):
n_big_felts.checked_add(n_small_felts).expect("Overflow computing total number of felts"); let builtin_instance_counter = if n_felts == 0 { HashMap::new()
Suggestion:
let builtin_instance_counter = if n_felts == 0 {
// The empty case does not use builtins at all.
HashMap::new()
crates/blockifier/src/execution/execution_utils.rs
line 475 at r2 (raw file):
HashMap::new() } else { // One `range_check` per input felt to validate its size + Overhead.
Suggestion:
// One `range_check` per input felt to validate its size + Overhead for the non empty case..
crates/blockifier/src/execution/execution_utils.rs
line 488 at r2 (raw file):
/// This includes: /// - ExecutionResources gas. /// - Blake opcode gas.
What do you mean here?
Why is the Blake opcode gas separated from the others?
Code quote:
/// This includes:
/// - ExecutionResources gas.
/// - Blake opcode gas.
crates/blockifier/src/execution/execution_utils.rs
line 514 at r2 (raw file):
This breaks the assumption that builtin costs are identical between provers.", ); }
I prefer something like it.
Suggestion:
assert!(
vm_resources
.builtin_instance_counter
.keys()
.all(|&k| k == BuiltinName::range_check),
"Expected either empty builtins or only `range_check` builtin, got: {:?}. \
This breaks the assumption that builtin costs are identical between provers.",
vm_resources.builtin_instance_counter.keys().collect::<Vec<_>>()
);
0c14c35
to
669d234
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: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @AvivYossef-starkware and @noaov1)
crates/blockifier/src/execution/execution_utils.rs
line 449 at r2 (raw file):
Previously, AvivYossef-starkware wrote…
if total_u32s == 0 {
return blake_estimation::STEPS_EMPTY_INPUT;
}
Added
crates/blockifier/src/execution/execution_utils.rs
line 472 at r2 (raw file):
Previously, AvivYossef-starkware wrote…
Personally, I prefer match here (non-blocking)
This way?
crates/blockifier/src/execution/execution_utils.rs
line 488 at r2 (raw file):
Previously, AvivYossef-starkware wrote…
What do you mean here?
Why is the Blake opcode gas separated from the others?
Is it clearer now? Does the modification to the comment answer your question?
crates/blockifier/src/execution/execution_utils.rs
line 514 at r2 (raw file):
Previously, AvivYossef-starkware wrote…
I prefer something like it.
no prob, replaced
crates/blockifier/src/execution/execution_utils_test.rs
line 34 at r2 (raw file):
Previously, AvivYossef-starkware wrote…
Can you remove it now?
definatly
crates/blockifier/src/execution/execution_utils.rs
line 473 at r2 (raw file):
n_big_felts.checked_add(n_small_felts).expect("Overflow computing total number of felts"); let builtin_instance_counter = if n_felts == 0 { HashMap::new()
Added
crates/blockifier/src/execution/execution_utils.rs
line 475 at r2 (raw file):
HashMap::new() } else { // One `range_check` per input felt to validate its size + Overhead.
Changed.
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.
Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @noaov1)
crates/blockifier/src/execution/execution_utils.rs
line 472 at r2 (raw file):
Previously, avivg-starkware wrote…
This way?
Yes
crates/blockifier/src/execution/execution_utils.rs
line 488 at r2 (raw file):
Previously, avivg-starkware wrote…
Is it clearer now? Does the modification to the comment answer your question?
Why is Blake's opcode not part of the ExecutionResources
?
Is it a problem of the VM?
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:
complete! all files reviewed, all discussions resolved (waiting on @noaov1)
crates/blockifier/src/execution/execution_utils.rs
line 488 at r2 (raw file):
Previously, AvivYossef-starkware wrote…
Why is Blake's opcode not part of the
ExecutionResources
?
Is it a problem of the VM?
--- continued discussion via Slack
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.
Reviewed 1 of 2 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @avivg-starkware)
No description provided.