Skip to content

build: filled forest #118

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
Merged

build: filled forest #118

merged 1 commit into from
May 22, 2024

Conversation

AvivYossef-starkware
Copy link
Collaborator

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

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented May 15, 2024

Codecov Report

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

Project coverage is 70.60%. Comparing base (b5df579) to head (5a664e1).

Files Patch % Lines
...ter/src/patricia_merkle_tree/filled_tree/forest.rs 0.00% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
- Coverage   71.83%   70.60%   -1.24%     
==========================================
  Files          31       32       +1     
  Lines        1090     1109      +19     
  Branches     1090     1109      +19     
==========================================
  Hits          783      783              
- Misses        270      289      +19     
  Partials       37       37              

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

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/impl_filledtree_serialize branch 3 times, most recently from d6f7eb9 to 8e9a49e Compare May 19, 2024 10:20
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv_build_filled_forest branch 3 times, most recently from eb82f78 to 1c8a8a8 Compare May 19, 2024 13:39
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/impl_filledtree_serialize branch from 8e9a49e to 55c75a9 Compare May 22, 2024 06:48
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv_build_filled_forest branch 2 times, most recently from f7df30d to ab99050 Compare May 22, 2024 07:53
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 2 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @amosStarkware and @AvivYossef-starkware)


crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs line 14 at r2 (raw file):

    #[allow(dead_code)]
    /// Serialize each tree and store it.
    fn write_to_storage(&self, storage: &mut S);

does this work?

Suggestion:

pub(crate) trait FilledForest<L: LeafData> {
    #[allow(dead_code)]
    /// Serialize each tree and store it.
    fn write_to_storage(&self, storage: &mut impl Storage);

crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs line 21 at r2 (raw file):

}

pub(crate) struct FilledForestImpl<L: LeafData + DBObject, T: FilledTree<L>> {

Suggestion:

<L: LeafData

crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs line 28 at r2 (raw file):

}

impl<L: LeafData + DBObject, T: FilledTree<L>, S: Storage> FilledForest<L, S>

Suggestion:

L: LeafData

crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs line 43 at r2 (raw file):

        // Store the contract tree.
        storage.mset(self.contract_tree.serialize());
    }

I am assuming that setting to storage is not a "local" operation, so I prefer to parallelize all sets to a single op.
to that end, I would construct an iterator over all new values and call mset once only.

Suggestion:

    #[allow(dead_code)]
    fn write_to_storage(&self, storage: &mut S) {
        let new_db_objects = self
            .storage_trees
            .values()
            .iter()
            // Serialize each storage tree and store it in the storage object.
            .flat_map(|tree| tree.serialize().iter())
            // Store the compiled class tree.
            .chain(self.compiled_class_tree.serialize().iter())
            // Store the contract tree.
            .chain(self.contract_tree.serialize().iter());
        storage.mset(new_db_objects.collect());
    }

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv/impl_filledtree_serialize branch from 55c75a9 to 2e06b90 Compare May 22, 2024 13:08
@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv_build_filled_forest branch from ab99050 to 24f128b Compare May 22, 2024 13:49
@AvivYossef-starkware AvivYossef-starkware changed the base branch from aviv/impl_filledtree_serialize to main May 22, 2024 13:49
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 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @amosStarkware)

@AvivYossef-starkware AvivYossef-starkware force-pushed the aviv_build_filled_forest branch from 24f128b to 5a664e1 Compare May 22, 2024 13:52
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 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @amosStarkware)

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