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

refactor(consensus): the Context is passed as a param instead of being held as a field by SHC #2238

Merged

Conversation

matan-starkware
Copy link
Contributor

@matan-starkware matan-starkware commented Jul 18, 2024

This change is Reviewable

@matan-starkware matan-starkware marked this pull request as ready for review July 18, 2024 15:37
@matan-starkware matan-starkware changed the title refactor(consensus): Context is passed as a param instead of being held as a field by SHC refactor(consensus): the Context is passed as a param instead of being held as a field by SHC Jul 18, 2024
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

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

Project coverage is 66.31%. Comparing base (537e11e) to head (069a8a8).

Files Patch % Lines
...g/papyrus_consensus/src/single_height_consensus.rs 0.00% 3 Missing ⚠️
crates/papyrus_node/src/main.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2238      +/-   ##
==========================================
+ Coverage   66.29%   66.31%   +0.01%     
==========================================
  Files         139      139              
  Lines       18347    18341       -6     
  Branches    18347    18341       -6     
==========================================
- Hits        12163    12162       -1     
+ Misses       4889     4883       -6     
- Partials     1295     1296       +1     

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

@matan-starkware matan-starkware force-pushed the matan/consensus/m3/pass_context_by_reference_shc branch 2 times, most recently from 3630e0a to 9378b37 Compare July 19, 2024 09:18
asmaastarkware
asmaastarkware previously approved these changes Jul 21, 2024
Copy link
Contributor

@asmaastarkware asmaastarkware 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 6 of 6 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @matan-starkware)

@matan-starkware matan-starkware force-pushed the matan/consensus/m3/pass_validators_to_shc_new branch from aca27b3 to 9cc64d9 Compare July 22, 2024 05:38
@matan-starkware matan-starkware force-pushed the matan/consensus/m3/pass_context_by_reference_shc branch from 9378b37 to 9aa2aec Compare July 22, 2024 05:38
Copy link
Contributor

@ShahakShama ShahakShama 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: all files reviewed, 3 unresolved discussions (waiting on @matan-starkware)


crates/sequencing/papyrus_consensus/src/lib.rs line 39 at r1 (raw file):

#[allow(missing_docs)]
async fn run_height<BlockT: ConsensusBlock>(
    context: &impl ConsensusContext<Block = BlockT>,

IMO impl should be used only if you have this type in this 1 place. Since you're using it everywhere, IMO <ConsensusContextT: ConsensusContext> will be cleaner
Same in SHC


crates/sequencing/papyrus_consensus/src/single_height_consensus.rs line 57 at r1 (raw file):

    pub(crate) async fn start(
        &mut self,
        context: &impl ConsensusContext<Block = BlockT>,

You're choosing here that each function can have a different type of context instead of having the context type hardcoded in the struct with a phantom. I'm just making sure you're aware of the 2 different options here and that you chose the one more correct to your case


crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs line 63 at r1 (raw file):

    // Sends proposal and prevote.
    assert!(matches!(shc.start(&context,).await, Ok(None)));

why ,?

Base automatically changed from matan/consensus/m3/pass_validators_to_shc_new to main July 22, 2024 08:01
@matan-starkware matan-starkware dismissed asmaastarkware’s stale review July 22, 2024 08:01

The base branch was changed.

@matan-starkware matan-starkware force-pushed the matan/consensus/m3/pass_context_by_reference_shc branch from 9aa2aec to d9610d2 Compare July 22, 2024 08:20
Copy link
Contributor Author

@matan-starkware matan-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: 3 of 6 files reviewed, 3 unresolved discussions (waiting on @asmaastarkware and @ShahakShama)


crates/sequencing/papyrus_consensus/src/lib.rs line 39 at r1 (raw file):

Previously, ShahakShama wrote…

IMO impl should be used only if you have this type in this 1 place. Since you're using it everywhere, IMO <ConsensusContextT: ConsensusContext> will be cleaner
Same in SHC

Done.


crates/sequencing/papyrus_consensus/src/single_height_consensus.rs line 57 at r1 (raw file):

Previously, ShahakShama wrote…

You're choosing here that each function can have a different type of context instead of having the context type hardcoded in the struct with a phantom. I'm just making sure you're aware of the 2 different options here and that you chose the one more correct to your case

Yes I'm aware. My feeling was that context is basically an outside resource and the caller can pass it what it wants. It would be very weird for it to pass multiple types, but I felt that adding PhantomData to the struct definition increases complexity for a benefit that I am not sure exists.


crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs line 63 at r1 (raw file):

Previously, ShahakShama wrote…

why ,?

Done.

Copy link
Contributor

@ShahakShama ShahakShama 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 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @matan-starkware)

@matan-starkware matan-starkware force-pushed the matan/consensus/m3/pass_context_by_reference_shc branch from d9610d2 to 069a8a8 Compare July 22, 2024 10:31
Copy link
Contributor

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

@matan-starkware matan-starkware added this pull request to the merge queue Jul 22, 2024
Merged via the queue into main with commit 2db883b Jul 22, 2024
19 checks passed
@matan-starkware matan-starkware deleted the matan/consensus/m3/pass_context_by_reference_shc branch July 22, 2024 10:55
dan-starkware pushed a commit that referenced this pull request Jul 23, 2024
dan-starkware pushed a commit that referenced this pull request Jul 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 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