types

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	CodeNoEvidenceHandlerExists sdk.CodeType = 1
	CodeInvalidEvidence         sdk.CodeType = 2
	CodeNoEvidenceExists        sdk.CodeType = 3
	CodeEvidenceExists          sdk.CodeType = 4
)

Error codes specific to the evidence module

View Source
const (
	EventTypeSubmitEvidence = "submit_evidence"

	AttributeValueCategory   = ModuleName
	AttributeKeyEvidenceHash = "evidence_hash"
)

evidence module event types

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "evidence"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName

	// RouterKey to be used for routing msgs
	RouterKey = ModuleName

	// QuerierRoute to be used for querierer msgs
	QuerierRoute = ModuleName
)
View Source
const (
	QueryEvidence    = "evidence"
	QueryAllEvidence = "all_evidence"
)

Querier routes for the evidence module

View Source
const (
	BehaviourCountDelayBlock uint64 = 10
)
View Source
const (
	DefaultParamspace = ModuleName
)

Default parameter namespace

View Source
const (
	TypeMsgSubmitEvidence = "submit_evidence"
)

Message types for the evidence module

Variables

View Source
var (
	VoteBehaviourKey  = "Vote"
	DsignBehaviourKey = "dsign"
)
View Source
var (
	EvidencePrefixKey             = []byte{0x00}
	ValidatorBehaviourKey         = []byte{0x01}
	ValidatorBehaviourBitArrayKey = []byte{0x02}
	VoteBoxKey                    = []byte{0x03}
	ConfirmedVoteKey              = []byte{0x04}
)
View Source
var (
	KeyBehaviourWindow        = []byte("BehaviourWindow")
	KeyMaxMisbehaviourCount   = []byte("MaxMisbehaviourCount")
	KeyBehaviourSlashFraction = []byte("BehaviourSlashFraction")
)

Parameter store keys

View Source
var AllBehaviourKeys = []string{
	VoteBehaviourKey,
	DsignBehaviourKey,
}
View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the module codec

Functions

func DecodeConfirmedVoteKey

func DecodeConfirmedVoteKey(key []byte) (uint64, string)

func ErrEvidenceExists

func ErrEvidenceExists(hash string) sdk.Error

ErrEvidenceExists returns a typed ABCI error for Evidence that already exists by hash in state.

func ErrInvalidEvidence

func ErrInvalidEvidence(msg string) sdk.Error

ErrInvalidEvidence returns a typed ABCI error for invalid evidence.

func ErrNoEvidenceExists

func ErrNoEvidenceExists(hash string) sdk.Error

ErrNoEvidenceExists returns a typed ABCI error for Evidence that does not exist for a given hash.

func ErrNoEvidenceHandlerExists

func ErrNoEvidenceHandlerExists(route string) sdk.Error

ErrNoEvidenceHandlerExists returns a typed ABCI error for an invalid evidence handler route.

func GetConfirmedVoteKeyPrefix

func GetConfirmedVoteKeyPrefix(height uint64) []byte

func GetValidatorBehaviourBitArrayKey

func GetValidatorBehaviourBitArrayKey(behaviourName string, v sdk.ValAddress, i int64) []byte

stored by *Consensus* address (not operator address)

func GetValidatorBehaviourBitArrayPrefixKey

func GetValidatorBehaviourBitArrayPrefixKey(behaviourName string, v sdk.ValAddress) []byte

func GetValidatorBehaviourKey

func GetValidatorBehaviourKey(behaviourName string, v sdk.ValAddress) []byte

func GetVoteBoxKey

func GetVoteBoxKey(voteID string) []byte

func NewVoteBox

func NewVoteBox(confirmThreshold int) exported.VoteBox

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for {{ .NameLowerCase }} module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

func ValidateGenesis

func ValidateGenesis(GenesisState) error

ValidateGenesis validates the evidence genesis parameters

Types

type BehaviourParams

type BehaviourParams struct {
	BehaviourWindow        int64
	MaxMisbehaviourCount   int64
	BehaviourSlashFraction sdk.Dec
}

Params - used for initializing default parameter for {{ .NameLowerCase }} at genesis

func DefaultBehaviourParams

func DefaultBehaviourParams() BehaviourParams

DefaultParams defines the parameters for this module

func NewBehaviourParams

func NewBehaviourParams(behaviourWindow int64, maxMisbehaviourCount int64, behaviourSlashFraction sdk.Dec) BehaviourParams

func (*BehaviourParams) ParamSetPairs

func (p *BehaviourParams) ParamSetPairs() params.ParamSetPairs

ParamSetPairs - Implements params.ParamSet

func (BehaviourParams) String

func (p BehaviourParams) String() string

String implements the stringer interface for Params

type BoolVote

type BoolVote bool

type GenesisState

type GenesisState struct {
	BehaviourParams map[string]BehaviourParams
}

GenesisState - all evidence state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

func NewGenesisState

func NewGenesisState(behaviourParams map[string]BehaviourParams) GenesisState

NewGenesisState creates a new GenesisState object

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.

type MsgSubmitEvidence

type MsgSubmitEvidence struct {
	Evidence  exported.Evidence `json:"evidence" yaml:"evidence"`
	Submitter sdk.CUAddress     `json:"submitter" yaml:"submitter"`
}

MsgSubmitEvidence defines an sdk.Msg type that supports submitting arbitrary Evidence.

func NewMsgSubmitEvidence

func NewMsgSubmitEvidence(e exported.Evidence, s sdk.CUAddress) 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.CUAddress

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() sdk.Error

ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitEvidence.

type ParamSubspace

type ParamSubspace interface {
	WithKeyTable(table params.KeyTable) params.Subspace
	Get(ctx sdk.Context, key []byte, ptr interface{})
	GetParamSet(ctx sdk.Context, ps params.ParamSet)
	SetParamSet(ctx sdk.Context, ps params.ParamSet)
	GetWithSubkey(ctx sdk.Context, key, subkey []byte, ptr interface{})
	GetParamSetWithSubkey(ctx sdk.Context, key []byte, ps params.ParamSet)
	SetParamSetWithSubkey(ctx sdk.Context, key []byte, ps params.ParamSet)
}

ParamSubspace defines the expected Subspace interfacace

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 StakingKeeper

type StakingKeeper interface {
	SlashByOperator(sdk.Context, sdk.ValAddress, int64, sdk.Dec)
	JailByOperator(ctx sdk.Context, operator sdk.ValAddress)
	GetEpochByHeight(ctx sdk.Context, height uint64) sdk.Epoch
	GetCurrentEpoch(ctx sdk.Context) sdk.Epoch
}

type ValidatorBehaviour

type ValidatorBehaviour struct {
	IndexOffset         int64 `json:"index_offset" yaml:"index_offset"`                   // index offset into signed block bit array
	MisbehaviourCounter int64 `json:"missed_blocks_counter" yaml:"missed_blocks_counter"` // missed blocks counter (to avoid scanning the array every time)
}

Signing info for a validator

type VoteBox

type VoteBox struct {
	ConfirmThreshold int                  `json:"confirm_threshold"`
	VoteItems        []*exported.VoteItem `json:"vote_items"`
	Confirmed        bool                 `json:"confirmed"`
	Result           exported.Vote        `json:"result"`
}

VoteBox is the default implement of exported.VoteBox interface. It's confirmed when over 2/3 validators vote to the same results.

func (*VoteBox) AddVote

func (v *VoteBox) AddVote(voter sdk.CUAddress, vote exported.Vote) bool

func (*VoteBox) HasConfirmed

func (v *VoteBox) HasConfirmed() bool

func (*VoteBox) ValidVotes

func (v *VoteBox) ValidVotes() []*exported.VoteItem

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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