Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yair-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

yair-starkware commented Nov 11, 2024

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.

Project coverage is 12.63%. Comparing base (e3165c4) to head (973a03d).
Report is 373 commits behind head on main.

Files with missing lines Patch % Lines
crates/papyrus_config/src/dumping.rs 97.22% 1 Missing ⚠️
crates/papyrus_config/src/lib.rs 50.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@yair-starkware yair-starkware changed the base branch from yair/use_same_config to graphite-base/1953 November 12, 2024 13:13
@yair-starkware yair-starkware changed the base branch from graphite-base/1953 to main November 12, 2024 13:14
Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a 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(),
        ));

Copy link
Contributor Author

@yair-starkware yair-starkware left a 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 define target_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

@yair-starkware
Copy link
Contributor Author

crates/papyrus_config/src/dumping.rs line 92 at r2 (raw file):

Previously, yair-starkware (Yair) wrote…

I don't think we support pointer to pointer, did you try it?

Thinking about it, the dump of a struct shouldn't contain pointers at all I think, only in the dump_to_file it should get pointers

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants