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

[Consensus] Decoupling the Pacemaker and Consensus modules (Synchronous method) #427

Merged
merged 71 commits into from
Jan 24, 2023

Conversation

gokutheengineer
Copy link
Contributor

@gokutheengineer gokutheengineer commented Jan 4, 2023

Description

This PR aims to decouple the consensus module and pacemaker module by making the pacemaker module a submodule of the consensus module.

In a nutshell, this PR includes and introduces:

  • The Pacemaker submodule
  • A shared ConsensusPacemaker interface used by the Pacemaker submodule
  • Renames some fields to improving code quality

Issue

Fixes (partially as intermediate step) #395

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation

List of changes

  • Defined a new shared interface called PaceMakerAccessModule which is implemented by Consensus module
  • Removed the consensus module field from Pacemaker struct
  • Made pacemaker a separate submodule
  • Modified the pacemaker to access the consensus module in a synchronous matter via the PaceMakerAccessModule interface

Testing

  • make develop_test
  • LocalNet w/ all of the steps outlined in the README

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested my changes using the available tooling
  • I have updated the corresponding CHANGELOG

If Applicable Checklist

  • I have updated the corresponding README(s); local and/or global
  • I have added tests that prove my fix is effective or that my feature works
  • I have added, or updated, mermaid.js diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@gokutheengineer gokutheengineer added the code health Nice to have code improvement label Jan 4, 2023
@gokutheengineer gokutheengineer marked this pull request as draft January 4, 2023 20:31
@Olshansk Olshansk added the consensus Consensus specific changes label Jan 4, 2023
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

Took a first pass at this. Let's clean it up a bit and I'll look deeper

consensus/module.go Outdated Show resolved Hide resolved
consensus/module.go Show resolved Hide resolved
consensus/module.go Show resolved Hide resolved
consensus/module.go Outdated Show resolved Hide resolved
consensus/module.go Outdated Show resolved Hide resolved
consensus/pacemaker/pacemaker.go Outdated Show resolved Hide resolved
consensus/pacemaker/pacemaker.go Outdated Show resolved Hide resolved
consensus/pacemaker/pacemaker.go Outdated Show resolved Hide resolved
consensus/pacemaker/pacemaker.go Outdated Show resolved Hide resolved
consensus/module.go Outdated Show resolved Hide resolved
@gokutheengineer gokutheengineer marked this pull request as ready for review January 5, 2023 12:38
@Olshansk Olshansk changed the title Issue 395 intermediate solution for separating pacemaker and consensus modules [Consensus] Intermediate solution for decoupling the Pacemaker and Consensus modules Jan 5, 2023
@gokutheengineer gokutheengineer changed the title [Consensus] Intermediate solution for decoupling the Pacemaker and Consensus modules [Consensus] Decoupling the Pacemaker and Consensus modules (Synchronous method) Jan 6, 2023
consensus/helpers.go Outdated Show resolved Hide resolved
consensus/hotstuff_leader.go Outdated Show resolved Hide resolved
consensus/hotstuff_leader.go Outdated Show resolved Hide resolved
consensus/module.go Show resolved Hide resolved
consensus/pacemaker/pacemaker.go Show resolved Hide resolved
shared/docs/PROTOCOL_STATE_HASH.md Outdated Show resolved Hide resolved
consensus/pacemaker_consensus.go Outdated Show resolved Hide resolved
consensus/pacemaker_consensus.go Outdated Show resolved Hide resolved
consensus/pacemaker_consensus.go Show resolved Hide resolved
consensus/pacemaker/pacemaker.go Outdated Show resolved Hide resolved
@Olshansk
Copy link
Member

Olshansk commented Jan 6, 2023

@gokutheengineer Also, please make sure this works with LocalNet

@Olshansk
Copy link
Member

Olshansk commented Jan 6, 2023

@gokutheengineer Would also appreciate if you could look into TestHotstuff4Nodes1BlockHappyPath to add a small/simple unit test. Hopefully it's an opportunity to get your hands dirty with the testing framework.

Will be easier after I merge my PR in though.

@gokutheengineer
Copy link
Contributor Author

gokutheengineer commented Jan 8, 2023

@gokutheengineer Also, please make sure this works with LocalNet

I am facing with problems running LocalNet, even on fresh clone with the latest main branch. I opened this ticket: #433

So as is, this branch doesn't execute correctly with LocalNet, but first we need to understand if what I am facing with the LocalNet as explained in the ticket is a general issue or not. Only after that diagnosis, and possible fix, I will be able to test with LocalNet.

@gokutheengineer
Copy link
Contributor Author

@gokutheengineer Would also appreciate if you could look into TestHotstuff4Nodes1BlockHappyPath to add a small/simple unit test. Hopefully it's an opportunity to get your hands dirty with the testing framework.

Will be easier after I merge my PR in though.

Okay, since I presume the merge will happen very soon, I will implement after the merge.

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me!

Let's get #404 over the finish line, I followed up on #433, and this should be almost good to go

consensus/pacemaker/pacemaker.go Outdated Show resolved Hide resolved
consensus/pacemaker_consensus.go Outdated Show resolved Hide resolved
shared/modules/consensus_module.go Outdated Show resolved Hide resolved
shared/modules/consensus_module.go Outdated Show resolved Hide resolved
@Olshansk
Copy link
Member

@gokutheengineer Per our discussion offline, here's a video with a bit of an explanation of my approach to merging with main and reviewing PRs: https://drive.google.com/file/d/1wmJHYFt8y-G7uWNur_k7K-D3XzJ4Q6XQ/view?usp=sharing

It's a little long (raw and unedited) but hopefully it helps.

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

@gokutheengineer I tested this locally, made a few minor NITS (and fixed an unresolved merge conflict) to help get this over the finish line.

Let's MERGE IT IN!

@gokutheengineer gokutheengineer merged commit 1bf119b into main Jan 24, 2023
@gokutheengineer gokutheengineer deleted the issue/395-decouple-consensus-and-pacemaker branch January 24, 2023 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Nice to have code improvement consensus Consensus specific changes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants