-
Notifications
You must be signed in to change notification settings - Fork 21
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(config): struct pointers #1953
base: main
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1953 +/- ##
===========================================
- Coverage 40.10% 12.63% -27.47%
===========================================
Files 26 34 +8
Lines 1895 3624 +1729
Branches 1895 3624 +1729
===========================================
- Hits 760 458 -302
- Misses 1100 3137 +2037
+ Partials 35 29 -6 ☔ View full report in Codecov by Sentry. |
9a55c5c
to
606a6e0
Compare
88dda67
to
467a521
Compare
467a521
to
4c80d65
Compare
606a6e0
to
fcb2b8e
Compare
4c80d65
to
38815fb
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 3 files reviewed, 6 unresolved discussions (waiting on @yair-starkware)
crates/papyrus_config/src/lib.rs
line 153 at r2 (raw file):
/// A serialized type of a configuration parameter. #[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq, strum_macros::Display)] #[allow(missing_docs)]
Is this still needed?
Code quote:
#[allow(missing_docs)]
crates/papyrus_config/src/dumping.rs
line 66 at r2 (raw file):
pub type ConfigPointers = Vec<(PointerTarget, Pointers)>; /// Given set of paths that are configuration of the same struct type, makes all the paths point to
Given a set
Code quote:
Given set
crates/papyrus_config/src/dumping.rs
line 75 at r2 (raw file):
) { let target_dump = default_instance.dump(); for (param_path, serialized_param) in target_dump {
Could this be default_instance.dump()
, and then you wouldn't have to define target_dump
?
Code quote:
target_dump
crates/papyrus_config/src/dumping.rs
line 86 at r2 (raw file):
.strip_prefix(REQUIRED_PARAM_DESCRIPTION_PREFIX) .unwrap_or(&serialized_param.description); ser_pointer_target_required_param(
Note this sets the target as a required parameter. In https://reviewable.io/reviews/starkware-libs/sequencer/1954 however it is added as a non-required parameter.
I'd be more explicit here, and have two variants, one for required and one for non-required params. They can both call a common base function if that makes sense.
Code quote:
ser_pointer_target_required_param(
crates/papyrus_config/src/dumping.rs
line 92 at r2 (raw file):
) } SerializedContent::PointerTarget(_) => panic!("Pointer target cannot be a pointer."),
Why not point it at the target as well?
Code quote:
SerializedContent::PointerTarget(_) => panic!("Pointer target cannot be a pointer."),
crates/papyrus_config/src/dumping.rs
line 98 at r2 (raw file):
pointer_prefixes .iter() .map(|pointer| format!("{}{}{}", pointer, FIELD_SEPARATOR, param_path))
Wrap as a function?
Code quote:
format!("{}{}{}", pointer, FIELD_SEPARATOR, param_path)
crates/papyrus_config/src/dumping.rs
line 100 at r2 (raw file):
.map(|pointer| format!("{}{}{}", pointer, FIELD_SEPARATOR, param_path)) .collect(), ));
Why not create a vector and return it?
Code quote:
config_pointers.push((
pointer_target,
pointer_prefixes
.iter()
.map(|pointer| format!("{}{}{}", pointer, FIELD_SEPARATOR, param_path))
.collect(),
));
38815fb
to
973a03d
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 3 files reviewed, 6 unresolved discussions (waiting on @Itay-Tsabary-Starkware)
crates/papyrus_config/src/dumping.rs
line 66 at r2 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Given a set
Done.
crates/papyrus_config/src/dumping.rs
line 75 at r2 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Could this be
default_instance.dump()
, and then you wouldn't have to definetarget_dump
?
Done.
crates/papyrus_config/src/dumping.rs
line 86 at r2 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Note this sets the target as a required parameter. In https://reviewable.io/reviews/starkware-libs/sequencer/1954 however it is added as a non-required parameter.
I'd be more explicit here, and have two variants, one for required and one for non-required params. They can both call a common base function if that makes sense.
Why do we have separation if they are combined later?
crates/papyrus_config/src/dumping.rs
line 92 at r2 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Why not point it at the target as well?
I don't think we support pointer to pointer, did you try it?
crates/papyrus_config/src/dumping.rs
line 100 at r2 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Why not create a vector and return it?
Done.
crates/papyrus_config/src/lib.rs
line 153 at r2 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Is this still needed?
Yes, otherwise you need to doc each variant
Previously, yair-starkware (Yair) wrote…
Thinking about it, the dump of a struct shouldn't contain pointers at all I think, only in the |
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 3 files reviewed, 2 unresolved discussions (waiting on @yair-starkware)
crates/papyrus_config/src/dumping.rs
line 86 at r2 (raw file):
Previously, yair-starkware (Yair) wrote…
Why do we have separation if they are combined later?
You could define a required parameter that no one points at. That's the current usage in papyrus.
However, we might as well just create required parameters as targets and have an empty set of pointers.
WDYT?
crates/papyrus_config/src/dumping.rs
line 100 at r2 (raw file):
Previously, yair-starkware (Yair) wrote…
Done.
I had something else in mind, wdyt?
The current code structure is:
let mut res;
loop over some list {
....
calculations
....
add a single result to res
}
res
I suggest to change it such it is more of a map
-like syntax, i.e., map each element from some list
to an element in res
.
No description provided.