syntax = "proto3";
package cometbft.types.v2;

option go_package = "github.com/cometbft/cometbft/api/cometbft/types/v2";

import "gogoproto/gogo.proto";
import "cometbft/types/v2/types.proto";
import "google/protobuf/timestamp.proto";

// CanonicalBlockID is a canonical representation of a BlockID, which gets
// serialized and signed.
message CanonicalBlockID {
  bytes                  hash            = 1;
  CanonicalPartSetHeader part_set_header = 2 [(gogoproto.nullable) = false];
}

// CanonicalPartSetHeader is a canonical representation of a PartSetHeader,
// which gets serialized and signed.
message CanonicalPartSetHeader {
  uint32 total = 1;
  bytes  hash  = 2;
}

// CanonicalProposal is a canonical representation of a Proposal, which gets
// serialized and signed.
message CanonicalProposal {
  SignedMsgType             type      = 1; // type alias for byte
  sfixed64                  height    = 2; // canonicalization requires fixed size encoding here
  sfixed64                  round     = 3; // canonicalization requires fixed size encoding here
  int64                     pol_round = 4 [(gogoproto.customname) = "POLRound"];
  CanonicalBlockID          block_id  = 5 [(gogoproto.customname) = "BlockID"];
  google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  string                    chain_id  = 7 [(gogoproto.customname) = "ChainID"];
}

// CanonicalVote is a canonical representation of a Vote, which gets
// serialized and signed.
message CanonicalVote {
  SignedMsgType             type      = 1; // type alias for byte
  sfixed64                  height    = 2; // canonicalization requires fixed size encoding here
  sfixed64                  round     = 3; // canonicalization requires fixed size encoding here
  CanonicalBlockID          block_id  = 4 [(gogoproto.customname) = "BlockID"];
  google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
  string                    chain_id  = 6 [(gogoproto.customname) = "ChainID"];
}

// CanonicalVoteExtension provides us a way to serialize a vote extension from
// a particular validator such that we can sign over those serialized bytes.
message CanonicalVoteExtension {
  bytes    extension = 1;
  sfixed64 height    = 2;
  sfixed64 round     = 3;
  string   chain_id  = 4;
}
