syntax = "proto3";

import "blockchain.proto";

package types;

message BlockID {
    bytes Hash = 1;
}

message TendermintBitArray {
    int32    Bits         = 1;
    repeated uint64 Elems = 2;
}

message Vote {
    bytes   ValidatorAddress = 1;
    int32   ValidatorIndex   = 2;
    int64   Height           = 3;
    int32   Round            = 4;
    int64   Timestamp        = 5;
    uint32  Type             = 6;
    BlockID BlockID          = 7;
    bytes   Signature        = 8;
}

message TendermintCommit {
    BlockID  BlockID         = 1;
    repeated Vote Precommits = 2;
}

message TendermintBlockInfo {
    State            State      = 2;
    Proposal         Proposal   = 3;
    TendermintBlock  block      = 4;
}

message BlockSize {
    int32 MaxBytes = 1;
    int32 MaxTxs   = 2;
    int64 MaxGas   = 3;
}

message TxSize {
    int32 MaxBytes = 1;
    int64 MaxGas   = 2;
}

message BlockGossip {
    int32 BlockPartSizeBytes = 1;
}

message EvidenceParams {
    int64 MaxAge = 1;
}
message ConsensusParams {
    BlockSize      BlockSize      = 1;
    TxSize         TxSize         = 2;
    BlockGossip    BlockGossip    = 3;
    EvidenceParams EvidenceParams = 4;
}

message Validator {
    bytes Address     = 1;
    bytes PubKey      = 2;
    int64 VotingPower = 3;
    int64 Accum       = 4;
}

message ValidatorSet {
    repeated Validator Validators = 1;
    Validator          Proposer   = 2;
}

message State {
    string          ChainID                          = 1;
    int64           LastBlockHeight                  = 2;
    int64           LastBlockTotalTx                 = 3;
    BlockID         LastBlockID                      = 4;
    int64           LastBlockTime                    = 5;
    ValidatorSet    Validators                       = 6;
    ValidatorSet    LastValidators                   = 7;
    int64           LastHeightValidatorsChanged      = 8;
    ConsensusParams ConsensusParams                  = 9;
    int64           LastHeightConsensusParamsChanged = 10;
    bytes           LastResultsHash                  = 11;
    bytes           AppHash                          = 12;
}


message TendermintBlockHeader {
    string  chainID         = 1;
    int64   height          = 2;
    int64   round           = 3;
    int64   time            = 4;
    int64   numTxs          = 5;
    BlockID lastBlockID     = 6;
    int64   totalTxs        = 7;
    bytes   lastCommitHash  = 8;
    bytes   validatorsHash  = 9;
    bytes   consensusHash   = 10;
    bytes   appHash         = 11;
    bytes   lastResultsHash = 12;
    bytes   proposerAddr    = 13;
}

message TendermintBlock {
    TendermintBlockHeader header       = 1;
    Block                 data         = 2;
    TendermintCommit      lastCommit   = 4;
}

message Proposal {
    int64   height     = 1;
    int32   round      = 2;
    int64   timestamp  = 3;
    int32   POLRound   = 4;
    BlockID POLBlockID = 5;
    bytes   signature  = 6;
    bytes   blockhash  = 7;
}

message NewRoundStepMsg {
    int64 height                = 1;
    int32 round                 = 2;
    int32 step                  = 3;
    int32 secondsSinceStartTime = 4;
    int32 lastCommitRound       = 5;
}

message ValidBlockMsg {
    int64 height    = 1;
    int32 round     = 2;
    bytes blockhash = 3;
    bool isCommit   = 4;
}

message ProposalPOLMsg {
    int64              height           = 1;
    int32              proposalPOLRound = 2;
    TendermintBitArray proposalPOL      = 3;
}

message HasVoteMsg {
    int64 height = 1;
    int32 round  = 2;
    int32 type   = 3;
    int32 index  = 4;
}

message VoteSetMaj23Msg {
    int64   height  = 1;
    int32   round   = 2;
    int32   type    = 3;
    BlockID blockID = 4;
}

message VoteSetBitsMsg {
    int64              height  = 1;
    int32              round   = 2;
    int32              type    = 3;
    BlockID            blockID = 4;
    TendermintBitArray votes   = 5;
}

message Heartbeat {
    bytes validatorAddress = 1;
    int32 validatorIndex   = 2;
    int64 height           = 3;
    int32 round            = 4;
    int32 sequence         = 5;
    bytes signature        = 6;
}

message IsHealthy {
    bool isHealthy = 1;
}