-
Notifications
You must be signed in to change notification settings - Fork 28
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(blockifier): split builtin gas costs from base gas costs #2514
chore(blockifier): split builtin gas costs from base gas costs #2514
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a4e9622
to
b6948ba
Compare
593d9bc
to
e744b52
Compare
b6948ba
to
347b59e
Compare
f4181f4
to
b57f472
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2514 +/- ##
===========================================
+ Coverage 40.10% 68.14% +28.04%
===========================================
Files 26 105 +79
Lines 1895 14332 +12437
Branches 1895 14332 +12437
===========================================
+ Hits 760 9767 +9007
- Misses 1100 4136 +3036
- Partials 35 429 +394 ☔ View full report in Codecov by Sentry. |
347b59e
to
a0dd2fb
Compare
b57f472
to
faf8f5c
Compare
ad1ba0b
to
a52c253
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 8 of 10 files at r1, 2 of 3 files at r2, all commit messages.
Reviewable status: 10 of 11 files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @Yonatan-Starkware, and @Yoni-Starkware)
crates/blockifier/src/versioned_constants.rs
line 650 at r2 (raw file):
// An estimation of the initial gas for a transaction to run with. This solution is // temporary and this value will be deduced from the transaction's fields. pub default_initial_gas_cost: u64,
This is what the transaction costs were till now, right?
Code quote:
pub default_initial_gas_cost: u64,
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: 10 of 11 files reviewed, 5 unresolved discussions (waiting on @avi-starkware, @Yonatan-Starkware, and @Yoni-Starkware)
crates/blockifier/src/versioned_constants.rs
line 662 at r2 (raw file):
pub range_check_gas_cost: u64, // Priced builtins. pub keccak_builtin_gas_cost: u64,
Let's remove the builtin from every builtin that has it because it is inconsistent and unnecessary now that they are under the builtin section.
Suggestion:
pub keccak_gas_cost: u64,
crates/blockifier/src/versioned_constants.rs
line 753 at r2 (raw file):
"syscall_gas_costs", "builtin_gas_costs", ];
Are not all the keys in the base now? We should aim to remove this constant, but this is outside of this PR scope.
Code quote:
const ADDITIONAL_FIELDS: [&'static str; 31] = [
"block_hash_contract_address",
"constructor_entry_point_selector",
"default_entry_point_selector",
"entry_point_type_constructor",
"entry_point_type_external",
"entry_point_type_l1_handler",
"error_block_number_out_of_range",
"error_invalid_input_len",
"error_invalid_argument",
"error_entry_point_failed",
"error_entry_point_not_found",
"error_out_of_gas",
"execute_entry_point_selector",
"l1_gas",
"l1_gas_index",
"l1_handler_version",
"l2_gas",
"l2_gas_index",
"l1_data_gas",
"l1_data_gas_index",
"nop_entry_point_offset",
"sierra_array_len_bound",
"stored_block_hash_buffer",
"transfer_entry_point_selector",
"validate_declare_entry_point_selector",
"validate_deploy_entry_point_selector",
"validate_entry_point_selector",
"validate_rounding_consts",
"validated",
"syscall_gas_costs",
"builtin_gas_costs",
];
crates/blockifier/src/versioned_constants.rs
line 765 at r2 (raw file):
let builtins: BuiltinGasCosts = serde_json::from_value(builtins_value)?; let syscalls_value: Value = serde_json::to_value(&raw_json_data.parse_syscalls(&base, &builtins)?)?;
Here, the way to make sure you have the builtins before you need to calculate the syscall is to call the builtin parse before you call the syscall parse, right?
Code quote:
let builtins_value: Value = serde_json::to_value(&raw_json_data.parse_builtin()?)?;
let builtins: BuiltinGasCosts = serde_json::from_value(builtins_value)?;
let syscalls_value: Value =
serde_json::to_value(&raw_json_data.parse_syscalls(&base, &builtins)?)?;
crates/blockifier/src/versioned_constants.rs
line 961 at r2 (raw file):
"default_initial_gas_cost" => base.default_initial_gas_cost, "entry_point_initial_budget" => base.entry_point_initial_budget, "syscall_base_gas_cost" => base.syscall_base_gas_cost,
I think it is easier to read this way
Suggestion:
let inner_value = match inner_key.as_str() {
"step_gas_cost" => base.step_gas_cost,
"memory_hole_gas_cost" => base.memory_hole_gas_cost,
"default_initial_gas_cost" => base.default_initial_gas_cost,
"entry_point_initial_budget" => base.entry_point_initial_budget,
"syscall_base_gas_cost" => base.syscall_base_gas_cost,
"range_check_gas_cost" => builtins.range_check_gas_cost,
"keccak_builtin_gas_cost" => builtins.keccak_builtin_gas_cost,
"pedersen_gas_cost" => builtins.pedersen_gas_cost,
"bitwise_builtin_gas_cost" => builtins.bitwise_builtin_gas_cost,
"ecop_gas_cost" => builtins.ecop_gas_cost,
"poseidon_gas_cost" => builtins.poseidon_gas_cost,
"add_mod_gas_cost" => builtins.add_mod_gas_cost,
"mul_mod_gas_cost" => builtins.mul_mod_gas_cost,
"ecdsa_gas_cost" => builtins.ecdsa_gas_cost,
Previously, meship-starkware (Meshi Peled) wrote…
Agree. |
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 10 of 10 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @noaov1, @Yonatan-Starkware, and @Yoni-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.
Reviewed 1 of 3 files at r2, 10 of 10 files at r4, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware, @Yonatan-Starkware, and @Yoni-Starkware)
crates/blockifier/resources/versioned_constants_0_13_3.json
line 80 at r4 (raw file):
"entry_point_initial_budget": 1, "step_gas_cost": 600 },
Now that you removed transaction_gas_cost
, this can be deleted as well (can be done in a separate PR)
Code quote:
"fee_transfer_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
crates/blockifier/src/versioned_constants.rs
line 719 at r4 (raw file):
// List of additinal os constants, beside the gas cost and validate rounding constants, that are // not used by the blockifier but included for transparency. These constanst will be ignored // during the creation of the struct containing the gas costs.
Suggestion:
// List of os constants to be ignored
// during the creation of the struct containing the base gas costs.
crates/blockifier/src/versioned_constants.rs
line 752 at r4 (raw file):
"validated", "syscall_gas_costs", "builtin_gas_costs",
Please keep the list alphabetize.
Code quote:
"builtin_gas_costs",
d26db48
to
8da5c3a
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 8 of 9 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware, @Yonatan-Starkware, and @Yoni-Starkware)
8da5c3a
to
1fb5bb8
Compare
1fb5bb8
to
cf1721c
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 5 of 9 files at r5, 1 of 1 files at r6, 4 of 4 files at r7, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware, @Yonatan-Starkware, and @Yoni-Starkware)
Done. |
Previously, noaov1 (Noa Oved) wrote…
Done. |
Previously, noaov1 (Noa Oved) wrote…
No problem. opening another PR |
cf1721c
to
9b7c19f
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: 10 of 11 files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @noaov1, and @Yoni-Starkware)
9b7c19f
to
5214bf3
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 8 of 8 files at r9, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @noaov1, and @Yoni-Starkware)
5214bf3
to
813f4d2
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.
Dismissed @noaov1 from a discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware and @Yoni-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 and @Yoni-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 and @Yoni-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.
Reviewed 2 of 8 files at r9, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @avi-starkware and @Yoni-Starkware)
No description provided.