You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
6.7 KiB

  1. # Tendermint Consensus Reactor
  2. Tendermint Consensus is a distributed protocol executed by validator processes to agree on
  3. the next block to be added to the Tendermint blockchain. The protocol proceeds in rounds, where
  4. each round is a try to reach agreement on the next block. A round starts by having a dedicated
  5. process (called proposer) suggesting to other processes what should be the next block with
  6. the `ProposalMessage`.
  7. The processes respond by voting for a block with `VoteMessage` (there are two kinds of vote
  8. messages, prevote and precommit votes). Note that a proposal message is just a suggestion what the
  9. next block should be; a validator might vote with a `VoteMessage` for a different block. If in some
  10. round, enough number of processes vote for the same block, then this block is committed and later
  11. added to the blockchain. `ProposalMessage` and `VoteMessage` are signed by the private key of the
  12. validator. The internals of the protocol and how it ensures safety and liveness properties are
  13. explained in a forthcoming document.
  14. For efficiency reasons, validators in Tendermint consensus protocol do not agree directly on the
  15. block as the block size is big, i.e., they don't embed the block inside `Proposal` and
  16. `VoteMessage`. Instead, they reach agreement on the `BlockID` (see `BlockID` definition in
  17. [Blockchain](https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#blockid) section) that uniquely identifies each block. The block itself is
  18. disseminated to validator processes using peer-to-peer gossiping protocol. It starts by having a
  19. proposer first splitting a block into a number of block parts, that are then gossiped between
  20. processes using `BlockPartMessage`.
  21. Validators in Tendermint communicate by peer-to-peer gossiping protocol. Each validator is connected
  22. only to a subset of processes called peers. By the gossiping protocol, a validator send to its peers
  23. all needed information (`ProposalMessage`, `VoteMessage` and `BlockPartMessage`) so they can
  24. reach agreement on some block, and also obtain the content of the chosen block (block parts). As
  25. part of the gossiping protocol, processes also send auxiliary messages that inform peers about the
  26. executed steps of the core consensus algorithm (`NewRoundStepMessage` and `NewValidBlockMessage`), and
  27. also messages that inform peers what votes the process has seen (`HasVoteMessage`,
  28. `VoteSetMaj23Message` and `VoteSetBitsMessage`). These messages are then used in the gossiping
  29. protocol to determine what messages a process should send to its peers.
  30. We now describe the content of each message exchanged during Tendermint consensus protocol.
  31. ## ProposalMessage
  32. ProposalMessage is sent when a new block is proposed. It is a suggestion of what the
  33. next block in the blockchain should be.
  34. ```go
  35. type ProposalMessage struct {
  36. Proposal Proposal
  37. }
  38. ```
  39. ### Proposal
  40. Proposal contains height and round for which this proposal is made, BlockID as a unique identifier
  41. of proposed block, timestamp, and POLRound (a so-called Proof-of-Lock (POL) round) that is needed for
  42. termination of the consensus. If POLRound >= 0, then BlockID corresponds to the block that
  43. is locked in POLRound. The message is signed by the validator private key.
  44. ```go
  45. type Proposal struct {
  46. Height int64
  47. Round int
  48. POLRound int
  49. BlockID BlockID
  50. Timestamp Time
  51. Signature Signature
  52. }
  53. ```
  54. ## VoteMessage
  55. VoteMessage is sent to vote for some block (or to inform others that a process does not vote in the
  56. current round). Vote is defined in the [Blockchain](https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#blockid) section and contains validator's
  57. information (validator address and index), height and round for which the vote is sent, vote type,
  58. blockID if process vote for some block (`nil` otherwise) and a timestamp when the vote is sent. The
  59. message is signed by the validator private key.
  60. ```go
  61. type VoteMessage struct {
  62. Vote Vote
  63. }
  64. ```
  65. ## BlockPartMessage
  66. BlockPartMessage is sent when gossipping a piece of the proposed block. It contains height, round
  67. and the block part.
  68. ```go
  69. type BlockPartMessage struct {
  70. Height int64
  71. Round int
  72. Part Part
  73. }
  74. ```
  75. ## NewRoundStepMessage
  76. NewRoundStepMessage is sent for every step transition during the core consensus algorithm execution.
  77. It is used in the gossip part of the Tendermint protocol to inform peers about a current
  78. height/round/step a process is in.
  79. ```go
  80. type NewRoundStepMessage struct {
  81. Height int64
  82. Round int
  83. Step RoundStepType
  84. SecondsSinceStartTime int
  85. LastCommitRound int
  86. }
  87. ```
  88. ## NewValidBlockMessage
  89. NewValidBlockMessage is sent when a validator observes a valid block B in some round r,
  90. i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r.
  91. It contains height and round in which valid block is observed, block parts header that describes
  92. the valid block and is used to obtain all
  93. block parts, and a bit array of the block parts a process currently has, so its peers can know what
  94. parts it is missing so they can send them.
  95. In case the block is also committed, then IsCommit flag is set to true.
  96. ```go
  97. type NewValidBlockMessage struct {
  98. Height int64
  99. Round int
  100. BlockPartsHeader PartSetHeader
  101. BlockParts BitArray
  102. IsCommit bool
  103. }
  104. ```
  105. ## ProposalPOLMessage
  106. ProposalPOLMessage is sent when a previous block is re-proposed.
  107. It is used to inform peers in what round the process learned for this block (ProposalPOLRound),
  108. and what prevotes for the re-proposed block the process has.
  109. ```go
  110. type ProposalPOLMessage struct {
  111. Height int64
  112. ProposalPOLRound int
  113. ProposalPOL BitArray
  114. }
  115. ```
  116. ## HasVoteMessage
  117. HasVoteMessage is sent to indicate that a particular vote has been received. It contains height,
  118. round, vote type and the index of the validator that is the originator of the corresponding vote.
  119. ```go
  120. type HasVoteMessage struct {
  121. Height int64
  122. Round int
  123. Type byte
  124. Index int
  125. }
  126. ```
  127. ## VoteSetMaj23Message
  128. VoteSetMaj23Message is sent to indicate that a process has seen +2/3 votes for some BlockID.
  129. It contains height, round, vote type and the BlockID.
  130. ```go
  131. type VoteSetMaj23Message struct {
  132. Height int64
  133. Round int
  134. Type byte
  135. BlockID BlockID
  136. }
  137. ```
  138. ## VoteSetBitsMessage
  139. VoteSetBitsMessage is sent to communicate the bit-array of votes a process has seen for a given
  140. BlockID. It contains height, round, vote type, BlockID and a bit array of
  141. the votes a process has.
  142. ```go
  143. type VoteSetBitsMessage struct {
  144. Height int64
  145. Round int
  146. Type byte
  147. BlockID BlockID
  148. Votes BitArray
  149. }
  150. ```