github.com/klaytn/klaytn@v1.12.1/consensus/istanbul/validator/doc.go (about)

     1  // Copyright 2018 The klaytn Authors
     2  // This file is part of the klaytn library.
     3  //
     4  // The klaytn library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The klaytn library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the klaytn library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  /*
    18  Package validator implements the types related to the validators participating in consensus.
    19  
    20  `Validator` and `ValidatorSet` interfaces are used to validate blocks and make a consensus.
    21  Implementations of these interfaces are different, depending on proposer-choosing policy.
    22  
    23  Validator
    24  
    25  `Validator` is a node which has 2 features to make a consensus: proposing and validating.
    26  
    27  Propose: A node can propose a block if it is a proposer. Only validators can be a proposer.
    28  
    29  Validate: A validator node can validate blocks from proposers. A block is valid only if more than 2/3 of validators approve the given block.
    30  
    31  ValidatorSet
    32  
    33  `ValidatorSet` is a group of validators. It is also called as a council.
    34  ValidatorSet calculates the block proposer of an upcoming block.
    35  A validator selected as a block proposer will have a chance to make a block.
    36  
    37  Implementation in Klaytn
    38  
    39  Klaytn implements `Validator` and `ValidatorSet` interface for Klaytn consensus.
    40  Klaytn reflects the ratio of staking amounts to the probability of selecting a proposer.
    41  This is called weightedRandom policy.
    42  Detailed information can be found in https://docs.klaytn.com/klaytn/token_economy#klaytn-governance-council-reward.
    43  Implementation structures are weightedValidator and weightedCouncil in weighted.go file.
    44  
    45  Files
    46  
    47  - default.go   : Validator and ValidatorSet for roundRobin policy is implemented.
    48  
    49  - weighted.go  : Validator and ValidatorSet for weightedRandom policy is implemented.
    50  
    51  - validator.go : common functions for Validator and ValidatorSet are implemented.
    52  */
    53  package validator