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