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.

456 lines
44 KiB

  1. # Data Structures
  2. Here we describe the data structures in the Tendermint blockchain and the rules for validating them.
  3. The Tendermint blockchains consists of a short list of data types:
  4. - [Data Structures](#data-structures)
  5. - [Block](#block)
  6. - [Execution](#execution)
  7. - [Header](#header)
  8. - [Version](#version)
  9. - [BlockID](#blockid)
  10. - [PartSetHeader](#partsetheader)
  11. - [Part](#part)
  12. - [Time](#time)
  13. - [Data](#data)
  14. - [Commit](#commit)
  15. - [CommitSig](#commitsig)
  16. - [BlockIDFlag](#blockidflag)
  17. - [Vote](#vote)
  18. - [CanonicalVote](#canonicalvote)
  19. - [Proposal](#proposal)
  20. - [SignedMsgType](#signedmsgtype)
  21. - [Signature](#signature)
  22. - [EvidenceList](#evidencelist)
  23. - [Evidence](#evidence)
  24. - [DuplicateVoteEvidence](#duplicatevoteevidence)
  25. - [LightClientAttackEvidence](#lightclientattackevidence)
  26. - [LightBlock](#lightblock)
  27. - [SignedHeader](#signedheader)
  28. - [ValidatorSet](#validatorset)
  29. - [Validator](#validator)
  30. - [Address](#address)
  31. - [ConsensusParams](#consensusparams)
  32. - [BlockParams](#blockparams)
  33. - [EvidenceParams](#evidenceparams)
  34. - [ValidatorParams](#validatorparams)
  35. - [VersionParams](#versionparams)
  36. - [Proof](#proof)
  37. ## Block
  38. A block consists of a header, transactions, votes (the commit),
  39. and a list of evidence of malfeasance (ie. signing conflicting votes).
  40. | Name | Type | Description | Validation |
  41. |--------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
  42. | Header | [Header](#header) | Header corresponding to the block. This field contains information used throughout consensus and other areas of the protocol. To find out what it contains, visit [header] (#header) | Must adhere to the validation rules of [header](#header) |
  43. | Data | [Data](#data) | Data contains a list of transactions. The contents of the transaction is unknown to Tendermint. | This field can be empty or populated, but no validation is performed. Applications can perform validation on individual transactions prior to block creation using [checkTx](../abci/abci.md#checktx).
  44. | Evidence | [EvidenceList](#evidence_list) | Evidence contains a list of infractions committed by validators. | Can be empty, but when populated the validations rules from [evidenceList](#evidence_list) apply |
  45. | LastCommit | [Commit](#commit) | `LastCommit` includes one vote for every validator. All votes must either be for the previous block, nil or absent. If a vote is for the previous block it must have a valid signature from the corresponding validator. The sum of the voting power of the validators that voted must be greater than 2/3 of the total voting power of the complete validator set. The number of votes in a commit is limited to 10000 (see `types.MaxVotesCount`). | Must be empty for the initial height and must adhere to the validation rules of [commit](#commit). |
  46. ## Execution
  47. Once a block is validated, it can be executed against the state.
  48. The state follows this recursive equation:
  49. ```go
  50. state(initialHeight) = InitialState
  51. state(h+1) <- Execute(state(h), ABCIApp, block(h))
  52. ```
  53. where `InitialState` includes the initial consensus parameters and validator set,
  54. and `ABCIApp` is an ABCI application that can return results and changes to the validator
  55. set (TODO). Execute is defined as:
  56. ```go
  57. func Execute(s State, app ABCIApp, block Block) State {
  58. // Fuction ApplyBlock executes block of transactions against the app and returns the new root hash of the app state,
  59. // modifications to the validator set and the changes of the consensus parameters.
  60. AppHash, ValidatorChanges, ConsensusParamChanges := app.ApplyBlock(block)
  61. nextConsensusParams := UpdateConsensusParams(state.ConsensusParams, ConsensusParamChanges)
  62. return State{
  63. ChainID: state.ChainID,
  64. InitialHeight: state.InitialHeight,
  65. LastResults: abciResponses.DeliverTxResults,
  66. AppHash: AppHash,
  67. InitialHeight: state.InitialHeight,
  68. LastValidators: state.Validators,
  69. Validators: state.NextValidators,
  70. NextValidators: UpdateValidators(state.NextValidators, ValidatorChanges),
  71. ConsensusParams: nextConsensusParams,
  72. Version: {
  73. Consensus: {
  74. AppVersion: nextConsensusParams.Version.AppVersion,
  75. },
  76. },
  77. }
  78. }
  79. ```
  80. Validating a new block is first done prior to the `prevote`, `precommit` & `finalizeCommit` stages.
  81. The steps to validate a new block are:
  82. - Check the validity rules of the block and its fields.
  83. - Check the versions (Block & App) are the same as in local state.
  84. - Check the chainID's match.
  85. - Check the height is correct.
  86. - Check the `LastBlockID` corresponds to BlockID currently in state.
  87. - Check the hashes in the header match those in state.
  88. - Verify the LastCommit against state, this step is skipped for the initial height.
  89. - This is where checking the signatures correspond to the correct block will be made.
  90. - Make sure the proposer is part of the validator set.
  91. - Validate bock time.
  92. - Make sure the new blocks time is after the previous blocks time.
  93. - Calculate the medianTime and check it against the blocks time.
  94. - If the blocks height is the initial height then check if it matches the genesis time.
  95. - Validate the evidence in the block. Note: Evidence can be empty
  96. ## Header
  97. A block header contains metadata about the block and about the consensus, as well as commitments to
  98. the data in the current block, the previous block, and the results returned by the application:
  99. | Name | Type | Description | Validation |
  100. |-------------------|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  101. | Version | [Version](#version) | Version defines the application and protocol version being used. | Must adhere to the validation rules of [Version](#version) |
  102. | ChainID | String | ChainID is the ID of the chain. This must be unique to your chain. | ChainID must be less than 50 bytes. |
  103. | Height | uint64 | Height is the height for this header. | Must be > 0, >= initialHeight, and == previous Height+1 |
  104. | Time | [Time](#time) | The timestamp is equal to the weighted median of validators present in the last commit. Read more on time in the [BFT-time section](../consensus/bft-time.md). Note: the timestamp of a vote must be greater by at least one millisecond than that of the block being voted on. | Time must be >= previous header timestamp + consensus parameters TimeIotaMs. The timestamp of the first block must be equal to the genesis time (since there's no votes to compute the median). |
  105. | LastBlockID | [BlockID](#blockid) | BlockID of the previous block. | Must adhere to the validation rules of [blockID](#blockid). The first block has `block.Header.LastBlockID == BlockID{}`. |
  106. | LastCommitHash | slice of bytes (`[]byte`) | MerkleRoot of the lastCommit's signatures. The signatures represent the validators that committed to the last block. The first block has an empty slices of bytes for the hash. | Must be of length 32 |
  107. | DataHash | slice of bytes (`[]byte`) | MerkleRoot of the hash of transactions. **Note**: The transactions are hashed before being included in the merkle tree, the leaves of the Merkle tree are the hashes, not the transactions themselves. | Must be of length 32 |
  108. | ValidatorHash | slice of bytes (`[]byte`) | MerkleRoot of the current validator set. The validators are first sorted by voting power (descending), then by address (ascending) prior to computing the MerkleRoot. | Must be of length 32 |
  109. | NextValidatorHash | slice of bytes (`[]byte`) | MerkleRoot of the next validator set. The validators are first sorted by voting power (descending), then by address (ascending) prior to computing the MerkleRoot. | Must be of length 32 |
  110. | ConsensusHash | slice of bytes (`[]byte`) | Hash of the protobuf encoded consensus parameters. | Must be of length 32 |
  111. | AppHash | slice of bytes (`[]byte`) | Arbitrary byte array returned by the application after executing and commiting the previous block. It serves as the basis for validating any merkle proofs that comes from the ABCI application and represents the state of the actual application rather than the state of the blockchain itself. The first block's `block.Header.AppHash` is given by `ResponseInitChain.app_hash`. | This hash is determined by the application, Tendermint can not perform validation on it. |
  112. | LastResultHash | slice of bytes (`[]byte`) | `LastResultsHash` is the root hash of a Merkle tree built from `ResponseDeliverTx` responses (`Log`,`Info`, `Codespace` and `Events` fields are ignored). | Must be of length 32. The first block has `block.Header.ResultsHash == MerkleRoot(nil)`, i.e. the hash of an empty input, for RFC-6962 conformance. |
  113. | EvidenceHash | slice of bytes (`[]byte`) | MerkleRoot of the evidence of Byzantine behaviour included in this block. | Must be of length 32 |
  114. | ProposerAddress | slice of bytes (`[]byte`) | Address of the original proposer of the block. Validator must be in the current validatorSet. | Must be of length 20 |
  115. ## Version
  116. NOTE: that this is more specifically the consensus version and doesn't include information like the
  117. P2P Version. (TODO: we should write a comprehensive document about
  118. versioning that this can refer to)
  119. | Name | type | Description | Validation |
  120. |-------|--------|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
  121. | Block | uint64 | This number represents the version of the block protocol and must be the same throughout an operational network | Must be equal to protocol version being used in a network (`block.Version.Block == state.Version.Consensus.Block`) |
  122. | App | uint64 | App version is decided on by the application. Read [here](../abci/abci.md#info) | `block.Version.App == state.Version.Consensus.App` |
  123. ## BlockID
  124. The `BlockID` contains two distinct Merkle roots of the block. The `BlockID` includes these two hashes, as well as the number of parts (ie. `len(MakeParts(block))`)
  125. | Name | Type | Description | Validation |
  126. |---------------|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
  127. | Hash | slice of bytes (`[]byte`) | MerkleRoot of all the fields in the header (ie. `MerkleRoot(header)`. | hash must be of length 32 |
  128. | PartSetHeader | [PartSetHeader](#PartSetHeader) | Used for secure gossiping of the block during consensus, is the MerkleRoot of the complete serialized block cut into parts (ie. `MerkleRoot(MakeParts(block))`). | Must adhere to the validation rules of [PartSetHeader](#PartSetHeader) |
  129. See [MerkleRoot](./encoding.md#MerkleRoot) for details.
  130. ## PartSetHeader
  131. | Name | Type | Description | Validation |
  132. |-------|---------------------------|-----------------------------------|----------------------|
  133. | Total | int32 | Total amount of parts for a block | Must be > 0 |
  134. | Hash | slice of bytes (`[]byte`) | MerkleRoot of a serialized block | Must be of length 32 |
  135. ## Part
  136. Part defines a part of a block. In Tendermint blocks are broken into `parts` for gossip.
  137. | Name | Type | Description | Validation |
  138. |-------|-----------------|-----------------------------------|----------------------|
  139. | index | int32 | Total amount of parts for a block | Must be > 0 |
  140. | bytes | bytes | MerkleRoot of a serialized block | Must be of length 32 |
  141. | proof | [Proof](#proof) | MerkleRoot of a serialized block | Must be of length 32 |
  142. ## Time
  143. Tendermint uses the [Google.Protobuf.Timestamp](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp)
  144. format, which uses two integers, one 64 bit integer for Seconds and a 32 bit integer for Nanoseconds.
  145. ## Data
  146. Data is just a wrapper for a list of transactions, where transactions are arbitrary byte arrays:
  147. | Name | Type | Description | Validation |
  148. |------|----------------------------|------------------------|-----------------------------------------------------------------------------|
  149. | Txs | Matrix of bytes ([][]byte) | Slice of transactions. | Validation does not occur on this field, this data is unknown to Tendermint |
  150. ## Commit
  151. Commit is a simple wrapper for a list of signatures, with one for each validator. It also contains the relevant BlockID, height and round:
  152. | Name | Type | Description | Validation |
  153. |------------|----------------------------------|----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
  154. | Height | uint64 | Height at which this commit was created. | Must be > 0 |
  155. | Round | int32 | Round that the commit corresponds to. | Must be > 0 |
  156. | BlockID | [BlockID](#blockid) | The blockID of the corresponding block. | Must adhere to the validation rules of [BlockID](#blockid). |
  157. | Signatures | Array of [CommitSig](#commitsig) | Array of commit signatures that correspond to current validator set. | Length of signatures must be > 0 and adhere to the validation of each individual [Commitsig](#commitsig) |
  158. ## CommitSig
  159. `CommitSig` represents a signature of a validator, who has voted either for nil,
  160. a particular `BlockID` or was absent. It's a part of the `Commit` and can be used
  161. to reconstruct the vote set given the validator set.
  162. | Name | Type | Description | Validation |
  163. |------------------|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
  164. | BlockIDFlag | [BlockIDFlag](#blockidflag) | Represents the validators participation in consensus: Either voted for the block that received the majority, voted for another block, voted nil or did not vote | Must be one of the fields in the [BlockIDFlag](#blockidflag) enum |
  165. | ValidatorAddress | [Address](#address) | Address of the validator | Must be of length 20 |
  166. | Timestamp | [Time](#time) | This field will vary from `CommitSig` to `CommitSig`. It represents the timestamp of the validator. | [Time](#time) |
  167. | Signature | [Signature](#signature) | Signature corresponding to the validators participation in consensus. | The length of the signature must be > 0 and < than 64 |
  168. NOTE: `ValidatorAddress` and `Timestamp` fields may be removed in the future
  169. (see [ADR-25](https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-025-commit.md)).
  170. ## BlockIDFlag
  171. BlockIDFlag represents which BlockID the [signature](#commitsig) is for.
  172. ```go
  173. enum BlockIDFlag {
  174. BLOCK_ID_FLAG_UNKNOWN = 0;
  175. BLOCK_ID_FLAG_ABSENT = 1; // signatures for other blocks are also considered absent
  176. BLOCK_ID_FLAG_COMMIT = 2;
  177. BLOCK_ID_FLAG_NIL = 3;
  178. }
  179. ```
  180. ## Vote
  181. A vote is a signed message from a validator for a particular block.
  182. The vote includes information about the validator signing it. When stored in the blockchain or propagated over the network, votes are encoded in Protobuf.
  183. | Name | Type | Description | Validation |
  184. |------------------|---------------------------------|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
  185. | Type | [SignedMsgType](#signedmsgtype) | Either prevote or precommit. [SignedMsgType](#signedmsgtype) | A Vote is valid if its corresponding fields are included in the enum [signedMsgType](#signedmsgtype) |
  186. | Height | uint64 | Height for which this vote was created for | Must be > 0 |
  187. | Round | int32 | Round that the commit corresponds to. | Must be > 0 |
  188. | BlockID | [BlockID](#blockid) | The blockID of the corresponding block. | [BlockID](#blockid) |
  189. | Timestamp | [Time](#Time) | Timestamp represents the time at which a validator signed. | [Time](#time) |
  190. | ValidatorAddress | slice of bytes (`[]byte`) | Address of the validator | Length must be equal to 20 |
  191. | ValidatorIndex | int32 | Index at a specific block height that corresponds to the Index of the validator in the set. | must be > 0 |
  192. | Signature | slice of bytes (`[]byte`) | Signature by the validator if they participated in consensus for the associated bock. | Length of signature must be > 0 and < 64 |
  193. ## CanonicalVote
  194. CanonicalVote is for validator signing. This type will not be present in a block. Votes are represented via `CanonicalVote` and also encoded using protobuf via `type.SignBytes` which includes the `ChainID`, and uses a different ordering of
  195. the fields.
  196. ```proto
  197. message CanonicalVote {
  198. SignedMsgType type = 1;
  199. fixed64 height = 2;
  200. sfixed64 round = 3;
  201. CanonicalBlockID block_id = 4;
  202. google.protobuf.Timestamp timestamp = 5;
  203. string chain_id = 6;
  204. }
  205. ```
  206. For signing, votes are represented via [`CanonicalVote`](#canonicalvote) and also encoded using protobuf via
  207. `type.SignBytes` which includes the `ChainID`, and uses a different ordering of
  208. the fields.
  209. We define a method `Verify` that returns `true` if the signature verifies against the pubkey for the `SignBytes`
  210. using the given ChainID:
  211. ```go
  212. func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error {
  213. if !bytes.Equal(pubKey.Address(), vote.ValidatorAddress) {
  214. return ErrVoteInvalidValidatorAddress
  215. }
  216. if !pubKey.VerifyBytes(types.VoteSignBytes(chainID), vote.Signature) {
  217. return ErrVoteInvalidSignature
  218. }
  219. return nil
  220. }
  221. ```
  222. ## Proposal
  223. Proposal contains height and round for which this proposal is made, BlockID as a unique identifier
  224. of proposed block, timestamp, and POLRound (a so-called Proof-of-Lock (POL) round) that is needed for
  225. termination of the consensus. If POLRound >= 0, then BlockID corresponds to the block that
  226. is locked in POLRound. The message is signed by the validator private key.
  227. | Name | Type | Description | Validation |
  228. |-----------|---------------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------|
  229. | Type | [SignedMsgType](#signedmsgtype) | Represents a Proposal [SignedMsgType](#signedmsgtype) | Must be `ProposalType` [signedMsgType](#signedmsgtype) |
  230. | Height | uint64 | Height for which this vote was created for | Must be > 0 |
  231. | Round | int32 | Round that the commit corresponds to. | Must be > 0 |
  232. | POLRound | int64 | Proof of lock | Must be > 0 |
  233. | BlockID | [BlockID](#blockid) | The blockID of the corresponding block. | [BlockID](#blockid) |
  234. | Timestamp | [Time](#Time) | Timestamp represents the time at which a validator signed. | [Time](#time) |
  235. | Signature | slice of bytes (`[]byte`) | Signature by the validator if they participated in consensus for the associated bock. | Length of signature must be > 0 and < 64 |
  236. ## SignedMsgType
  237. Signed message type represents a signed messages in consensus.
  238. ```proto
  239. enum SignedMsgType {
  240. SIGNED_MSG_TYPE_UNKNOWN = 0;
  241. // Votes
  242. SIGNED_MSG_TYPE_PREVOTE = 1;
  243. SIGNED_MSG_TYPE_PRECOMMIT = 2;
  244. // Proposal
  245. SIGNED_MSG_TYPE_PROPOSAL = 32;
  246. }
  247. ```
  248. ## Signature
  249. Signatures in Tendermint are raw bytes representing the underlying signature.
  250. See the [signature spec](./encoding.md#key-types) for more.
  251. ## EvidenceList
  252. EvidenceList is a simple wrapper for a list of evidence:
  253. | Name | Type | Description | Validation |
  254. |----------|--------------------------------|----------------------------------------|-----------------------------------------------------------------|
  255. | Evidence | Array of [Evidence](#evidence) | List of verified [evidence](#evidence) | Validation adheres to individual types of [Evidence](#evidence) |
  256. ## Evidence
  257. Evidence in Tendermint is used to indicate breaches in the consensus by a validator.
  258. More information on how evidence works in Tendermint can be found [here](../consensus/evidence.md)
  259. ### DuplicateVoteEvidence
  260. `DuplicateVoteEvidence` represents a validator that has voted for two different blocks
  261. in the same round of the same height. Votes are lexicographically sorted on `BlockID`.
  262. | Name | Type | Description | Validation |
  263. |------------------|---------------|--------------------------------------------------------------------|-----------------------------------------------------|
  264. | VoteA | [Vote](#vote) | One of the votes submitted by a validator when they equivocated | VoteA must adhere to [Vote](#vote) validation rules |
  265. | VoteB | [Vote](#vote) | The second vote submitted by a validator when they equivocated | VoteB must adhere to [Vote](#vote) validation rules |
  266. | TotalVotingPower | int64 | The total power of the validator set at the height of equivocation | Must be equal to nodes own copy of the data |
  267. | ValidatorPower | int64 | Power of the equivocating validator at the height | Must be equal to the nodes own copy of the data |
  268. | Timestamp | [Time](#Time) | Time of the block where the equivocation occurred | Must be equal to the nodes own copy of the data |
  269. ### LightClientAttackEvidence
  270. `LightClientAttackEvidence` is a generalized evidence that captures all forms of known attacks on
  271. a light client such that a full node can verify, propose and commit the evidence on-chain for
  272. punishment of the malicious validators. There are three forms of attacks: Lunatic, Equivocation
  273. and Amnesia. These attacks are exhaustive. You can find a more detailed overview of this [here](../light-client/accountability#the_misbehavior_of_faulty_validators)
  274. | Name | Type | Description | Validation |
  275. |----------------------|------------------------------------|----------------------------------------------------------------------|------------------------------------------------------------------|
  276. | ConflictingBlock | [LightBlock](#LightBlock) | Read Below | Must adhere to the validation rules of [lightBlock](#lightblock) |
  277. | CommonHeight | int64 | Read Below | must be > 0 |
  278. | Byzantine Validators | Array of [Validators](#Validators) | validators that acted maliciously | Read Below |
  279. | TotalVotingPower | int64 | The total power of the validator set at the height of the infraction | Must be equal to the nodes own copy of the data |
  280. | Timestamp | [Time](#Time) | Time of the block where the infraction occurred | Must be equal to the nodes own copy of the data |
  281. ## LightBlock
  282. LightBlock is the core data structure of the [light client](../light-client/README.md). It combines two data structures needed for verification ([signedHeader](#signedheader) & [validatorSet](#validatorset)).
  283. | Name | Type | Description | Validation |
  284. |--------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
  285. | SignedHeader | [SignedHeader](#signedheader) | The header and commit, these are used for verification purposes. To find out more visit [light client docs](../light-client/README.md) | Must not be nil and adhere to the validation rules of [signedHeader](#signedheader) |
  286. | ValidatorSet | [ValidatorSet](#validatorset) | The validatorSet is used to help with verify that the validators in that committed the infraction were truly in the validator set. | Must not be nil and adhere to the validation rules of [validatorSet](#validatorset) |
  287. The `SignedHeader` and `ValidatorSet` are linked by the hash of the validator set(`SignedHeader.ValidatorsHash == ValidatorSet.Hash()`.
  288. ## SignedHeader
  289. The SignedhHeader is the [header](#header) accompanied by the commit to prove it.
  290. | Name | Type | Description | Validation |
  291. |--------|-------------------|-------------------|-----------------------------------------------------------------------------------|
  292. | Header | [Header](#Header) | [Header](#header) | Header cannot be nil and must adhere to the [Header](#Header) validation criteria |
  293. | Commit | [Commit](#commit) | [Commit](#commit) | Commit cannot be nil and must adhere to the [Commit](#commit) criteria |
  294. ## ValidatorSet
  295. | Name | Type | Description | Validation |
  296. |------------|----------------------------------|----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
  297. | Validators | Array of [validator](#validator) | List of the active validators at a specific height | The list of validators can not be empty or nil and must adhere to the validation rules of [validator](#validator) |
  298. | Proposer | [validator](#validator) | The block proposer for the corresponding block | The proposer cannot be nil and must adhere to the validation rules of [validator](#validator) |
  299. ## Validator
  300. | Name | Type | Description | Validation |
  301. |------------------|---------------------------|---------------------------------------------------------------------------------------------------|---------------------------------------------------|
  302. | Address | [Address](#address) | Validators Address | Length must be of size 20 |
  303. | Pubkey | slice of bytes (`[]byte`) | Validators Public Key | must be a length greater than 0 |
  304. | VotingPower | int64 | Validators voting power | cannot be < 0 |
  305. | ProposerPriority | int64 | Validators proposer priority. This is used to gauge when a validator is up next to propose blocks | No validation, value can be negative and positive |
  306. ## Address
  307. Address is a type alias of a slice of bytes. The address is calculated by hashing the public key using sha256 and truncating it to only use the first 20 bytes of the slice.
  308. ```go
  309. const (
  310. TruncatedSize = 20
  311. )
  312. func SumTruncated(bz []byte) []byte {
  313. hash := sha256.Sum256(bz)
  314. return hash[:TruncatedSize]
  315. }
  316. ```
  317. ## ConsensusParams
  318. | Name | Type | Description | Field Number |
  319. |-----------|-------------------------------------|------------------------------------------------------------------------------|--------------|
  320. | block | [BlockParams](#blockparams) | Parameters limiting the size of a block and time between consecutive blocks. | 1 |
  321. | evidence | [EvidenceParams](#evidenceparams) | Parameters limiting the validity of evidence of byzantine behaviour. | 2 |
  322. | validator | [ValidatorParams](#validatorparams) | Parameters limiting the types of public keys validators can use. | 3 |
  323. | version | [BlockParams](#blockparams) | The ABCI application version. | 4 |
  324. ### BlockParams
  325. | Name | Type | Description | Field Number |
  326. |--------------|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  327. | max_bytes | int64 | Max size of a block, in bytes. | 1 |
  328. | max_gas | int64 | Max sum of `GasWanted` in a proposed block. NOTE: blocks that violate this may be committed if there are Byzantine proposers. It's the application's responsibility to handle this when processing a block! | 2 |
  329. ### EvidenceParams
  330. | Name | Type | Description | Field Number |
  331. |--------------------|------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
  332. | max_age_num_blocks | int64 | Max age of evidence, in blocks. | 1 |
  333. | max_age_duration | [google.protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration) | Max age of evidence, in time. It should correspond with an app's "unbonding period" or other similar mechanism for handling [Nothing-At-Stake attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). | 2 |
  334. | max_bytes | int64 | maximum size in bytes of total evidence allowed to be entered into a block | 3 |
  335. ### ValidatorParams
  336. | Name | Type | Description | Field Number |
  337. |---------------|-----------------|-----------------------------------------------------------------------|--------------|
  338. | pub_key_types | repeated string | List of accepted public key types. Uses same naming as `PubKey.Type`. | 1 |
  339. ### VersionParams
  340. | Name | Type | Description | Field Number |
  341. |-------------|--------|-------------------------------|--------------|
  342. | app_version | uint64 | The ABCI application version. | 1 |
  343. ## Proof
  344. | Name | Type | Description | Field Number |
  345. |-----------|----------------|-----------------------------------------------|--------------|
  346. | total | int64 | Total number of items. | 1 |
  347. | index | int64 | Index item to prove. | 2 |
  348. | leaf_hash | bytes | Hash of item value. | 3 |
  349. | aunts | repeated bytes | Hashes from leaf's sibling to a root's child. | 4 |