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.

199 lines
8.1 KiB

  1. # Evidence
  2. Evidence is an important component of Tendermint's security model. Whilst the core
  3. consensus protocol provides correctness gaurantees for state machine replication
  4. that can tolerate less than 1/3 failures, the evidence system looks to detect and
  5. gossip byzantine faults whose combined power is greater than or equal to 1/3. It is worth noting that
  6. the evidence system is designed purely to detect possible attacks, gossip them,
  7. commit them on chain and inform the application running on top of Tendermint.
  8. Evidence in itself does not punish "bad actors", this is left to the discretion
  9. of the application. A common form of punishment is slashing where the validators
  10. that were caught violating the protocol have all or a portion of their voting
  11. power removed. Evidence, given the assumption that 1/3+ of the network is still
  12. byzantine, is susceptible to censorship and should therefore be considered added
  13. security on a "best effort" basis.
  14. This document walks through the various forms of evidence, how they are detected,
  15. gossiped, verified and committed.
  16. > NOTE: Evidence here is internal to tendermint and should not be confused with
  17. > application evidence
  18. ## Detection
  19. ### Equivocation
  20. Equivocation is the most fundamental of byzantine faults. Simply put, to prevent
  21. replication of state across all nodes, a validator tries to convince some subset
  22. of nodes to commit one block whilst convincing another subset to commit a
  23. different block. This is achieved by double voting (hence
  24. `DuplicateVoteEvidence`). A successful duplicate vote attack requires greater
  25. than 1/3 voting power and a (temporary) network partition between the aforementioned
  26. subsets. This is because in consensus, votes are gossiped around. When a node
  27. observes two conflicting votes from the same peer, it will use the two votes of
  28. evidence and begin gossiping this evidence to other nodes. [Verification](#duplicatevoteevidence) is addressed further down.
  29. ```go
  30. type DuplicateVoteEvidence struct {
  31. VoteA Vote
  32. VoteB Vote
  33. // and abci specific fields
  34. }
  35. ```
  36. ### Light Client Attacks
  37. Light clients also comply with the 1/3+ security model, however, by using a
  38. different, more lightweight verification method they are subject to a
  39. different kind of 1/3+ attack whereby the byzantine validators could sign an
  40. alternative light block that the light client will think is valid. Detection,
  41. explained in greater detail
  42. [here](../light-client/detection/detection_003_reviewed.md), involves comparison
  43. with multiple other nodes in the hope that at least one is "honest". An "honest"
  44. node will return a challenging light block for the light client to validate. If
  45. this challenging light block also meets the
  46. [validation criteria](../light-client/verification/verification_001_published.md)
  47. then the light client sends the "forged" light block to the node.
  48. [Verification](#lightclientattackevidence) is addressed further down.
  49. ```go
  50. type LightClientAttackEvidence struct {
  51. ConflictingBlock LightBlock
  52. CommonHeight int64
  53. // and abci specific fields
  54. }
  55. ```
  56. ## Verification
  57. If a node receives evidence, it will first try to verify it, then persist it.
  58. Evidence of byzantine behavior should only be committed once (uniqueness) and
  59. should be committed within a certain period from the point that it occurred
  60. (timely). Timelines is defined by the `EvidenceParams`: `MaxAgeNumBlocks` and
  61. `MaxAgeDuration`. In Proof of Stake chains where validators are bonded, evidence
  62. age should be less than the unbonding period so validators still can be
  63. punished. Given these two propoerties the following initial checks are made.
  64. 1. Has the evidence expired? This is done by taking the height of the `Vote`
  65. within `DuplicateVoteEvidence` or `CommonHeight` within
  66. `LightClientAttakEvidence`. The evidence height is then used to retrieve the
  67. header and thus the time of the block that corresponds to the evidence. If
  68. `CurrentHeight - MaxAgeNumBlocks > EvidenceHeight` && `CurrentTime -
  69. MaxAgeDuration > EvidenceTime`, the evidence is considered expired and
  70. ignored.
  71. 2. Has the evidence already been committed? The evidence pool tracks the hash of
  72. all committed evidence and uses this to determine uniqueness. If a new
  73. evidence has the same hash as a committed one, the new evidence will be
  74. ignored.
  75. ### DuplicateVoteEvidence
  76. Valid `DuplicateVoteEvidence` must adhere to the following rules:
  77. - Validator Address, Height, Round and Type must be the same for both votes
  78. - BlockID must be different for both votes (BlockID can be for a nil block)
  79. - Validator must have been in the validator set at that height
  80. - Vote signature must be correctly signed. This also uses `ChainID` so we know
  81. that the fault occurred on this chain
  82. ### LightClientAttackEvidence
  83. Valid Light Client Attack Evidence must adhere to the following rules:
  84. - If the header of the light block is invalid, thus indicating a lunatic attack,
  85. the node must check that they can use `verifySkipping` from their header at
  86. the common height to the conflicting header
  87. - If the header is valid, then the validator sets are the same and this is
  88. either a form of equivocation or amnesia. We therefore check that 2/3 of the
  89. validator set also signed the conflicting header.
  90. - The nodes own header at the same height as the conflicting header must have a
  91. different hash to the conflicting header.
  92. - If the nodes latest header is less in height to the conflicting header, then
  93. the node must check that the conflicting block has a time that is less than
  94. this latest header (This is a forward lunatic attack).
  95. ## Gossiping
  96. If a node verifies evidence it then broadcasts it to all peers, continously sending
  97. the same evidence once every 10 seconds until the evidence is seen on chain or
  98. expires.
  99. ## Commiting on Chain
  100. Evidence takes strict priority over regular transactions, thus a block is filled
  101. with evidence first and transactions take up the remainder of the space. To
  102. mitigate the threat of an already punished node from spamming the network with
  103. more evidence, the size of the evidence in a block can be capped by
  104. `EvidenceParams.MaxBytes`. Nodes receiving blocks with evidence will validate
  105. the evidence before sending `Prevote` and `Precommit` votes. The evidence pool
  106. will usually cache verifications so that this process is much quicker.
  107. ## Sending Evidence to the Application
  108. After evidence is committed, the block is then processed by the block executor
  109. which delivers the evidence to the application via `EndBlock`. Evidence is
  110. stripped of the actual proof, split up per faulty validator and only the
  111. validator, height, time and evidence type is sent.
  112. ```proto
  113. enum EvidenceType {
  114. UNKNOWN = 0;
  115. DUPLICATE_VOTE = 1;
  116. LIGHT_CLIENT_ATTACK = 2;
  117. }
  118. message Evidence {
  119. EvidenceType type = 1;
  120. // The offending validator
  121. Validator validator = 2 [(gogoproto.nullable) = false];
  122. // The height when the offense occurred
  123. int64 height = 3;
  124. // The corresponding time where the offense occurred
  125. google.protobuf.Timestamp time = 4 [
  126. (gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  127. // Total voting power of the validator set in case the ABCI application does
  128. // not store historical validators.
  129. // https://github.com/tendermint/tendermint/issues/4581
  130. int64 total_voting_power = 5;
  131. }
  132. ```
  133. `DuplicateVoteEvidence` and `LightClientAttackEvidence` are self-contained in
  134. the sense that the evidence can be used to derive the `abci.Evidence` that is
  135. sent to the application. Because of this, extra fields are necessary:
  136. ```go
  137. type DuplicateVoteEvidence struct {
  138. VoteA *Vote
  139. VoteB *Vote
  140. // abci specific information
  141. TotalVotingPower int64
  142. ValidatorPower int64
  143. Timestamp time.Time
  144. }
  145. type LightClientAttackEvidence struct {
  146. ConflictingBlock *LightBlock
  147. CommonHeight int64
  148. // abci specific information
  149. ByzantineValidators []*Validator
  150. TotalVotingPower int64
  151. Timestamp time.Time
  152. }
  153. ```
  154. These ABCI specific fields don't affect validity of the evidence itself but must
  155. be consistent amongst nodes and agreed upon on chain. If evidence with the
  156. incorrect abci information is sent, a node will create new evidence from it and
  157. replace the ABCI fields with the correct information.