PBFT refactor
PBFT refactor
Description
Goal of this refactor is to split PbftManager class and increase readability by this.
We have a few main logical parts in our consensus algorithm and all this logic was in one PbftManager class with numerous bool flags and variables in it. And right now we have corresponding classes for it with its own states and related logic
-
RoundFaceis abstract class used by step classes. This is needed to not create cyclic dependency betweenRoundandStepclasses. Have fields and methods that used by that step classes.Roundclass is managing steps switching and timers. Steps switching and timers was reworked and we didn't have numerous bool flags and timestamps. Now we are switching to next step if previous was finished. If we are finished earlier with step then next should start we are waiting forend_timein methodfinishinStep. -
Step. We have 5 types of steps that inherits base class
Step.1.1.
Stepis abstract class and base class for all steps. Have methods and fields that is common for more some steps. For example methodplaceVote, that is used by every step.1.2.
Propose. Step 1 of consensus. Creates and propagates block proposal if current node needs to make one.1.3.
Filter. Step 2 of consensus. Picking best proposal fromStep1andsoft-votingon it if this node picked to vote.1.4.
Certify. Step 3 of consensus.cert-votingon some value if saw2t+1soft-voteson some value.1.5.
Finish. Step 4 of consensus.next-votingstep. Checks if we certified a value in current round or not and voting correspondingly1.6.
Polling. Step 5 of consensus.next-votingstep. Voting result depends onsoft-voting
Tasks
Separate steps Separate round and steps switching Optimize logging in steps Remove dependency of all new consensus classes from PbftManager