github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/evidence/spec/01_concepts.md (about)

     1  <!--
     2  order: 1
     3  -->
     4  
     5  # Concepts
     6  
     7  ## Evidence
     8  
     9  Any concrete type of evidence submitted to the `x/evidence` module must fulfill the
    10  `Evidence` contract outlined below. Not all concrete types of evidence will fulfill
    11  this contract in the same way and some data may be entirely irrelevant to certain
    12  types of evidence.
    13  
    14  ```go
    15  type Evidence interface {
    16    Route() string
    17    Type() string
    18    String() string
    19    Hash() HexBytes
    20    ValidateBasic() error
    21  
    22    // The consensus address of the malicious validator at time of infraction
    23    GetConsensusAddress() ConsAddress
    24  
    25    // Height at which the infraction occurred
    26    GetHeight() int64
    27  
    28    // The total power of the malicious validator at time of infraction
    29    GetValidatorPower() int64
    30  
    31    // The total validator set power at time of infraction
    32    GetTotalPower() int64
    33  }
    34  ```
    35  
    36  ## Registration & Handling
    37  
    38  The `x/evidence` module must first know about all types of evidence it is expected
    39  to handle. This is accomplished by registering the `Route` method in the `Evidence`
    40  contract with what is known as a `Router` (defined below). The `Router` accepts
    41  `Evidence` and attempts to find the corresponding `Handler` for the `Evidence`
    42  via the `Route` method.
    43  
    44  ```go
    45  type Router interface {
    46    AddRoute(r string, h Handler) Router
    47    HasRoute(r string) bool
    48    GetRoute(path string) Handler
    49    Seal()
    50    Sealed() bool
    51  }
    52  ```
    53  
    54  The `Handler` (defined below) is responsible for executing the entirety of the
    55  business logic for handling `Evidence`. This typically includes validating the
    56  evidence, both stateless checks via `ValidateBasic` and stateful checks via any
    57  keepers provided to the `Handler`. In addition, the `Handler` may also perform
    58  capabilities such as slashing and jailing a validator.
    59  
    60  ```go
    61  type Handler func(Context, Evidence) error
    62  ```