syntax = "proto3";
package interchain_security.ccv.consumer.v1;

import "interchain_security/ccv/v1/ccv.proto";

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

import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

// Params defines the parameters for CCV consumer module
message Params {
  // TODO: Remove enabled flag and find a better way to setup e2e tests
  // See: https://github.com/cosmos/interchain-security/issues/339
  bool enabled = 1;

  ///////////////////////
  // Distribution Params
  // Number of blocks between ibc-token-transfers from the consumer chain to
  // the provider chain. Note that at this transmission event a fraction of
  // the accumulated tokens are divided and sent consumer redistribution
  // address.
  int64 blocks_per_distribution_transmission = 2;

  // Channel, and provider-chain receiving address to send distribution token
  // transfers over. These parameters is auto-set during the consumer <->
  // provider handshake procedure.
  string distribution_transmission_channel = 3;
  string provider_fee_pool_addr_str = 4;
  // Sent CCV related IBC packets will timeout after this duration
  google.protobuf.Duration ccv_timeout_period = 5
      [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];

  // Sent transfer related IBC packets will timeout after this duration
  google.protobuf.Duration transfer_timeout_period = 6
      [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];

  // The fraction of tokens allocated to the consumer redistribution address
  // during distribution events. The fraction is a string representing a
  // decimal number. For example "0.75" would represent 75%.
  string consumer_redistribution_fraction = 7;

  // The number of historical info entries to persist in store.
  // This param is a part of the cosmos sdk staking module. In the case of 
  // a ccv enabled consumer chain, the ccv module acts as the staking module.
  int64 historical_entries = 8;

  // Unbonding period for the consumer,
  // which should be smaller than that of the provider in general.
  google.protobuf.Duration unbonding_period = 9
      [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
}

// LastTransmissionBlockHeight is the last time validator holding
// pools were transmitted to the provider chain
message LastTransmissionBlockHeight { int64 height = 1; }

// CrossChainValidator defines the validators for CCV consumer module
message CrossChainValidator {
  bytes address = 1;
  int64 power = 2;
  // pubkey is the consensus public key of the validator, as a Protobuf Any.
  google.protobuf.Any pubkey = 3 [
    (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey",
    (gogoproto.moretags) = "yaml:\"consensus_pubkey\""
  ];
}

// MaturingVSCPacket contains the maturing time of a received VSCPacket
message MaturingVSCPacket {
  uint64 vscId = 1;
  google.protobuf.Timestamp maturity_time = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}
