Documentation ¶
Overview ¶
Package evidence implements a Cosmos SDK module, per ADR 009, that allows for the submission and handling of arbitrary evidence of misbehavior.
All concrete evidence types must implement the Evidence interface contract. Submitted evidence is first routed through the evidence module's Router in which it attempts to find a corresponding Handler for that specific evidence type. Each evidence type must have a Handler registered with the evidence module's keeper in order for it to be successfully executed.
Each corresponding handler must also fulfill the Handler interface contract. The Handler for a given Evidence type can perform any arbitrary state transitions such as slashing, jailing, and tombstoning. This provides developers with great flexibility in designing evidence handling.
A full setup of the evidence module may look something as follows:
ModuleBasics = module.NewBasicManager( // ..., evidence.AppModuleBasic{}, ) // First, create the keeper's subspace for parameters and the keeper itself. evidenceParamspace := app.ParamsKeeper.Subspace(evidence.DefaultParamspace) evidenceKeeper := evidence.NewKeeper( app.cdc, keys[evidence.StoreKey], evidenceParamspace, evidence.DefaultCodespace, ) // Second, create the evidence Handler and register all desired routes. evidenceRouter := evidence.NewRouter(). AddRoute(evidenceRoute, evidenceHandler). AddRoute(..., ...) evidenceKeeper.SetRouter(evidenceRouter) app.mm = module.NewManager( // ... evidence.NewAppModule(evidenceKeeper), ) // Remaining application bootstrapping...
Index ¶
- Constants
- Variables
- func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k Keeper)
- func InitGenesis(ctx sdk.Context, k Keeper, gs GenesisState)
- func NewHandler(k Keeper) sdk.Handler
- type AppModule
- func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)
- func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
- func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, bz json.RawMessage) []abci.ValidatorUpdate
- func (am AppModule) Name() string
- func (am AppModule) NewHandler() sdk.Handler
- func (am AppModule) NewQuerierHandler() sdk.Querier
- func (AppModule) QuerierRoute() string
- func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
- func (AppModule) Route() string
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis() json.RawMessage
- func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
- func (a AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
- func (a AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
- func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
- type Equivocation
- type GenesisState
- type Handler
- type Keeper
- type MsgSubmitEvidence
- type Router
Constants ¶
const ( ModuleName = types.ModuleName StoreKey = types.StoreKey RouterKey = types.RouterKey QuerierRoute = types.QuerierRoute DefaultParamspace = types.DefaultParamspace QueryEvidence = types.QueryEvidence QueryAllEvidence = types.QueryAllEvidence QueryParameters = types.QueryParameters TypeMsgSubmitEvidence = types.TypeMsgSubmitEvidence EventTypeSubmitEvidence = types.EventTypeSubmitEvidence AttributeValueCategory = types.AttributeValueCategory AttributeKeyEvidenceHash = types.AttributeKeyEvidenceHash DefaultMaxEvidenceAge = types.DefaultMaxEvidenceAge )
Variables ¶
var ( NewKeeper = keeper.NewKeeper NewQuerier = keeper.NewQuerier NewMsgSubmitEvidence = types.NewMsgSubmitEvidence NewRouter = types.NewRouter NewQueryEvidenceParams = types.NewQueryEvidenceParams NewQueryAllEvidenceParams = types.NewQueryAllEvidenceParams RegisterCodec = types.RegisterCodec RegisterEvidenceTypeCodec = types.RegisterEvidenceTypeCodec ModuleCdc = types.ModuleCdc NewGenesisState = types.NewGenesisState DefaultGenesisState = types.DefaultGenesisState ConvertDuplicateVoteEvidence = types.ConvertDuplicateVoteEvidence KeyMaxEvidenceAge = types.KeyMaxEvidenceAge DoubleSignJailEndTime = types.DoubleSignJailEndTime ParamKeyTable = types.ParamKeyTable )
Functions ¶
func BeginBlocker ¶
func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k Keeper)
BeginBlocker iterates through and handles any newly discovered evidence of misbehavior submitted by Tendermint. Currently, only equivocation is handled.
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, k Keeper, gs GenesisState)
InitGenesis initializes the evidence module's state from a provided genesis state.
func NewHandler ¶
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule implements the AppModule interface for the evidence module.
func NewAppModule ¶
func (AppModule) BeginBlock ¶
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)
BeginBlock executes all ABCI BeginBlock logic respective to the evidence module.
func (AppModule) EndBlock ¶
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
EndBlock executes all ABCI EndBlock logic respective to the evidence module. It returns no validator updates.
func (AppModule) ExportGenesis ¶
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
ExportGenesis returns the evidence module's exported genesis state as raw JSON bytes.
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, bz json.RawMessage) []abci.ValidatorUpdate
InitGenesis performs the evidence module's genesis initialization It returns no validator updates.
func (AppModule) NewHandler ¶
NewHandler returns the evidence module's message Handler.
func (AppModule) NewQuerierHandler ¶
NewQuerierHandler returns the evidence module's Querier.
func (AppModule) QuerierRoute ¶
QuerierRoute returns the evidence module's query routing key.
func (AppModule) RegisterInvariants ¶
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
RegisterInvariants registers the evidence module's invariants.
type AppModuleBasic ¶
type AppModuleBasic struct {
// contains filtered or unexported fields
}
AppModuleBasic implements the AppModuleBasic interface for the evidence module.
func NewAppModuleBasic ¶
func NewAppModuleBasic(evidenceHandlers ...client.EvidenceHandler) AppModuleBasic
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis() json.RawMessage
DefaultGenesis returns the evidence module's default genesis state.
func (AppModuleBasic) GetQueryCmd ¶
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
GetTxCmd returns the evidence module's root query command.
func (AppModuleBasic) GetTxCmd ¶
func (a AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command
GetTxCmd returns the evidence module's root tx command.
func (AppModuleBasic) Name ¶
func (AppModuleBasic) Name() string
Name returns the evidence module's name.
func (AppModuleBasic) RegisterCodec ¶
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
RegisterCodec registers the evidence module's types to the provided codec.
func (AppModuleBasic) RegisterRESTRoutes ¶
func (a AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
RegisterRESTRoutes registers the evidence module's REST service handlers.
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
ValidateGenesis performs genesis state validation for the evidence module.
type Equivocation ¶
type Equivocation = types.Equivocation
type GenesisState ¶
type GenesisState = types.GenesisState
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState
ExportGenesis returns the evidence module's exported genesis.
type MsgSubmitEvidence ¶
type MsgSubmitEvidence = types.MsgSubmitEvidence
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
types
DONTCOVER Common testing types and utility functions and methods to be used in unit and integration testing of the evidence module.
|
DONTCOVER Common testing types and utility functions and methods to be used in unit and integration testing of the evidence module. |
DONTCOVER
|
DONTCOVER |