Skip to content

refactor: leafdata implementations #115

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

Merged
merged 1 commit into from
May 22, 2024

Conversation

AvivYossef-starkware
Copy link
Collaborator

@AvivYossef-starkware AvivYossef-starkware commented May 15, 2024

Needed for the implementation of serialize for FilledTree<L: LeafData>.


This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented May 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 72.03%. Comparing base (59c6c07) to head (ddbdbce).

Files Patch % Lines
crates/committer/src/storage/serde_trait.rs 0.00% 10 Missing ⚠️
...src/patricia_merkle_tree/filled_tree/node_serde.rs 0.00% 7 Missing ⚠️
...r/src/patricia_merkle_tree/node_data/leaf_serde.rs 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
- Coverage   73.10%   72.03%   -1.08%     
==========================================
  Files          30       31       +1     
  Lines        1071     1087      +16     
  Branches     1071     1087      +16     
==========================================
  Hits          783      783              
- Misses        251      267      +16     
  Partials       37       37              

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

@AvivYossef-starkware
Copy link
Collaborator Author

I would love to hear if you have a more elegant way of doing it.
Maybe changing the Serializable trait and making leaf data Implement Part of it.

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/refactor_leaf_data branch 2 times, most recently from c312db6 to 1401918 Compare May 15, 2024 06:26
@AvivYossef-starkware AvivYossef-starkware changed the title Refactor serialization for LeafData implementations refactor: leafdata implementations May 15, 2024
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 5 files at r1, all commit messages.
Reviewable status: 2 of 5 files reviewed, all discussions resolved (waiting on @amosStarkware)

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/refactor_leaf_data branch 4 times, most recently from 7a44f0d to f1fdaff Compare May 22, 2024 06:22
Copy link
Collaborator Author

@AvivYossef-starkware AvivYossef-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is for LeafdataImpl impl DB object trait.

Reviewable status: 0 of 6 files reviewed, all discussions resolved (waiting on @amosStarkware and @dorimedini-starkware)

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 5 files at r1, 3 of 5 files at r2, 1 of 2 files at r3, all commit messages.
Reviewable status: 5 of 6 files reviewed, 5 unresolved discussions (waiting on @amosStarkware and @AvivYossef-starkware)


crates/committer/src/patricia_merkle_tree/filled_tree/node_serde.rs line 42 at r3 (raw file):

}

impl<L: LeafData + DBObject> DBObject for FilledNode<L> {

All "filled leaves" (i.e. leaves with actual data) should be DBObjects, right?
since this is the case, I would bind the LeafData trait to DBObject directly (and remove the extra binding here):

trait LeafData: Clone + Sync + Send + DBObject

Suggestion:

<L: LeafData>

crates/committer/src/patricia_merkle_tree/filled_tree/node_serde.rs line 80 at r3 (raw file):

    }

    /// Returns the prefix of the filled node.

move this docstring (and rephrase to be general) to the DbObject trait; in general it's best to document functions once.
if the specific implementation of a trait function should get it's own docstring, that would be a special case.

Suggestion:

/// Returns the storage key prefix of the DB object.

crates/committer/src/storage/serde_trait.rs line 0 at r3 (raw file):
this file should be renamed to db_object.rs or something... "serde" is no longer a good name.
not part of this PR in any case (non-blocking)


crates/committer/src/storage/serde_trait.rs line 9 at r3 (raw file):

    fn get_prefix(&self) -> StoragePrefix;
    /// Returns a `StorageKey` from a prefix and a suffix.

newline between functions

Suggestion:

    fn get_prefix(&self) -> StoragePrefix;
    
    /// Returns a `StorageKey` from a prefix and a suffix.

crates/committer_cli/src/tests/python_tests.rs line 0 at r3 (raw file):
In this file I see this pattern several times:

leaf.get_db_key(leaf.suffix());

where leaf is a FilledNode.
please change this to

leaf.db_key();

I know you can't just add a suffix() function to the DBObject trait, but you can add a db_key() function to the impl<L: LeafData> FilledNode<L> block which uses the suffix.

Copy link
Collaborator

@dorimedini-starkware dorimedini-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 4 of 4 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @amosStarkware and @AvivYossef-starkware)

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a 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 r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @amosStarkware and @AvivYossef-starkware)

@AvivYossef-starkware AvivYossef-starkware added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit c5a134e May 22, 2024
10 of 11 checks passed
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