# Concepts

# Evidence

Any concrete type of evidence submitted to the x/evidence module must fulfill the Evidence contract outlined below. Not all concrete types of evidence will fulfill this contract in the same way and some data may be entirely irrelevant to certain types of evidence. An additional ValidatorEvidence, which extends Evidence, has also been created to define a contract for evidence against malicious validators.

Copy // Evidence defines the contract which concrete evidence types of misbehavior // must implement. type Evidence interface { proto.Message Route() string Type() string String() string Hash() tmbytes.HexBytes ValidateBasic() error // Height at which the infraction occurred GetHeight() int64 } // ValidatorEvidence extends Evidence interface to define contract // for evidence against malicious validators type ValidatorEvidence interface { Evidence // The consensus address of the malicious validator at time of infraction GetConsensusAddress() sdk.ConsAddress // The total power of the malicious validator at time of infraction GetValidatorPower() int64 // The total validator set power at time of infraction GetTotalPower() int64 }

# Registration & Handling

The x/evidence module must first know about all types of evidence it is expected to handle. This is accomplished by registering the Route method in the Evidence contract with what is known as a Router (defined below). The Router accepts Evidence and attempts to find the corresponding Handler for the Evidence via the Route method.

Copy type Router interface { AddRoute(r string, h Handler) Router HasRoute(r string) bool GetRoute(path string) Handler Seal() Sealed() bool }

The Handler (defined below) is responsible for executing the entirety of the business logic for handling Evidence. This typically includes validating the evidence, both stateless checks via ValidateBasic and stateful checks via any keepers provided to the Handler. In addition, the Handler may also perform capabilities such as slashing and jailing a validator. All Evidence handled by the Handler should be persisted.

Copy // Handler defines an agnostic Evidence handler. The handler is responsible // for executing all corresponding business logic necessary for verifying the // evidence as valid. In addition, the Handler may execute any necessary // slashing and potential jailing. type Handler func(sdk.Context, Evidence) error

# App Wiring

The minimal app-wiring configuration for x/evidence is as follows:

Copy modules: - name: runtime config: "@type": cosmos.app.runtime.v1alpha1.Module app_name: EvidenceApp begin_blockers: [slashing, evidence, staking, auth, bank, genutil, params] end_blockers: [staking, auth, bank, slashing, genutil, evidence, params] init_genesis: [auth, bank, staking, slashing, genutil, evidence, params] - name: auth config: "@type": cosmos.auth.module.v1.Module bech32_prefix: cosmos module_account_permissions: - account: fee_collector - account: mint permissions: [minter] - account: bonded_tokens_pool permissions: [burner, staking] - account: not_bonded_tokens_pool permissions: [burner, staking] - account: nft - name: bank config: "@type": cosmos.bank.module.v1.Module - name: params config: "@type": cosmos.params.module.v1.Module - name: tx config: "@type": cosmos.tx.module.v1.Module - name: staking config: "@type": cosmos.staking.module.v1.Module - name: slashing config: "@type": cosmos.slashing.module.v1.Module - name: genutil config: "@type": cosmos.genutil.module.v1.Module - name: evidence config: "@type": cosmos.evidence.module.v1.Module