-
Notifications
You must be signed in to change notification settings - Fork 107
feat: added private versioned constants #1992
Conversation
1b0c74b
to
da2a563
Compare
7589a25
to
fc2bf75
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.
+reviewer:@dorimedini-starkware
Reviewable status: 0 of 6 files reviewed, all discussions resolved (waiting on @dorimedini-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 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @amosStarkware)
crates/blockifier/src/versioned_constants.rs
line 207 at r1 (raw file):
/// Private versioned constants are used if they are provided, otherwise the latest versioned /// constants are used. `validate_max_n_steps` & `max_recursion_depth` override both.
Suggestion:
/// Private versioned constants are used if they are provided, otherwise the latest versioned
/// constants are used. `validate_max_n_steps` & `max_recursion_depth` override both.
// TODO(Amos, 1/8/2024): remove the explicit max_n_steps, they should be part of the general override.
crates/blockifier/src/versioned_constants.rs
line 209 at r1 (raw file):
/// constants are used. `validate_max_n_steps` & `max_recursion_depth` override both. pub fn get_versioned_constants( private_versioned_constants: Option<String>,
please move all deserialization logic to the native blockifier side (you can add a utility function for this)
Suggestion:
versioned_constants_override: Option<VersionedConstants>,
crates/blockifier/src/versioned_constants.rs
line 231 at r1 (raw file):
} } }
reduce some duplication
Suggestion:
let base_versioned_constants = match private_versioned_constants {
Some(private_versioned_constants) => {
log::debug!(
"Using provided private versioned constants (with additional overrides)."
);
serde_json::from_str(&private_versioned_constants)
.expect("Versioned constants JSON file is malformed.")
}
None => {
log::debug!("Using latest versioned constants (with additional overrides).");
Self::latest_constants().clone()
};
Self {
validate_max_n_steps,
max_recursion_depth,
..base_versioned_constants
}
}
crates/native_blockifier/src/py_block_executor.rs
line 115 at r1 (raw file):
validate_max_n_steps, max_recursion_depth, );
- Define a
VersionedConstantsOverrides
(without thePy
) struct - implement
From<PyVersionedConstantsOverrides> for VersionedConstantsOverrides
- use it instead of the three params in
get_versioned_constants
Suggestion:
let versioned_constants = VersionedConstants::get_versioned_constants(
versioned_constants_overrides.into
);
crates/native_blockifier/src/py_objects.rs
line 65 at r1 (raw file):
Err(PyValueError::new_err("Failed to parse private_versioned_constants.")) } }
is this ever used in business logic...? I don't see any usage here
Code quote:
#[staticmethod]
pub fn validate_private_versioned_constants_str(
private_versioned_constants: &str,
) -> PyResult<()> {
if serde_json::from_str::<VersionedConstants>(private_versioned_constants).is_ok() {
Ok(())
} else {
Err(PyValueError::new_err("Failed to parse private_versioned_constants."))
}
}
crates/native_blockifier/src/py_validator.rs
line 48 at r1 (raw file):
validate_max_n_steps, max_recursion_depth, );
see above
Code quote:
let PyVersionedConstantsOverrides {
validate_max_n_steps,
max_recursion_depth,
private_versioned_constants,
} = versioned_constants_overrides;
let versioned_constants = VersionedConstants::get_versioned_constants(
private_versioned_constants,
validate_max_n_steps,
max_recursion_depth,
);
fc2bf75
to
2b91343
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1992 +/- ##
=======================================
Coverage ? 78.47%
=======================================
Files ? 62
Lines ? 8967
Branches ? 8967
=======================================
Hits ? 7037
Misses ? 1483
Partials ? 447 ☔ View full report in Codecov by Sentry. |
2b91343
to
984beba
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 7 files reviewed, 6 unresolved discussions (waiting on @dorimedini-starkware)
crates/blockifier/src/versioned_constants.rs
line 207 at r1 (raw file):
/// Private versioned constants are used if they are provided, otherwise the latest versioned /// constants are used. `validate_max_n_steps` & `max_recursion_depth` override both.
how would you implement this?
i.e., how would an override of only validate_max_n_steps
look like?
crates/blockifier/src/versioned_constants.rs
line 209 at r1 (raw file):
Previously, dorimedini-starkware wrote…
please move all deserialization logic to the native blockifier side (you can add a utility function for this)
Done.
crates/blockifier/src/versioned_constants.rs
line 231 at r1 (raw file):
Previously, dorimedini-starkware wrote…
reduce some duplication
Done.
crates/native_blockifier/src/py_block_executor.rs
line 115 at r1 (raw file):
Previously, dorimedini-starkware wrote…
- Define a
VersionedConstantsOverrides
(without thePy
) struct- implement
From<PyVersionedConstantsOverrides> for VersionedConstantsOverrides
- use it instead of the three params in
get_versioned_constants
Done.
crates/native_blockifier/src/py_objects.rs
line 65 at r1 (raw file):
Previously, dorimedini-starkware wrote…
is this ever used in business logic...? I don't see any usage here
This is used in the Python test private_versioned_constants_test.py
crates/native_blockifier/src/py_validator.rs
line 48 at r1 (raw file):
Previously, dorimedini-starkware wrote…
see above
Done.
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 6 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @amosStarkware)
crates/blockifier/src/versioned_constants.rs
line 207 at r1 (raw file):
Previously, amosStarkware wrote…
how would you implement this?
i.e., how would an override of onlyvalidate_max_n_steps
look like?
good question.
I can think of a solution using a macro; macro should accept the fields defining the versioned constants, and automatically defines VersionedConstants and VersionedConstantsOverrides: the latter equal to the former except every field is wrapped with Option<>.
the macro can also generate an apply_overrides(&mut self, overrides: &VersionedConstantsOverrides)
method on VersionedConstants to update every non-None field.
needs thought, out of scope of this PR though; a TODO is enough
crates/native_blockifier/src/py_block_executor.rs
line 109 at r3 (raw file):
VersionedConstantsOverrides::from(py_versioned_constants_overrides); let versioned_constants = VersionedConstants::get_versioned_constants(versioned_constants_overrides);
more concice
Suggestion:
let versioned_constants =
VersionedConstants::get_versioned_constants(
py_versioned_constants_overrides.into()
);
crates/native_blockifier/src/py_validator.rs
line 42 at r3 (raw file):
VersionedConstantsOverrides::from(py_versioned_constants_overrides); let versioned_constants = VersionedConstants::get_versioned_constants(versioned_constants_overrides);
see above
Suggestion:
let versioned_constants =
VersionedConstants::get_versioned_constants(
py_versioned_constants_overrides.into()
);
984beba
to
1beb676
Compare
1beb676
to
6df3e21
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: 6 of 7 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware)
crates/blockifier/src/versioned_constants.rs
line 207 at r1 (raw file):
Previously, dorimedini-starkware wrote…
good question.
I can think of a solution using a macro; macro should accept the fields defining the versioned constants, and automatically defines VersionedConstants and VersionedConstantsOverrides: the latter equal to the former except every field is wrapped with Option<>.
the macro can also generate anapply_overrides(&mut self, overrides: &VersionedConstantsOverrides)
method on VersionedConstants to update every non-None field.
needs thought, out of scope of this PR though; a TODO is enough
Done.
crates/native_blockifier/src/py_block_executor.rs
line 109 at r3 (raw file):
Previously, dorimedini-starkware wrote…
more concice
Done.
crates/native_blockifier/src/py_validator.rs
line 42 at r3 (raw file):
Previously, dorimedini-starkware wrote…
see above
Done.
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.
+reviewer:@Yoni-Starkware
Reviewable status: 3 of 7 files reviewed, 3 unresolved discussions (waiting on @dorimedini-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 1 files at r4, 3 of 3 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Yoni-Starkware)
This change is