syntax = "proto3";

package interchain_security.ccv.v1;

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

import "cosmos/staking/v1beta1/staking.proto";

import "gogoproto/gogo.proto";
import "tendermint/abci/types.proto";

// This packet is sent from provider chain to consumer chain if the validator
// set for consumer chain changes (due to new bonding/unbonding messages or
// slashing events) A VSCMatured packet from consumer chain will be sent
// asynchronously once unbonding period is over, and this will function as
// `UnbondingOver` message for this packet.
message ValidatorSetChangePacketData {
  repeated .tendermint.abci.ValidatorUpdate validator_updates = 1 [
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"validator_updates\""
  ];
  uint64 valset_update_id = 2;
  // consensus address of consumer chain validators
  // successfully slashed on the provider chain
  repeated string slash_acks = 3;
}

// List of ccv.ValidatorSetChangePacketData.
message ValidatorSetChangePackets {
  repeated ValidatorSetChangePacketData list = 1 [
    (gogoproto.nullable) = false
  ];
}

// This packet is sent from the consumer chain to the provider chain
// to notify that a VSC packet reached maturity on the consumer chain.
message VSCMaturedPacketData {
  // the id of the VSC packet that reached maturity
  uint64 valset_update_id = 1;
}

// This packet is sent from the consumer chain to the provider chain
// to request the slashing of a validator as a result of an infraction
// committed on the consumer chain.
message SlashPacketData {
  tendermint.abci.Validator validator = 1 [
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"validator\""
  ];
  // map to the infraction block height on the provider
  uint64 valset_update_id = 2;
  // tell if the slashing is for a downtime or a double-signing infraction
  cosmos.staking.v1beta1.InfractionType infraction = 3;
}

// MaturedUnbondingOps defines a list of ids corresponding to ids of matured unbonding operations. 
message MaturedUnbondingOps {
  repeated uint64 ids = 1;
}

// ConsumerPacketData contains a consumer packet data and a type tag
message ConsumerPacketData {
  ConsumerPacketDataType type = 1; 

  oneof data {
    SlashPacketData slashPacketData = 2;
    VSCMaturedPacketData vscMaturedPacketData = 3;
  }
}


// ConsumerPacketDataList is a list of consumer packet data packets.
message ConsumerPacketDataList {
  repeated ConsumerPacketData list = 1
  [ (gogoproto.nullable) = false ];
}


// ConsumerPacketType indicates interchain security specific packet types.
enum ConsumerPacketDataType {
  option (gogoproto.goproto_enum_prefix) = false;

  // UNSPECIFIED packet type
  CONSUMER_PACKET_TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UnspecifiedPacket"];
  // Slash packet
  CONSUMER_PACKET_TYPE_SLASH = 1 [(gogoproto.enumvalue_customname) = "SlashPacket"];
  // VSCMatured packet
  CONSUMER_PACKET_TYPE_VSCM = 2 [(gogoproto.enumvalue_customname) = "VscMaturedPacket"];
}