taraxa-node icon indicating copy to clipboard operation
taraxa-node copied to clipboard

PBFT refactor

Open kstdl opened this issue 3 years ago • 0 comments

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

  1. RoundFace is abstract class used by step classes. This is needed to not create cyclic dependency between Round and Step classes. Have fields and methods that used by that step classes. Round class 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 for end_time in method finish in Step.

  2. Step. We have 5 types of steps that inherits base class Step.

    1.1. Step is abstract class and base class for all steps. Have methods and fields that is common for more some steps. For example method placeVote, 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 from Step1 and soft-voting on it if this node picked to vote.

    1.4. Certify. Step 3 of consensus. cert-voting on some value if saw 2t+1 soft-votes on some value.

    1.5. Finish. Step 4 of consensus. next-voting step. Checks if we certified a value in current round or not and voting correspondingly

    1.6. Polling. Step 5 of consensus. next-voting step. Voting result depends on soft-voting

Tasks

Separate steps Separate round and steps switching Optimize logging in steps Remove dependency of all new consensus classes from PbftManager

kstdl avatar Jun 27 '22 15:06 kstdl