syntax = "proto3";

package interchain_security.ccv.provider.v1;

option go_package = "github.com/cosmos/interchain-security/v7/x/ccv/provider/types";

import "gogoproto/gogo.proto";
import "interchain_security/ccv/v1/shared_consumer.proto";
import "interchain_security/ccv/v1/wire.proto";
import "interchain_security/ccv/provider/v1/provider.proto";

// GenesisState defines the CCV provider chain genesis state
message GenesisState {
    // Reserve 3rd slot for removed unbonding_ops field
    reserved 3;

    // Reserve 4th slot for removed mature_unbonding_ops field
    reserved 4;

    // Reserve 6th slot for removed consumer_addition_proposals field
    reserved 6;

    // Reserve 7th slot for removed consumer_removal_proposals field
    reserved 7;

    // Reserve 11th slot for consumer_addrs_to_prune field
    reserved 11;

    // Reserve 12th slot for removed init_timeout_timestamps field
    reserved 12;

    // Reserve 13th slot for removed exported_vsc_send_timestamps field
    reserved 13;

  // strictly positive and set to 1 (DefaultValsetUpdateID) for a new chain
  uint64 valset_update_id = 1;
  // empty for a new chain
  repeated ConsumerState consumer_states = 2 [
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"consumer_states\""
  ];
  // empty for a new chain
  repeated ValsetUpdateIdToHeight valset_update_id_to_height = 5
      [ (gogoproto.nullable) = false ];
  Params params = 8 [ (gogoproto.nullable) = false ];
  // empty for a new chain
  repeated ValidatorConsumerPubKey validator_consumer_pubkeys = 9
      [ (gogoproto.nullable) = false ];
  // empty for a new chain
  repeated ValidatorByConsumerAddr validators_by_consumer_addr = 10
      [ (gogoproto.nullable) = false ];

  // empty for a new chain
  repeated ConsumerAddrsToPruneV2 consumer_addrs_to_prune_v2 = 14
      [ (gogoproto.nullable) = false ];
}

// The provider CCV module's knowledge of consumer state. 
//
// Note this type is only used internally to the provider CCV module.
message ConsumerState {
    // Reserve 8th slot for removed unbonding_ops_index field
    reserved 8;

  // ChainID defines the chain ID for the consumer chain
  string chain_id = 1;
  // ChannelID defines the IBC channel ID for the consumer chain
  string channel_id = 2;
  // ClientID defines the IBC client ID for the consumer chain
  string client_id = 3;
  // InitalHeight defines the initial block height for the consumer chain
  uint64 initial_height = 4;
  // ConsumerGenesis defines the initial consumer chain genesis states
  interchain_security.ccv.v1.ConsumerGenesisState consumer_genesis = 5
      [ (gogoproto.nullable) = false ];
  // PendingValsetChanges defines the pending validator set changes for the
  // consumer chain
  repeated interchain_security.ccv.v1.ValidatorSetChangePacketData
      pending_valset_changes = 6 [ (gogoproto.nullable) = false ];
  repeated string slash_downtime_ack = 7;
  // the phase of the consumer chain
  ConsumerPhase phase = 9;
}

// ValsetUpdateIdToHeight defines the genesis information for the mapping
// of each valset update id to a block height
message ValsetUpdateIdToHeight {
  uint64 valset_update_id = 1;
  uint64 height = 2;
}
