-
Notifications
You must be signed in to change notification settings - Fork 107
feat: backwards compatibility for calldata_factor #1529
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main-v0.13.1 #1529 +/- ##
================================================
- Coverage 69.19% 69.16% -0.04%
================================================
Files 59 59
Lines 8159 8173 +14
Branches 8159 8173 +14
================================================
+ Hits 5646 5653 +7
- Misses 2053 2056 +3
- Partials 460 464 +4 ☔ View full report in Codecov by Sentry. |
36a91f8
to
8496617
Compare
6ac6afa
to
71b3720
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 r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @giladchase and @noaov1)
crates/blockifier/src/versioned_constants.rs
line 392 at r1 (raw file):
} impl TryFrom<OSConstantsRawJSON> for OSConstants {
Throughout the file.
Suggestion:
OsConstantsRawJson
crates/blockifier/src/versioned_constants.rs
line 499 at r1 (raw file):
} #[derive(Debug, Clone, Default, Serialize, Deserialize)]
Alphabetize?
Throughout this file.
Code quote:
derive
crates/blockifier/src/versioned_constants.rs
line 512 at r1 (raw file):
Ok(Self { constant: serde_json::from_value( raw_json_data.raw_resource_params_as_dict["constant"].clone(),
Any way to avoid these, given that we have ownership?
Code quote:
.clone()
crates/blockifier/src/versioned_constants_test.rs
line 44 at r1 (raw file):
"validate_max_n_steps": 1, "os_constants": {}, "os_resources": {
Do we have a test of loading the 0.13.1
versioned constants?
crates/blockifier/src/versioned_constants_test.rs
line 69 at r1 (raw file):
// Calldata-factor was initialized as 0, and did not affect the expected result, even if // calldata_length is nonzero.
Try to refrain from mentioning variables and functions by name in documentation, if possible; it causes false-positives when searching throughout the codebase.
Suggestion:
// Calldata factor was initialized as 0, and did not affect the expected result, even if
// calldata length is nonzero.
71b3720
to
d98ee70
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: all files reviewed, 1 unresolved discussion (waiting on @elintul and @noaov1)
crates/blockifier/src/versioned_constants.rs
line 512 at r1 (raw file):
Previously, elintul (Elin) wrote…
Any way to avoid these, given that we have ownership?
Done.
Also added proper error handling: return error if the user gave json with constant
but not with calldata_factor
, which should never happen...
crates/blockifier/src/versioned_constants_test.rs
line 44 at r1 (raw file):
Previously, elintul (Elin) wrote…
Do we have a test of loading the
0.13.1
versioned constants?
This line loads it during compilation, so if there's a bug it won't compile.
Is that what you meant?
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, 3 unresolved discussions (waiting on @noaov1)
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, 3 unresolved discussions (waiting on @giladchase and @noaov1)
crates/blockifier/src/versioned_constants_test.rs
line 44 at r1 (raw file):
Previously, giladchase wrote…
This line loads it during compilation, so if there's a bug it won't compile.
Is that what you meant?
Link is broken.
d98ee70
to
551a75f
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 r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @giladchase and @noaov1)
crates/blockifier/src/versioned_constants.rs
line 521 at r2 (raw file):
(None, _) => { // If "constant" is not found, use the entire map for "constant" and default // "calldata_factor"
Suggestion:
// If `constant` is not found, use the entire map for `constant` and default
// `calldata_factor`.
crates/blockifier/src/versioned_constants.rs
line 522 at r2 (raw file):
// If "constant" is not found, use the entire map for "constant" and default // "calldata_factor" let entire_map = std::mem::take(&mut json_data.raw_resource_params_as_dict);
Suggestion:
entire_value
crates/blockifier/src/versioned_constants.rs
line 528 at r2 (raw file):
let constant = serde_json::from_value(constant)?; let calldata_factor = serde_json::from_value(calldata_factor)?;
I think you can pass them directly, without intermediate variables; short enough.
Code quote:
let constant = serde_json::from_value(constant)?;
let calldata_factor = serde_json::from_value(calldata_factor)?;
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: all files reviewed, 3 unresolved discussions (waiting on @elintul and @noaov1)
crates/blockifier/src/versioned_constants_test.rs
line 44 at r1 (raw file):
Previously, elintul (Elin) wrote…
Link is broken.
odd 🤔
serde_json::from_str(DEFAULT_CONSTANTS_JSON) |
551a75f
to
26ed90c
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 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @giladchase and @noaov1)
crates/blockifier/src/versioned_constants_test.rs
line 44 at r1 (raw file):
Previously, giladchase wrote…
odd 🤔
serde_json::from_str(DEFAULT_CONSTANTS_JSON)
Yup.
26ed90c
to
2ef72a9
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 2 files reviewed, 2 unresolved discussions (waiting on @elintul and @noaov1)
crates/blockifier/src/versioned_constants.rs
line 392 at r1 (raw file):
Previously, elintul (Elin) wrote…
Throughout the file.
Done
crates/blockifier/src/versioned_constants.rs
line 499 at r1 (raw file):
Previously, elintul (Elin) wrote…
Alphabetize?
Throughout this file.
Done, also removed Serialize, it isn't used and won't help anyone anyway.
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: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
If os resources' inner tx is missing `constant` and `calldata_factor` keys, then: - assume it is a flat `ExecutionResources` instance, and put its contents inside a `constant` key. - initialize calldata_factor as default (all zeros).
2ef72a9
to
b8ae6a9
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 1 of 1 files at r6, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
If os resources' inner tx is missing
constant
andcalldata_factor
keys, then:ExecutionResources
instance, and put its contents inside aconstant
key.Python: https://reviewable.io/reviews/starkware-industries/starkware/34026
This change is