types

package
v0.0.0-...-a8d0dae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

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

View Source
const (
	EventTypeSubmitEvidence = "submit_evidence"

	AttributeValueCategory   = "evidence"
	AttributeKeyEvidenceHash = "evidence_hash"
)

evidence module events

View Source
const (
	RouteEquivocation = "equivocation"
	TypeEquivocation  = "equivocation"
)

Evidence type constants

View Source
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
)
View Source
const (
	DefaultParamspace     = ModuleName
	DefaultMaxEvidenceAge = 60 * 2 * time.Second
)

Default parameter values

View Source
const (
	QueryParameters  = "parameters"
	QueryEvidence    = "evidence"
	QueryAllEvidence = "all_evidence"
)

Querier routes for the evidence module

View Source
const (
	TestEvidenceRouteEquivocation = "TestEquivocationEvidence"
	TestEvidenceTypeEquivocation  = "equivocation"
)
View Source
const BaseEvidenceError = 9001
View Source
const (
	TypeMsgSubmitEvidence = "submit_evidence"
)

Message types for the evidence module

Variables

View Source
var (
	ErrNoEvidenceHandlerExists = sdkerrors.Register(ModuleName, BaseEvidenceError+1, "unregistered handler for evidence type")
	ErrInvalidEvidence         = sdkerrors.Register(ModuleName, BaseEvidenceError+2, "invalid evidence")
	ErrNoEvidenceExists        = sdkerrors.Register(ModuleName, BaseEvidenceError+3, "evidence does not exist")
	ErrEvidenceExists          = sdkerrors.Register(ModuleName, BaseEvidenceError+4, "evidence already exists")
)

x/evidence module sentinel errors

View Source
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

View Source
var (
	KeyPrefixEvidence = []byte{0x00}
)

KVStore key prefixes

View Source
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.

View Source
var (
	TestingCdc = codec.New()
)

Functions

func ConvertDuplicateVoteEvidence

func ConvertDuplicateVoteEvidence(dupVote abci.Evidence) exported.Evidence

ConvertDuplicateVoteEvidence converts a Tendermint concrete Evidence type to SDK Evidence using Equivocation as the concrete type.

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable returns the parameter key table.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

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

type Handler func(sdk.Context, exported.Evidence) error

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 (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.

func (Params) String

func (p Params) String() string

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.

func NewRouter

func NewRouter() Router

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

	//Append abandoned validator to staking keeper
	AppendAbandonedValidatorAddrs(ctx sdk.Context, ConsAddr sdk.ConsAddress)
}

StakingKeeper defines the staking module interface contract needed by the evidence module.

type TestCanonicalVote

type TestCanonicalVote struct {
	Height    int64
	Round     int64
	Timestamp time.Time
	ChainID   string
}

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 (TestEquivocationEvidence) Route

func (e TestEquivocationEvidence) Route() string

func (TestEquivocationEvidence) String

func (e TestEquivocationEvidence) String() string

func (TestEquivocationEvidence) Type

func (TestEquivocationEvidence) ValidateBasic

func (e TestEquivocationEvidence) ValidateBasic() error

type TestVote

type TestVote struct {
	Height           int64
	Round            int64
	Timestamp        time.Time
	ValidatorAddress tmbytes.HexBytes
	Signature        []byte
}

func (TestVote) SignBytes

func (v TestVote) SignBytes(chainID string) []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL