Documentation ¶
Overview ¶
DONTCOVER
Common testing types and utility functions and methods to be used in unit and integration testing of the evidence module.
DONTCOVER
Index ¶
- Constants
- Variables
- func ConvertDuplicateVoteEvidence(dupVote abci.Evidence) exported.Evidence
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func RegisterEvidenceTypeCodec(o interface{}, name string)
- type Equivocation
- func (e Equivocation) GetConsensusAddress() sdk.ConsAddress
- func (e Equivocation) GetHeight() int64
- func (e Equivocation) GetTime() time.Time
- func (e Equivocation) GetTotalPower() int64
- func (e Equivocation) GetValidatorPower() int64
- func (e Equivocation) Hash() tmbytes.HexBytes
- func (e Equivocation) Route() string
- func (e Equivocation) String() string
- func (e Equivocation) Type() string
- func (e Equivocation) ValidateBasic() error
- type GenesisState
- type Handler
- type MsgSubmitEvidence
- type Params
- type QueryAllEvidenceParams
- type QueryEvidenceParams
- type Router
- type SlashingKeeper
- type StakingKeeper
- type TestCanonicalVote
- type TestEquivocationEvidence
- func (e TestEquivocationEvidence) GetConsensusAddress() sdk.ConsAddress
- func (e TestEquivocationEvidence) GetHeight() int64
- func (e TestEquivocationEvidence) GetTotalPower() int64
- func (e TestEquivocationEvidence) GetValidatorPower() int64
- func (e TestEquivocationEvidence) Hash() tmbytes.HexBytes
- func (e TestEquivocationEvidence) Route() string
- func (e TestEquivocationEvidence) String() string
- func (e TestEquivocationEvidence) Type() string
- func (e TestEquivocationEvidence) ValidateBasic() error
- type TestVote
Constants ¶
const ( EventTypeSubmitEvidence = "submit_evidence" AttributeValueCategory = "evidence" AttributeKeyEvidenceHash = "evidence_hash" )
evidence module events
const ( RouteEquivocation = "equivocation" TypeEquivocation = "equivocation" )
Evidence type constants
const ( // ModuleName defines the module name ModuleName = "evidence" // StoreKey defines the primary module store key StoreKey = ModuleName // RouterKey defines the module's message routing key RouterKey = ModuleName // QuerierRoute defines the module's query routing key QuerierRoute = ModuleName )
const ( DefaultParamspace = ModuleName DefaultMaxEvidenceAge = 60 * 2 * time.Second )
Default parameter values
const ( QueryParameters = "parameters" QueryEvidence = "evidence" QueryAllEvidence = "all_evidence" )
Querier routes for the evidence module
const ( TestEvidenceRouteEquivocation = "TestEquivocationEvidence" TestEvidenceTypeEquivocation = "equivocation" )
const (
TypeMsgSubmitEvidence = "submit_evidence"
)
Message types for the evidence module
Variables ¶
var ( ErrNoEvidenceHandlerExists = sdkerrors.Register(ModuleName, 1, "unregistered handler for evidence type") ErrInvalidEvidence = sdkerrors.Register(ModuleName, 2, "invalid evidence") ErrNoEvidenceExists = sdkerrors.Register(ModuleName, 3, "evidence does not exist") ErrEvidenceExists = sdkerrors.Register(ModuleName, 4, "evidence already exists") )
x/evidence module sentinel errors
var ( KeyMaxEvidenceAge = []byte("MaxEvidenceAge") // The Double Sign Jail period ends at Max Time supported by Amino // (Dec 31, 9999 - 23:59:59 GMT). DoubleSignJailEndTime = time.Unix(253402300799, 0) )
Parameter store keys
var (
KeyPrefixEvidence = []byte{0x00}
)
KVStore key prefixes
var ModuleCdc = codec.New()
ModuleCdc defines the evidence module's codec. The codec is not sealed as to allow other modules to register their concrete Evidence types.
var (
TestingCdc = codec.New()
)
Functions ¶
func ConvertDuplicateVoteEvidence ¶
ConvertDuplicateVoteEvidence converts a Tendermint concrete Evidence type to SDK Evidence using Equivocation as the concrete type.
func ParamKeyTable ¶
ParamKeyTable returns the parameter key table.
func RegisterCodec ¶
RegisterCodec registers all the necessary types and interfaces for the evidence module.
func RegisterEvidenceTypeCodec ¶
func RegisterEvidenceTypeCodec(o interface{}, name string)
RegisterEvidenceTypeCodec registers an external concrete Evidence type defined in another module for the internal ModuleCdc. This allows the MsgSubmitEvidence to be correctly Amino encoded and decoded.
Types ¶
type Equivocation ¶
type Equivocation struct { Height int64 `json:"height" yaml:"height"` Time time.Time `json:"time" yaml:"time"` Power int64 `json:"power" yaml:"power"` ConsensusAddress sdk.ConsAddress `json:"consensus_address" yaml:"consensus_address"` }
Equivocation implements the Evidence interface and defines evidence of double signing misbehavior.
func (Equivocation) GetConsensusAddress ¶
func (e Equivocation) GetConsensusAddress() sdk.ConsAddress
GetConsensusAddress returns the validator's consensus address at time of the Equivocation infraction.
func (Equivocation) GetHeight ¶
func (e Equivocation) GetHeight() int64
GetHeight returns the height at time of the Equivocation infraction.
func (Equivocation) GetTime ¶
func (e Equivocation) GetTime() time.Time
GetTime returns the time at time of the Equivocation infraction.
func (Equivocation) GetTotalPower ¶
func (e Equivocation) GetTotalPower() int64
GetTotalPower is a no-op for the Equivocation type.
func (Equivocation) GetValidatorPower ¶
func (e Equivocation) GetValidatorPower() int64
GetValidatorPower returns the validator's power at time of the Equivocation infraction.
func (Equivocation) Hash ¶
func (e Equivocation) Hash() tmbytes.HexBytes
Hash returns the hash of an Equivocation object.
func (Equivocation) Route ¶
func (e Equivocation) Route() string
Route returns the Evidence Handler route for an Equivocation type.
func (Equivocation) String ¶
func (e Equivocation) String() string
func (Equivocation) Type ¶
func (e Equivocation) Type() string
Type returns the Evidence Handler type for an Equivocation type.
func (Equivocation) ValidateBasic ¶
func (e Equivocation) ValidateBasic() error
ValidateBasic performs basic stateless validation checks on an Equivocation object.
type GenesisState ¶
type GenesisState struct { Params Params `json:"params" yaml:"params"` Evidence []exported.Evidence `json:"evidence" yaml:"evidence"` }
GenesisState defines the evidence module's genesis state.
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState returns the evidence module's default genesis state.
func NewGenesisState ¶
func NewGenesisState(p Params, e []exported.Evidence) GenesisState
func (GenesisState) Validate ¶
func (gs GenesisState) Validate() error
Validate performs basic gensis state validation returning an error upon any failure.
type Handler ¶
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.
func TestEquivocationHandler ¶
func TestEquivocationHandler(k interface{}) Handler
type MsgSubmitEvidence ¶
type MsgSubmitEvidence struct { Evidence exported.Evidence `json:"evidence" yaml:"evidence"` Submitter sdk.AccAddress `json:"submitter" yaml:"submitter"` }
MsgSubmitEvidence defines an sdk.Msg type that supports submitting arbitrary Evidence.
func NewMsgSubmitEvidence ¶
func NewMsgSubmitEvidence(e exported.Evidence, s sdk.AccAddress) MsgSubmitEvidence
func (MsgSubmitEvidence) GetSignBytes ¶
func (m MsgSubmitEvidence) GetSignBytes() []byte
GetSignBytes returns the raw bytes a signer is expected to sign when submitting a MsgSubmitEvidence message.
func (MsgSubmitEvidence) GetSigners ¶
func (m MsgSubmitEvidence) GetSigners() []sdk.AccAddress
GetSigners returns the single expected signer for a MsgSubmitEvidence.
func (MsgSubmitEvidence) Route ¶
func (m MsgSubmitEvidence) Route() string
Route returns the MsgSubmitEvidence's route.
func (MsgSubmitEvidence) Type ¶
func (m MsgSubmitEvidence) Type() string
Type returns the MsgSubmitEvidence's type.
func (MsgSubmitEvidence) ValidateBasic ¶
func (m MsgSubmitEvidence) ValidateBasic() error
ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitEvidence.
type Params ¶
type Params struct {
MaxEvidenceAge time.Duration `json:"max_evidence_age" yaml:"max_evidence_age"`
}
Params defines the total set of parameters for the evidence module
func DefaultParams ¶
func DefaultParams() Params
DefaultParams returns the default parameters for the evidence module.
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs returns the parameter set pairs.
type QueryAllEvidenceParams ¶
type QueryAllEvidenceParams struct { Page int `json:"page" yaml:"page"` Limit int `json:"limit" yaml:"limit"` }
QueryAllEvidenceParams defines the parameters necessary for querying for all Evidence.
func NewQueryAllEvidenceParams ¶
func NewQueryAllEvidenceParams(page, limit int) QueryAllEvidenceParams
type QueryEvidenceParams ¶
type QueryEvidenceParams struct {
EvidenceHash string `json:"evidence_hash" yaml:"evidence_hash"`
}
QueryEvidenceParams defines the parameters necessary for querying Evidence.
func NewQueryEvidenceParams ¶
func NewQueryEvidenceParams(hash string) QueryEvidenceParams
type Router ¶
type Router interface { AddRoute(r string, h Handler) Router HasRoute(r string) bool GetRoute(path string) Handler Seal() Sealed() bool }
Router defines a contract for which any Evidence handling module must implement in order to route Evidence to registered Handlers.
type SlashingKeeper ¶
type SlashingKeeper interface { GetPubkey(sdk.Context, crypto.Address) (crypto.PubKey, error) IsTombstoned(sdk.Context, sdk.ConsAddress) bool HasValidatorSigningInfo(sdk.Context, sdk.ConsAddress) bool Tombstone(sdk.Context, sdk.ConsAddress) Slash(sdk.Context, sdk.ConsAddress, sdk.Dec, int64, int64) SlashFractionDoubleSign(sdk.Context) sdk.Dec Jail(sdk.Context, sdk.ConsAddress) JailUntil(sdk.Context, sdk.ConsAddress, time.Time) }
SlashingKeeper defines the slashing module interface contract needed by the evidence module.
type StakingKeeper ¶
type StakingKeeper interface {
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingexported.ValidatorI
}
StakingKeeper defines the staking module interface contract needed by the evidence module.
type TestCanonicalVote ¶
type TestEquivocationEvidence ¶
type TestEquivocationEvidence struct { Power int64 TotalPower int64 PubKey crypto.PubKey VoteA TestVote VoteB TestVote }
func (TestEquivocationEvidence) GetConsensusAddress ¶
func (e TestEquivocationEvidence) GetConsensusAddress() sdk.ConsAddress
func (TestEquivocationEvidence) GetHeight ¶
func (e TestEquivocationEvidence) GetHeight() int64
func (TestEquivocationEvidence) GetTotalPower ¶
func (e TestEquivocationEvidence) GetTotalPower() int64
func (TestEquivocationEvidence) GetValidatorPower ¶
func (e TestEquivocationEvidence) GetValidatorPower() int64
func (TestEquivocationEvidence) Hash ¶
func (e TestEquivocationEvidence) Hash() tmbytes.HexBytes
func (TestEquivocationEvidence) Route ¶
func (e TestEquivocationEvidence) Route() string
func (TestEquivocationEvidence) String ¶
func (e TestEquivocationEvidence) String() string
func (TestEquivocationEvidence) Type ¶
func (e TestEquivocationEvidence) Type() string
func (TestEquivocationEvidence) ValidateBasic ¶
func (e TestEquivocationEvidence) ValidateBasic() error