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

Merged
merged 1 commit into from
Nov 18, 2024
Merged

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 93.87755% with 3 lines in your changes missing coverage. Please review.

Project coverage is 69.37%. Comparing base (e3165c4) to head (467ccb1).
Report is 454 commits behind head on main.

Files with missing lines Patch % Lines
crates/papyrus_config/src/dumping.rs 95.74% 2 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%   69.37%   +29.27%     
===========================================
  Files          26        7       -19     
  Lines        1895      676     -1219     
  Branches     1895      676     -1219     
===========================================
- Hits          760      469      -291     
+ Misses       1100      178      -922     
+ Partials       35       29        -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yair-starkware yair-starkware force-pushed the yair/config_struct_pointers branch from 88dda67 to 467a521 Compare November 12, 2024 07:50
@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 force-pushed the yair/config_struct_pointers branch from 467a521 to 4c80d65 Compare November 12, 2024 13:14
@yair-starkware yair-starkware changed the base branch from graphite-base/1953 to main November 12, 2024 13:14
@yair-starkware yair-starkware force-pushed the yair/config_struct_pointers branch from 4c80d65 to 38815fb Compare 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.

@yair-starkware yair-starkware force-pushed the yair/config_struct_pointers branch from 973a03d to b7d736f Compare November 17, 2024 13:05
@yair-starkware yair-starkware changed the base branch from main to yair/cosolidate_config_pointers November 17, 2024 13:05
@yair-starkware yair-starkware force-pushed the yair/config_struct_pointers branch from b7d736f to 9b3eb3a Compare November 17, 2024 14:03
@yair-starkware yair-starkware force-pushed the yair/cosolidate_config_pointers branch from ad21cda to 1b8edd9 Compare November 17, 2024 14:07
@yair-starkware yair-starkware force-pushed the yair/config_struct_pointers branch from 9b3eb3a to b7afab7 Compare November 17, 2024 14:07
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, 2 unresolved discussions (waiting on @Itay-Tsabary-Starkware)


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

Previously, Itay-Tsabary-Starkware wrote…

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?

Consolidated pointers as discussed in #2111


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

Previously, Itay-Tsabary-Starkware wrote…

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.

Done.

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, 1 unresolved discussion (waiting on @yair-starkware)


crates/papyrus_config/src/dumping.rs line 87 at r4 (raw file):

// Converts a serialized param to a pointer target.
fn to_target(

Please change to a more descriptive name, e.g., serialized_param_to_pointer_target (leaving as non blocking).

Code quote:

to_target

@yair-starkware yair-starkware force-pushed the yair/config_struct_pointers branch from b7afab7 to e0ff8fe Compare November 18, 2024 08:31
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, all discussions resolved (waiting on @Itay-Tsabary-Starkware)


crates/papyrus_config/src/dumping.rs line 87 at r4 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Please change to a more descriptive name, e.g., serialized_param_to_pointer_target (leaving as non blocking).

done

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.

:lgtm:

Reviewed 1 of 3 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yair-starkware)

Copy link
Contributor Author

yair-starkware commented Nov 18, 2024

Merge activity

  • Nov 18, 4:13 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Nov 18, 4:15 AM EST: Graphite rebased this pull request as part of a merge.
  • Nov 18, 4:35 AM EST: A user merged this pull request with Graphite.

@yair-starkware yair-starkware changed the base branch from yair/cosolidate_config_pointers to graphite-base/1953 November 18, 2024 09:13
@yair-starkware yair-starkware changed the base branch from graphite-base/1953 to main November 18, 2024 09:13
@yair-starkware yair-starkware force-pushed the yair/config_struct_pointers branch from e0ff8fe to 467ccb1 Compare November 18, 2024 09:14
@yair-starkware yair-starkware merged commit bfe7a4c into main Nov 18, 2024
17 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants