-
Notifications
You must be signed in to change notification settings - Fork 25
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(blockifier): add get_syscall_gas_cost to versioned constants impl #2188
feat(blockifier): add get_syscall_gas_cost to versioned constants impl #2188
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Artifacts upload triggered. View details here |
for now, returning zero by default in the case of unsupported builtin. Would love to consider a better way to handle this error. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2188 +/- ##
===========================================
+ Coverage 40.10% 68.84% +28.74%
===========================================
Files 26 108 +82
Lines 1895 14025 +12130
Branches 1895 14025 +12130
===========================================
+ Hits 760 9656 +8896
- Misses 1100 3956 +2856
- Partials 35 413 +378 ☔ View full report in Codecov by Sentry. |
will change the magic numbers to one of two options: The problem with the first option is that it will require maintenance every time the values in the json will change. |
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 2 files reviewed, 4 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)
crates/blockifier/src/versioned_constants.rs
line 347 at r1 (raw file):
Previously, Yonatan-Starkware wrote…
for now, returning zero by default in the case of unsupported builtin. Would love to consider a better way to handle this error.
It's okay to panic. All builtins should be there.
crates/blockifier/src/versioned_constants.rs
line 337 at r1 (raw file):
/// Calculates a syscall's gas costs from the os resources pub fn get_syscall_gas_cost(&self, syscall_selector: &SyscallSelector) -> u64 { let constant_gas_costs = &self.os_constants.gas_costs;
Suggestion:
gas_costs
crates/blockifier/src/versioned_constants.rs
line 343 at r1 (raw file):
.get(syscall_selector) .expect("Fetching the execution resources of a syscall should not fail."); let n_steps = std::cmp::max(u64_from_usize(execution_resources.n_steps), 100);
The max should be with syscall_base_gas_cost
.
We should take the max at the end of the calculation. This will require further changes in python.
cc @meship-starkware
Suggestion:
// The minimum total cost is `syscall_base_gas_cost`, which is pre-charged by the compiler.
let n_steps = std::cmp::max(u64_from_usize(execution_resources.n_steps), 100);
1624253
to
4bae353
Compare
Previously, Yoni-Starkware (Yoni) wrote…
Done. |
2441d87
to
54def71
Compare
86f183e
to
215da8b
Compare
Artifacts upload triggered. View details here |
54def71
to
2f133bb
Compare
215da8b
to
2ea8126
Compare
2f133bb
to
7f1ff03
Compare
2ea8126
to
7363e9e
Compare
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
7363e9e
to
9024d8b
Compare
Artifacts upload triggered. View details here |
7f1ff03
to
87d6285
Compare
9024d8b
to
9b0da15
Compare
87d6285
to
5d273b8
Compare
9b0da15
to
031e2fa
Compare
8e62d52
to
3aa46ab
Compare
Previously, meship-starkware (Meshi Peled) wrote…
for now the function is just there, nothing call it. so by adding the test i verify that it works correctly, and prevent the error of it being unused |
3aa46ab
to
dbae55c
Compare
9619604
to
640e1dc
Compare
dbae55c
to
58755ee
Compare
58755ee
to
d7b5bc8
Compare
640e1dc
to
7072ab0
Compare
d7b5bc8
to
c0ec97c
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 all commit messages.
Reviewable status: 0 of 2 files reviewed, 6 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)
crates/blockifier/src/versioned_constants.rs
line 343 at r1 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
this will break Python. Lets put in the Os_constants the number according to the calculation without the max and add the maximum where needed. @Yoni-Starkware WDYT?
@meship-starkware why? he is not using this func yet
@Yonatan-Starkware please add my comment.
crates/blockifier/src/versioned_constants.rs
line 335 at r3 (raw file):
} /// Calculates a syscall's gas costs from the os resources
Suggestion:
/// Calculates the syscall gas cost from the OS resources.
crates/blockifier/src/versioned_constants.rs
line 346 at r3 (raw file):
let n_memory_holes = u64_from_usize(execution_resources.n_memory_holes); let mut total_builtin_gas_cost: u64 = 0; for (builtin, amount) in &execution_resources.builtin_instance_counter {
Use rust style instead (iter + map + sum)
Code quote:
let mut total_builtin_gas_cost: u64 = 0;
for (builtin, amount) in &execution_resources.builtin_instance_counter {
crates/blockifier/src/versioned_constants.rs
line 349 at r3 (raw file):
let builtin_cost = gas_costs .get_builtin_gas_cost(builtin) .unwrap_or_else(|err| panic!("Failed to get gas cost: {}", err));
Suggestion:
(|err| panic!("Failed to get gas cost: {}.",
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 2 files reviewed, 6 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)
crates/blockifier/src/versioned_constants_test.rs
line 177 at r1 (raw file):
Previously, Yonatan-Starkware wrote…
for now the function is just there, nothing call it. so by adding the test i verify that it works correctly, and prevent the error of it being unused
Sounds good
crates/blockifier/src/versioned_constants_test.rs
line 172 at r3 (raw file):
#[test] fn test_correct_syscall_gas_cost_calculation() {
Suggestion:
fn test_syscall_gas_cost_calculation() {
there is already a coma in the error mesegge itself. |
Previously, Yonatan-Starkware wrote…
the messege that goes into the curly braces |
7bf221e
to
03ea98e
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 2 files reviewed, 4 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yonatan-Starkware)
crates/blockifier/src/versioned_constants.rs
line 343 at r4 (raw file):
.get(syscall_selector) .expect("Fetching the execution resources of a syscall should not fail."); // The minimum total cost is `syscall_base_gas_cost`, which is pre-charged by the compiler.
Move the message down to the cmp
Code quote:
// The minimum total cost is `syscall_base_gas_cost`, which is pre-charged by the compiler.
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 1 files at r5, all commit messages.
Reviewable status: 1 of 2 files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @Yonatan-Starkware)
crates/blockifier/src/versioned_constants.rs
line 343 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
@meship-starkware why? he is not using this func yet
@Yonatan-Starkware please add my comment.
Oh, I see; I'll add a Monday task to change the Python accordingly.
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.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @Yonatan-Starkware)
03ea98e
to
e5ebc1e
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 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware and @Yonatan-Starkware)
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 @avi-starkware)
No description provided.