github.com/aakash4dev/cometbft@v0.38.2/spec/core/data_structures.md (about)

     1  ---
     2  order: 1
     3  ---
     4  
     5  # Data Structures
     6  
     7  Here we describe the data structures in the CometBFT blockchain and the rules for validating them.
     8  
     9  The CometBFT blockchain consists of a short list of data types:
    10  
    11  - [Data Structures](#data-structures)
    12      - [Block](#block)
    13      - [Execution](#execution)
    14      - [Header](#header)
    15      - [Version](#version)
    16      - [BlockID](#blockid)
    17      - [PartSetHeader](#partsetheader)
    18      - [Part](#part)
    19      - [Time](#time)
    20      - [Data](#data)
    21      - [Commit](#commit)
    22      - [CommitSig](#commitsig)
    23      - [BlockIDFlag](#blockidflag)
    24      - [Vote](#vote)
    25      - [CanonicalVote](#canonicalvote)
    26      - [Proposal](#proposal)
    27      - [SignedMsgType](#signedmsgtype)
    28      - [Signature](#signature)
    29      - [EvidenceList](#evidencelist)
    30      - [Evidence](#evidence)
    31          - [DuplicateVoteEvidence](#duplicatevoteevidence)
    32          - [LightClientAttackEvidence](#lightclientattackevidence)
    33      - [LightBlock](#lightblock)
    34      - [SignedHeader](#signedheader)
    35      - [ValidatorSet](#validatorset)
    36      - [Validator](#validator)
    37      - [Address](#address)
    38      - [ConsensusParams](#consensusparams)
    39          - [BlockParams](#blockparams)
    40          - [EvidenceParams](#evidenceparams)
    41          - [ValidatorParams](#validatorparams)
    42          - [VersionParams](#versionparams)
    43      - [Proof](#proof)
    44  
    45  
    46  ## Block
    47  
    48  A block consists of a header, transactions, votes (the commit),
    49  and a list of evidence of malfeasance (ie. signing conflicting votes).
    50  
    51  | Name   | Type              | Description                                                                                                                                                                          | Validation                                               |
    52  |--------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
    53  | 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) |
    54  | Data       | [Data](#data)                  | Data contains a list of transactions. The contents of the transaction is unknown to CometBFT.                                                                                      | 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](https://github.com/aakash4dev/cometbft/blob/main/spec/abci/abci%2B%2B_methods.md#checktx).
    55  | Evidence   | [EvidenceList](#evidencelist) | Evidence contains a list of infractions committed by validators.                                                                                                                     | Can be empty, but when populated the validations rules from [evidenceList](#evidencelist) apply |
    56  | 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).  |
    57  
    58  ## Execution
    59  
    60  Once a block is validated, it can be executed against the state.
    61  
    62  The state follows this recursive equation:
    63  
    64  ```go
    65  state(initialHeight) = InitialState
    66  state(h+1) <- Execute(state(h), ABCIApp, block(h))
    67  ```
    68  
    69  where `InitialState` includes the initial consensus parameters and validator set,
    70  and `ABCIApp` is an ABCI application that can return results and changes to the validator
    71  set (TODO). Execute is defined as:
    72  
    73  ```go
    74  func Execute(state State, app ABCIApp, block Block) State {
    75   // Fuction ApplyBlock executes block of transactions against the app and returns the new root hash of the app state,
    76   // modifications to the validator set and the changes of the consensus parameters.
    77   AppHash, ValidatorChanges, ConsensusParamChanges := app.ApplyBlock(block)
    78  
    79   nextConsensusParams := UpdateConsensusParams(state.ConsensusParams, ConsensusParamChanges)
    80   return State{
    81    ChainID:         state.ChainID,
    82    InitialHeight:   state.InitialHeight,
    83    LastResults:     abciResponses.DeliverTxResults,
    84    AppHash:         AppHash,
    85    LastValidators:  state.Validators,
    86    Validators:      state.NextValidators,
    87    NextValidators:  UpdateValidators(state.NextValidators, ValidatorChanges),
    88    ConsensusParams: nextConsensusParams,
    89    Version: {
    90     Consensus: {
    91      AppVersion: nextConsensusParams.Version.AppVersion,
    92     },
    93    },
    94   }
    95  }
    96  ```
    97  
    98  Validating a new block is first done prior to the `prevote`, `precommit` & `finalizeCommit` stages.
    99  
   100  The steps to validate a new block are:
   101  
   102  - Check the validity rules of the block and its fields.
   103  - Check the versions (Block & App) are the same as in local state.
   104  - Check the chainID's match.
   105  - Check the height is correct.
   106  - Check the `LastBlockID` corresponds to BlockID currently in state.
   107  - Check the hashes in the header match those in state.
   108  - Verify the LastCommit against state, this step is skipped for the initial height.
   109      - This is where checking the signatures correspond to the correct block will be made.
   110  - Make sure the proposer is part of the validator set.
   111  - Validate bock time.
   112      - Make sure the new blocks time is after the previous blocks time.
   113      - Calculate the medianTime and check it against the blocks time.
   114      - If the blocks height is the initial height then check if it matches the genesis time.
   115  - Validate the evidence in the block. Note: Evidence can be empty
   116  
   117  ## Header
   118  
   119  A block header contains metadata about the block and about the consensus, as well as commitments to
   120  the data in the current block, the previous block, and the results returned by the application:
   121  
   122  | Name              | Type                      | Description                                                                                                                                                                                                                                                                                                                                                                           | Validation                                                                                                                                                                                       |
   123  |-------------------|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
   124  | Version           | [Version](#version)       | Version defines the application and protocol version being used.                                                                                                                                                                                                                                                                                                                       | Must adhere to the validation rules of [Version](#version)                                                                                                                                       |
   125  | ChainID           | String                    | ChainID is the ID of the chain. This must be unique to your chain.                                                                                                                                                                                                                                                                                                                    | ChainID must be less than 50 bytes.                                                                                                                                                              |
   126  | Height            | uint64                     | Height is the height for this header.                                                                                                                                                                                                                                                                                                                                                 | Must be > 0, >= initialHeight, and == previous Height+1                                                                                                                                          |
   127  | 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). |
   128  | 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{}`.                                                                         |
   129  | 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                                                                                                                                                                            |
   130  | 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                                                                                                                                                                            |
   131  | 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                                                                                                                                                                            |
   132  | 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                                                                                                                                                                            |
   133  | ConsensusHash     | slice of bytes (`[]byte`) | Hash of the protobuf encoded consensus parameters.                                                                                                                                                                                                                                                                                                                                    | Must  be of length 32                                                                                                                                                                            |
   134  | 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, CometBFT can not perform validation on it.                                                                                                         |
   135  | 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.                                             |
   136  | EvidenceHash      | slice of bytes (`[]byte`) | MerkleRoot of the evidence of Byzantine behavior included in this block.                                                                                                                                                                                                                                                                                                             | Must  be of length 32                                                                                                                                                                            |
   137  | 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                                                                                                                                                                            |
   138  
   139  ## Version
   140  
   141  NOTE: that this is more specifically the consensus version and doesn't include information like the
   142  P2P Version. (TODO: we should write a comprehensive document about
   143  versioning that this can refer to)
   144  
   145  | Name  | type   | Description                                                                                                     | Validation                                                                                                         |
   146  |-------|--------|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
   147  | 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`) |
   148  | App   | uint64 | App version is decided on by the application. Read [here](https://github.com/aakash4dev/cometbft/blob/main/spec/abci/abci++_app_requirements.md)                                 | `block.Version.App == state.Version.Consensus.App`                                                                 |
   149  
   150  ## BlockID
   151  
   152  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))`)
   153  
   154  | Name          | Type                            | Description                                                                                                                                                      | Validation                                                             |
   155  |---------------|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
   156  | Hash          | slice of bytes (`[]byte`)       | MerkleRoot of all the fields in the header (ie. `MerkleRoot(header)`.                                                                                            | hash must be of length 32                                              |
   157  | 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) |
   158  
   159  See [MerkleRoot](./encoding.md#MerkleRoot) for details.
   160  
   161  ## PartSetHeader
   162  
   163  | Name  | Type                      | Description                       | Validation           |
   164  |-------|---------------------------|-----------------------------------|----------------------|
   165  | Total | int32                     | Total amount of parts for a block | Must be > 0          |
   166  | Hash  | slice of bytes (`[]byte`) | MerkleRoot of a serialized block  | Must be of length 32 |
   167  
   168  ## Part
   169  
   170  Part defines a part of a block. In CometBFT blocks are broken into `parts` for gossip.
   171  
   172  | Name  | Type            | Description                       | Validation           |
   173  |-------|-----------------|-----------------------------------|----------------------|
   174  | index | int32           | Total amount of parts for a block | Must be > 0          |
   175  | bytes | bytes           | MerkleRoot of a serialized block  | Must be of length 32 |
   176  | proof | [Proof](#proof) | MerkleRoot of a serialized block  | Must be of length 32 |
   177  
   178  ## Time
   179  
   180  CometBFT uses the [Google.Protobuf.Timestamp](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp)
   181  format, which uses two integers, one 64 bit integer for Seconds and a 32 bit integer for Nanoseconds.
   182  
   183  ## Data
   184  
   185  Data is just a wrapper for a list of transactions, where transactions are arbitrary byte arrays:
   186  
   187  | Name | Type                       | Description            | Validation                                                                  |
   188  |------|----------------------------|------------------------|-----------------------------------------------------------------------------|
   189  | Txs  | Matrix of bytes ([][]byte) | Slice of transactions. | Validation does not occur on this field, this data is unknown to CometBFT |
   190  
   191  ## Commit
   192  
   193  Commit is a simple wrapper for a list of signatures, with one for each validator. It also contains the relevant BlockID, height and round:
   194  
   195  | Name       | Type                             | Description                                                          | Validation                                                                                               |
   196  |------------|----------------------------------|----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
   197  | Height     | int64                            | Height at which this commit was created.                             | Must be > 0                                                                                              |
   198  | Round      | int32                            | Round that the commit corresponds to.                                | Must be > 0                                                                                              |
   199  | BlockID    | [BlockID](#blockid)              | The blockID of the corresponding block.                              | Must adhere to the validation rules of [BlockID](#blockid).                                              |
   200  | 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) |
   201  
   202  ## ExtendedCommit
   203  
   204  `ExtendedCommit`, similarly to Commit, wraps a list of votes with signatures together with other data needed to verify them.
   205  In addition, it contains the verified vote extensions, one for each non-`nil` vote, along with the extension signatures.
   206  
   207  | Name               | Type                                     | Description                                                                         | Validation                                                                                                               |
   208  |--------------------|------------------------------------------|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
   209  | Height             | int64                                    | Height at which this commit was created.                                            | Must be > 0                                                                                                              |
   210  | Round              | int32                                    | Round that the commit corresponds to.                                               | Must be > 0                                                                                                              |
   211  | BlockID            | [BlockID](#blockid)                      | The blockID of the corresponding block.                                             | Must adhere to the validation rules of [BlockID](#blockid).                                                              |
   212  | ExtendedSignatures | Array of [ExtendedCommitSig](#commitsig) | The current validator set's commit signatures, extension, and extension signatures. | Length of signatures must be > 0 and adhere to the validation of each individual [ExtendedCommitSig](#extendedcommitsig) |
   213  
   214  ## CommitSig
   215  
   216  `CommitSig` represents a signature of a validator, who has voted either for nil,
   217  a particular `BlockID` or was absent. It's a part of the `Commit` and can be used
   218  to reconstruct the vote set given the validator set.
   219  
   220  | Name             | Type                        | Description                                                                                                                                       | Validation                                                        |
   221  |------------------|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
   222  | BlockIDFlag      | [BlockIDFlag](#blockidflag) | Represents the validators participation in consensus: its vote was not received, voted for the block that received the majority, or voted for nil | Must be one of the fields in the [BlockIDFlag](#blockidflag) enum |
   223  | ValidatorAddress | [Address](#address)         | Address of the validator                                                                                                                          | Must be of length 20                                              |
   224  | Timestamp        | [Time](#time)               | This field will vary from `CommitSig` to `CommitSig`. It represents the timestamp of the validator.                                               | [Time](#time)                                                     |
   225  | Signature        | [Signature](#signature)     | Signature corresponding to the validators participation in consensus.                                                                             | The length of the signature must be > 0 and < than  64            |
   226  
   227  NOTE: `ValidatorAddress` and `Timestamp` fields may be removed in the future
   228  (see [ADR-25](https://github.com/aakash4dev/cometbft/blob/main/docs/architecture/adr-025-commit.md)).
   229  
   230  ## ExtendedCommitSig
   231  
   232  `ExtendedCommitSig` represents a signature of a validator that has voted either for `nil`,
   233  a particular `BlockID` or was absent. It is part of the `ExtendedCommit` and can be used
   234  to reconstruct the vote set given the validator set.
   235  Additionally it contains the vote extensions that were attached to each non-`nil` precommit vote.
   236  All these extensions have been verified by the application operating at the signing validator's node.
   237  
   238  | Name               | Type                        | Description                                                                                                                                       | Validation                                                          |
   239  |--------------------|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
   240  | BlockIDFlag        | [BlockIDFlag](#blockidflag) | Represents the validators participation in consensus: its vote was not received, voted for the block that received the majority, or voted for nil | Must be one of the fields in the [BlockIDFlag](#blockidflag) enum   |
   241  | ValidatorAddress   | [Address](#address)         | Address of the validator                                                                                                                          | Must be of length 20                                                |
   242  | Timestamp          | [Time](#time)               | This field will vary from `CommitSig` to `CommitSig`. It represents the timestamp of the validator.                                               |                                                                     |
   243  | Signature          | [Signature](#signature)     | Signature corresponding to the validators participation in consensus.                                                                             | Length must be > 0 and < 64                                         |
   244  | Extension          | bytes                       | Vote extension provided by the Application running on the sender of the precommit vote, and verified by the local application.                    | Length must be zero if BlockIDFlag is not `Commit`                  |
   245  | ExtensionSignature | [Signature](#signature)     | Signature of the vote extension.                                                                                                                  | Length must be > 0 and < than 64 if BlockIDFlag is `Commit`, else 0 |
   246  
   247  ## BlockIDFlag
   248  
   249  BlockIDFlag represents which BlockID the [signature](#commitsig) is for.
   250  
   251  ```go
   252  enum BlockIDFlag {
   253    BLOCK_ID_FLAG_UNKNOWN = 0; // indicates an error condition
   254    BLOCK_ID_FLAG_ABSENT  = 1; // the vote was not received
   255    BLOCK_ID_FLAG_COMMIT  = 2; // voted for the block that received the majority
   256    BLOCK_ID_FLAG_NIL     = 3; // voted for nil
   257  }
   258  ```
   259  
   260  ## Vote
   261  
   262  A vote is a signed message from a validator for a particular block.
   263  The vote includes information about the validator signing it. When stored in the blockchain or propagated over the network, votes are encoded in Protobuf.
   264  
   265  | Name               | Type                            | Description                                                                              | Validation                               |
   266  |--------------------|---------------------------------|------------------------------------------------------------------------------------------|------------------------------------------|
   267  | Type               | [SignedMsgType](#signedmsgtype) | The type of message the vote refers to                                                   | Must be `PrevoteType` or `PrecommitType` |
   268  | Height             | int64                           | Height for which this vote was created for                                               | Must be > 0                              |
   269  | Round              | int32                           | Round that the commit corresponds to.                                                    | Must be > 0                              |
   270  | BlockID            | [BlockID](#blockid)             | The blockID of the corresponding block.                                                  |                                          |
   271  | Timestamp          | [Time](#time)                   | Timestamp represents the time at which a validator signed.                               |                                          |
   272  | ValidatorAddress   | bytes                           | Address of the validator                                                                 | Length must be equal to 20               |
   273  | ValidatorIndex     | int32                           | Index at a specific block height corresponding to the Index of the validator in the set. | Must be > 0                              |
   274  | Signature          | bytes                           | Signature by the validator if they participated in consensus for the associated block.   | Length must be > 0 and < 64              |
   275  | Extension          | bytes                           | Vote extension provided by the Application running at the validator's node.              | Length can be 0                          |
   276  | ExtensionSignature | bytes                           | Signature for the extension                                                              | Length must be > 0 and < 64              |
   277  
   278  ## CanonicalVote
   279  
   280  CanonicalVote is for validator signing. This type will not be present in a block.
   281  Votes are represented via `CanonicalVote` and also encoded using protobuf via `type.SignBytes` which includes the `ChainID`,
   282  and uses a different ordering of the fields.
   283  
   284  | Name      | Type                            | Description                             | Validation                               |
   285  |-----------|---------------------------------|-----------------------------------------|------------------------------------------|
   286  | Type      | [SignedMsgType](#signedmsgtype) | The type of message the vote refers to  | Must be `PrevoteType` or `PrecommitType` |
   287  | Height    | int64                           | Height in which the vote was provided.  | Must be > 0                              |
   288  | Round     | int64                           | Round in which the vote was provided.   | Must be > 0                              |
   289  | BlockID   | string                          | ID of the block the vote refers to.     |                                          |
   290  | Timestamp | string                          | Time of the vote.                       |                                          |
   291  | ChainID   | string                          | ID of the blockchain running consensus. |                                          |
   292  
   293  For signing, votes are represented via [`CanonicalVote`](#canonicalvote) and also encoded using protobuf via
   294  `type.SignBytes` which includes the `ChainID`, and uses a different ordering of
   295  the fields.
   296  
   297  We define a method `Verify` that returns `true` if the signature verifies against the pubkey for the `SignBytes`
   298  using the given ChainID:
   299  
   300  ```go
   301  func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error {
   302   if !bytes.Equal(pubKey.Address(), vote.ValidatorAddress) {
   303    return ErrVoteInvalidValidatorAddress
   304   }
   305   v := vote.ToProto()
   306   if !pubKey.VerifyBytes(types.VoteSignBytes(chainID, v), vote.Signature) {
   307    return ErrVoteInvalidSignature
   308   }
   309   return nil
   310  }
   311  ```
   312  
   313  ### CanonicalVoteExtension
   314  
   315  Vote extensions are signed using a representation similar to votes.
   316  This is the structure to marshall in order to obtain the bytes to sign or verify the signature.
   317  
   318  | Name      | Type   | Description                                 | Validation           |
   319  |-----------|--------|---------------------------------------------|----------------------|
   320  | Extension | bytes  | Vote extension provided by the Application. | Can have zero length |
   321  | Height    | int64  | Height in which the extension was provided. | Must be > 0          |
   322  | Round     | int64  | Round in which the extension was provided.  | Must be > 0          |
   323  | ChainID   | string | ID of the blockchain running consensus.     |                      |
   324  
   325  ## Proposal
   326  
   327  Proposal contains height and round for which this proposal is made, BlockID as a unique identifier
   328  of proposed block, timestamp, and POLRound (a so-called Proof-of-Lock (POL) round) that is needed for
   329  termination of the consensus. If POLRound >= 0, then BlockID corresponds to the block that
   330  is locked in POLRound. The message is signed by the validator private key.
   331  
   332  | Name      | Type                            | Description                                                                           | Validation                                              |
   333  |-----------|---------------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------|
   334  | Type      | [SignedMsgType](#signedmsgtype) | Represents a Proposal [SignedMsgType](#signedmsgtype)                                 | Must be `ProposalType`  [signedMsgType](#signedmsgtype) |
   335  | Height    | uint64                           | Height for which this vote was created for                                            | Must be > 0                                             |
   336  | Round     | int32                           | Round that the commit corresponds to.                                                 | Must be > 0                                             |
   337  | POLRound  | int64                           | Proof of lock                                                                         | Must be > 0                                             |
   338  | BlockID   | [BlockID](#blockid)             | The blockID of the corresponding block.                                               | [BlockID](#blockid)                                     |
   339  | Timestamp | [Time](#time)                   | Timestamp represents the time at which a validator signed.                            | [Time](#time)                                           |
   340  | 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                |
   341  
   342  ## SignedMsgType
   343  
   344  Signed message type represents a signed messages in consensus.
   345  
   346  ```proto
   347  enum SignedMsgType {
   348  
   349    SIGNED_MSG_TYPE_UNKNOWN = 0;
   350    // Votes
   351    SIGNED_MSG_TYPE_PREVOTE   = 1;
   352    SIGNED_MSG_TYPE_PRECOMMIT = 2;
   353  
   354    // Proposal
   355    SIGNED_MSG_TYPE_PROPOSAL = 32;
   356  }
   357  ```
   358  
   359  ## Signature
   360  
   361  Signatures in CometBFT are raw bytes representing the underlying signature.
   362  
   363  See the [signature spec](./encoding.md#key-types) for more.
   364  
   365  ## EvidenceList
   366  
   367  EvidenceList is a simple wrapper for a list of evidence:
   368  
   369  | Name     | Type                           | Description                            | Validation                                                      |
   370  |----------|--------------------------------|----------------------------------------|-----------------------------------------------------------------|
   371  | Evidence | Array of [Evidence](#evidence) | List of verified [evidence](#evidence) | Validation adheres to individual types of [Evidence](#evidence) |
   372  
   373  ## Evidence
   374  
   375  Evidence in CometBFT is used to indicate breaches in the consensus by a validator.
   376  
   377  More information on how evidence works in CometBFT can be found [here](../consensus/evidence.md)
   378  
   379  ### DuplicateVoteEvidence
   380  
   381  `DuplicateVoteEvidence` represents a validator that has voted for two different blocks
   382  in the same round of the same height. Votes are lexicographically sorted on `BlockID`.
   383  
   384  | Name             | Type          | Description                                                        | Validation                                          |
   385  |------------------|---------------|--------------------------------------------------------------------|-----------------------------------------------------|
   386  | VoteA            | [Vote](#vote) | One of the votes submitted by a validator when they equivocated    | VoteA must adhere to [Vote](#vote) validation rules |
   387  | VoteB            | [Vote](#vote) | The second vote submitted by a validator when they equivocated     | VoteB must adhere to [Vote](#vote) validation rules |
   388  | TotalVotingPower | int64         | The total power of the validator set at the height of equivocation | Must be equal to nodes own copy of the data         |
   389  | ValidatorPower   | int64         | Power of the equivocating validator at the height                  | Must be equal to the nodes own copy of the data     |
   390  | Timestamp        | [Time](#time) | Time of the block where the equivocation occurred                  | Must be equal to the nodes own copy of the data     |
   391  
   392  ### LightClientAttackEvidence
   393  
   394  `LightClientAttackEvidence` is a generalized evidence that captures all forms of known attacks on
   395  a light client such that a full node can verify, propose and commit the evidence on-chain for
   396  punishment of the malicious validators. There are three forms of attacks: Lunatic, Equivocation
   397  and Amnesia. These attacks are exhaustive. You can find a more detailed overview of this [here](../light-client/accountability#the_misbehavior_of_faulty_validators)
   398  
   399  | Name                 | Type                               | Description                                                          | Validation                                                       |
   400  |----------------------|------------------------------------|----------------------------------------------------------------------|------------------------------------------------------------------|
   401  | ConflictingBlock     | [LightBlock](#lightblock)          | Read Below                                                           | Must adhere to the validation rules of [lightBlock](#lightblock) |
   402  | CommonHeight         | int64                              | Read Below                                                           | must be > 0                                                      |
   403  | Byzantine Validators | Array of [Validators](#validator) | validators that acted maliciously                                    | Read Below                                                       |
   404  | 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                  |
   405  | Timestamp            | [Time](#time)                      | Time of the block where the infraction occurred                      | Must be equal to the nodes own copy of the data                  |
   406  
   407  ## LightBlock
   408  
   409  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)).
   410  
   411  | Name         | Type                          | Description                                                                                                                            | Validation                                                                          |
   412  |--------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
   413  | 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) |
   414  | 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) |
   415  
   416  The `SignedHeader` and `ValidatorSet` are linked by the hash of the validator set(`SignedHeader.ValidatorsHash == ValidatorSet.Hash()`.
   417  
   418  ## SignedHeader
   419  
   420  The SignedhHeader is the [header](#header) accompanied by the commit to prove it.
   421  
   422  | Name   | Type              | Description       | Validation                                                                        |
   423  |--------|-------------------|-------------------|-----------------------------------------------------------------------------------|
   424  | Header | [Header](#header) | [Header](#header) | Header cannot be nil and must adhere to the [Header](#header) validation criteria |
   425  | Commit | [Commit](#commit) | [Commit](#commit) | Commit cannot be nil and must adhere to the [Commit](#commit) criteria            |
   426  
   427  ## ValidatorSet
   428  
   429  | Name       | Type                             | Description                                        | Validation                                                                                                        |
   430  |------------|----------------------------------|----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
   431  | 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) |
   432  | 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)                    |
   433  
   434  ## Validator
   435  
   436  | Name             | Type                      | Description                                                                                       | Validation                                        |
   437  |------------------|---------------------------|---------------------------------------------------------------------------------------------------|---------------------------------------------------|
   438  | Address          | [Address](#address)       | Validators Address                                                                                | Length must be of size 20                         |
   439  | Pubkey           | slice of bytes (`[]byte`) | Validators Public Key                                                                             | must be a length greater than 0                   |
   440  | VotingPower      | int64                     | Validators voting power                                                                           | cannot be < 0                                     |
   441  | 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 |
   442  
   443  ## Address
   444  
   445  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.
   446  
   447  ```go
   448  const (
   449    TruncatedSize = 20
   450  )
   451  
   452  func SumTruncated(bz []byte) []byte {
   453    hash := sha256.Sum256(bz)
   454    return hash[:TruncatedSize]
   455  }
   456  ```
   457  
   458  ## ConsensusParams
   459  
   460  | Name      | Type                                | Description                                                                  | Field Number |
   461  |-----------|-------------------------------------|------------------------------------------------------------------------------|--------------|
   462  | block     | [BlockParams](#blockparams)         | Parameters limiting the size of a block and time between consecutive blocks. | 1            |
   463  | evidence  | [EvidenceParams](#evidenceparams)   | Parameters limiting the validity of evidence of byzantine behavior.         | 2            |
   464  | validator | [ValidatorParams](#validatorparams) | Parameters limiting the types of public keys validators can use.             | 3            |
   465  | version   | [BlockParams](#blockparams)         | The ABCI application version.                                                | 4            |
   466  
   467  ### BlockParams
   468  
   469  | Name         | Type  | Description                                                                                                                                                                                                 | Field Number |
   470  |--------------|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
   471  | max_bytes    | int64 | Max size of a block, in bytes.                                                                                                                                                                              | 1            |
   472  | 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            |
   473  
   474  ### EvidenceParams
   475  
   476  | Name               | Type                                                                                                                               | Description                                                                                                                                                                                                                                                                    | Field Number |
   477  |--------------------|------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
   478  | max_age_num_blocks | int64                                                                                                                              | Max age of evidence, in blocks.                                                                                                                                                                                                                                                | 1            |
   479  | 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            |
   480  | max_bytes          | int64                                                                                                                              | maximum size in bytes of total evidence allowed to be entered into a block                                                                                                                                                                                                     | 3            |
   481  
   482  ### ValidatorParams
   483  
   484  | Name          | Type            | Description                                                           | Field Number |
   485  |---------------|-----------------|-----------------------------------------------------------------------|--------------|
   486  | pub_key_types | repeated string | List of accepted public key types. Uses same naming as `PubKey.Type`. | 1            |
   487  
   488  ### VersionParams
   489  
   490  | Name        | Type   | Description                   | Field Number |
   491  |-------------|--------|-------------------------------|--------------|
   492  | app_version | uint64 | The ABCI application version. | 1            |
   493  
   494  ## Proof
   495  
   496  | Name      | Type           | Description                                   | Field Number |
   497  |-----------|----------------|-----------------------------------------------|--------------|
   498  | total     | int64          | Total number of items.                        | 1            |
   499  | index     | int64          | Index item to prove.                          | 2            |
   500  | leaf_hash | bytes          | Hash of item value.                           | 3            |
   501  | aunts     | repeated bytes | Hashes from leaf's sibling to a root's child. | 4            |