syntax = "proto3";
package tendermint.types;

option go_package = "github.com/cometbft/cometbft/proto/tendermint/types";

import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";

option (gogoproto.equal_all) = true;

// ConsensusParams contains consensus critical parameters that determine the
// validity of blocks.
message ConsensusParams {
  BlockParams     block     = 1;
  EvidenceParams  evidence  = 2;
  ValidatorParams validator = 3;
  VersionParams   version   = 4;
  ABCIParams      abci      = 5;
}

// BlockParams contains limits on the block size.
message BlockParams {
  // Max block size, in bytes.
  // Note: must be greater than 0
  int64 max_bytes = 1;
  // Max gas per block.
  // Note: must be greater or equal to -1
  int64 max_gas = 2;

  reserved 3; // was TimeIotaMs see https://github.com/tendermint/tendermint/pull/5792
}

// EvidenceParams determine how we handle evidence of malfeasance.
message EvidenceParams {
  // Max age of evidence, in blocks.
  //
  // The basic formula for calculating this is: MaxAgeDuration / {average block
  // time}.
  int64 max_age_num_blocks = 1;

  // 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).
  google.protobuf.Duration max_age_duration = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];

  // This sets the maximum size of total evidence in bytes that can be committed in a single block.
  // and should fall comfortably under the max block bytes.
  // Default is 1048576 or 1MB
  int64 max_bytes = 3;
}

// ValidatorParams restrict the public key types validators can use.
// NOTE: uses ABCI pubkey naming, not Amino names.
message ValidatorParams {
  option (gogoproto.populate) = true;
  option (gogoproto.equal)    = true;

  repeated string pub_key_types = 1;
}

// VersionParams contains the ABCI application version.
message VersionParams {
  option (gogoproto.populate) = true;
  option (gogoproto.equal)    = true;

  uint64 app = 1;
}

// HashedParams is a subset of ConsensusParams.
//
// It is hashed into the Header.ConsensusHash.
message HashedParams {
  int64 block_max_bytes = 1;
  int64 block_max_gas   = 2;
}

// ABCIParams configure functionality specific to the Application Blockchain Interface.
message ABCIParams {
  // vote_extensions_enable_height configures the first height during which
  // vote extensions will be enabled. During this specified height, and for all
  // subsequent heights, precommit messages that do not contain valid extension data
  // will be considered invalid. Prior to this height, vote extensions will not
  // be used or accepted by validators on the network.
  //
  // Once enabled, vote extensions will be created by the application in ExtendVote,
  // passed to the application for validation in VerifyVoteExtension and given
  // to the application to use when proposing a block during PrepareProposal.
  int64 vote_extensions_enable_height = 1;
}
