Skip to content

chore: get_lca for NodeIndex #98

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 8, 2024
Merged

chore: get_lca for NodeIndex #98

merged 1 commit into from
May 8, 2024

Conversation

TzahiTaub
Copy link
Contributor

@TzahiTaub TzahiTaub commented May 7, 2024

This change is Reviewable

@TzahiTaub TzahiTaub self-assigned this May 7, 2024
@TzahiTaub TzahiTaub force-pushed the tzahi/Node_index/get_lca branch from aab72c9 to bc39814 Compare May 7, 2024 08:14
@TzahiTaub TzahiTaub changed the title Tzahi/node index/get lca chore: NodeIndex get_lca + better range checks May 7, 2024
@TzahiTaub TzahiTaub force-pushed the tzahi/Node_index/get_lca branch from bc39814 to 4f3409b Compare May 7, 2024 08:25
@codecov-commenter
Copy link

codecov-commenter commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.38%. Comparing base (5f7259d) to head (97bf4b9).

Additional details and impacted files
@@                           Coverage Diff                           @@
##           tzahi/node_index/tight_range_checks      #98      +/-   ##
=======================================================================
+ Coverage                                75.94%   76.38%   +0.43%     
=======================================================================
  Files                                       25       25              
  Lines                                      869      885      +16     
  Branches                                   869      885      +16     
=======================================================================
+ Hits                                       660      676      +16     
  Misses                                     175      175              
  Partials                                    34       34              

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

@TzahiTaub TzahiTaub force-pushed the tzahi/Node_index/get_lca branch 2 times, most recently from c359279 to bcabc7f Compare May 7, 2024 09:24
@TzahiTaub TzahiTaub changed the base branch from main to tzahi/node_index/tight_range_checks May 7, 2024 09:24
@TzahiTaub TzahiTaub changed the title chore: NodeIndex get_lca + better range checks chore: get_lca for NodeIndex May 7, 2024
@TzahiTaub TzahiTaub force-pushed the tzahi/node_index/tight_range_checks branch from 35502bb to 489e2b0 Compare May 7, 2024 09:29
@TzahiTaub TzahiTaub force-pushed the tzahi/Node_index/get_lca branch 3 times, most recently from e142824 to c59efaf Compare May 7, 2024 13:35
@TzahiTaub TzahiTaub force-pushed the tzahi/node_index/tight_range_checks branch from 489e2b0 to e7358dc Compare May 7, 2024 16:33
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 4 of 6 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @amosStarkware and @TzahiTaub)


crates/committer/Cargo.toml line 15 at r2 (raw file):

pretty_assertions.workspace = true
rstest.workspace = true
rand.workspace = true

Suggestion:

pretty_assertions.workspace = true
rand.workspace = true
rstest.workspace = true

crates/committer/src/patricia_merkle_tree/types.rs line 83 at r2 (raw file):

            Ordering::Greater => adapted_self = adapted_self >> (bit_length - other_bit_length),
            Ordering::Equal => return *self,
        }

clearer?
also removes the need for Ordering.
if you like minimal amount of lines you can replace the if .. else with match .. true => .. false => ..

Suggestion:

    pub(crate) fn get_lca(&self, other: &NodeIndex) -> NodeIndex {
        if self == other {
            return *self;
        }
        let bit_length = self.bit_length();
        let other_bit_length = other.bit_length();

        // Bring self to the level of other.
        let adapted_self = if self < other {
            self << (other_bit_length - bit_length)
        } else {
            self >> (bit_length - other_bit_length)
        };

crates/committer/src/patricia_merkle_tree/types.rs line 86 at r2 (raw file):

        let xor = adapted_self.0 ^ other.0;
        // The length of the reminder after removing the common prefix of the two nodes.

typo

Suggestion:

remainder

@TzahiTaub TzahiTaub force-pushed the tzahi/node_index/tight_range_checks branch 6 times, most recently from 1fd20f3 to 5f7259d Compare May 8, 2024 12:07
@TzahiTaub TzahiTaub force-pushed the tzahi/Node_index/get_lca branch 2 times, most recently from 40447a5 to 97bf4b9 Compare May 8, 2024 12:22
Copy link
Contributor Author

@TzahiTaub TzahiTaub 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: 2 of 6 files reviewed, 2 unresolved discussions (waiting on @amosStarkware and @dorimedini-starkware)


crates/committer/Cargo.toml line 15 at r2 (raw file):

pretty_assertions.workspace = true
rstest.workspace = true
rand.workspace = true

Done.


crates/committer/src/patricia_merkle_tree/types.rs line 83 at r2 (raw file):

Previously, dorimedini-starkware wrote…

clearer?
also removes the need for Ordering.
if you like minimal amount of lines you can replace the if .. else with match .. true => .. false => ..

Done.

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 r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @amosStarkware)

@TzahiTaub TzahiTaub force-pushed the tzahi/node_index/tight_range_checks branch from 5f7259d to 9fa2140 Compare May 8, 2024 12:35
@TzahiTaub TzahiTaub force-pushed the tzahi/Node_index/get_lca branch from 97bf4b9 to 1743662 Compare May 8, 2024 12:35
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)

@TzahiTaub TzahiTaub force-pushed the tzahi/Node_index/get_lca branch from 1743662 to b1e87fb Compare May 8, 2024 14:11
@TzahiTaub TzahiTaub changed the base branch from tzahi/node_index/tight_range_checks to main May 8, 2024 14:11
@TzahiTaub TzahiTaub enabled auto-merge May 8, 2024 14:11
Copy link
Contributor Author

@TzahiTaub TzahiTaub left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @amosStarkware)

@TzahiTaub TzahiTaub added this pull request to the merge queue May 8, 2024
Merged via the queue into main with commit aa7f27e May 8, 2024
18 checks passed
@TzahiTaub TzahiTaub deleted the tzahi/Node_index/get_lca branch May 9, 2024 07:55
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