| layout | post |
|---|---|
| permalink | /how-the-consensus-protocol-works/ |
There are two protocols in SEBAK. One is ISAAC protocol for consensus and another is Transaction Protocol for sharing transactions.
The ISAAC is a consensus protocol based on PBFT.
In the ISAAC, all nodes will vote two times to determine which transactions to include in this block.
For each voting unit, the nodes have the role proposer or validator.
The proposer gathers the transactions for this vote and puts them in a ballot and passes it to the validators.
The validator checks that the transactions in the ballot are valid and then votes.
If the voting determines that the ballot is valid, all nodes confirm the transactions in the ballot.
'Height + 1'
┌──────────────────────────────────────────────────────────────────────────────────┐
╎ ╎
╎ ╎
╎ 'get ballot' 'get 67% of YES' 'get 67% of YES' ╎
▼ ╎
INIT ────────────────────> SIGN ──────────────────> ACCEPT ──────────────────> ALL_CONFIRM
▲ ╎ ╎
╎ ╎ ╎
╎ 'get 34% of NO or EXP' ╎ 'get 34% of NO or EXP' ╎
╎ ╎ ╎
└────────────────────────────────────────────────────┘
'Round + 1'
-
INIT- Proposed or received a ballot with transactions. -
SIGN- Checked that the ballot is valid by itself. -
ACCEPT- Checked that the ballot is valid by validators. -
ALL_CONFIRM- Confirmed block with the transactions in the ballot.
-
YES- Agreed -
NO- Disagreed -
EXP- Expired
-
TIMEOUT_INIT - The timeout for
INITstate. The default value is 2 sec. -
TIMEOUT_SIGN - The timeout for
SIGNstate. The default value is 2 sec. -
TIMEOUT_ACCEPT - The timeout for
ACCEPTstate. The default value is 2 sec. -
B(ISAAC State, Voting Hole) - A ballot with ISAAC state and voting hole.
-
B(
INIT,YES) - A ballot with ISAAC stateINITand voting holeYES. -
B(
SIGN,NO) - A ballot with ISAAC stateINITand voting holeNO. -
B(
ACCEPT,EXP) - A ballot with ISAAC stateINITand voting holeEXP.
- At the beginning of the network, the genesis block is saved with block height 1 and round 0.
- The node start with
INITstate, height 2 and round 0.
- The timer is set to TIMEOUT_INIT.
- The steps to propose transactions are as follows.
- If the node is proposer of this round, it broadcasts a B(
INIT,YES),- The ballot includes valid transactions(only hashes) or empty(If the transaction pool is empty).
- When the node broadcasts the ballot, the node goes to the next state.
- If the node is not
proposer, it waits until receiving the B(INIT,YES).- When it receives the ballot, the node goes to the next state.
- When the timer expires, the node goes to the next state.
- If the node is proposer of this round, it broadcasts a B(
- The timer is reset to TIMEOUT_SIGN.
- The node checks the proposed ballot is valid.
- If the proposed ballot is valid(or empty), the node broadcasts B(
SIGN,YES). - If the proposed ballot is invalid, the node broadcasts B(
SIGN,NO). - When the timer expires, the node hasn't sent a ballot in
SIGNstate yet, it broadcasts B(SIGN,EXP).
- If the proposed ballot is valid(or empty), the node broadcasts B(
- Each node receives ballots and goes to the next state after,
- the number of B(
SIGN,YES) is greater than or equal to 67% of validators, the node broadcasts B(ACCEPT,YES). - the number of B(
SIGN,NO) or B(SIGN,EXP) is greater than 33% of validators, the node goes back toINITstate with same height and round + 1.
- the number of B(
- The timer is reset to TIMEOUT_ACCEPT.
- When the timer expires, the node hasn't sent a ballot in
ACCEPTstate yet, it broadcasts B(ACCEPT,EXP). - Each node receives ballots and,
- if the number of B(
ACCEPT,YES) is greater than or equal to 67% of validators, the node goes to the next state. - if the number of B(
ACCEPT,NO) or B(ACCEPT,EXP) is greater than 33% of validators, the node goes back toINITstate with same height and round + 1.
- if the number of B(
- the node confirms and saves the block with proposed transactions even though it is empty.
- the node filters invalid transactions in the transaction pool.
- It goes to
INITstate with height + 1 and round 0.
- If the node is
proposer, it waits for block time buffer and propose. - Else, it waits for
block time buffer+ TIMEOUT_INIT to receive proposed ballot.
Transaction Protocolis a protocol for sharing transactions between the nodes.