types

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

noalias

Index

Constants

View Source
const (
	EventTypeSlash       = "slash"
	EventTypeSlashLimit  = "slash-limit"
	EventTypeTickConfirm = "tick-confirm"
	EventTypeTickAck     = "tick-ack"
	EventTypeUnjail      = "unjail"
	EventTypeLiveness    = "liveness"

	AttributeKeyAddress        = "address"
	AttributeKeyValID          = "valid"
	AttributeKeyHeight         = "height"
	AttributeKeyPower          = "power"
	AttributeKeySlashedAmount  = "slashed-amount"
	AttributeKeySlashInfoBytes = "slash-info-bytes"
	AttributeKeyProposer       = "proposer"
	AttributeKeyReason         = "reason"
	AttributeKeyJailed         = "jailed"
	AttributeKeyMissedBlocks   = "missed_blocks"

	AttributeValueDoubleSign       = "double_sign"
	AttributeValueMissingSignature = "missing_signature"
	AttributeValueCategory         = ModuleName
)

Slashing module event types

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

Evidence type constants

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

	// StoreKey is the store key string for slashing
	StoreKey = ModuleName

	// RouterKey is the message route for slashing
	RouterKey = ModuleName

	// QuerierRoute is the querier route for slashing
	QuerierRoute = ModuleName
)
View Source
const (
	DefaultParamspace           = ModuleName
	DefaultSignedBlocksWindow   = int64(100)
	DefaultDowntimeJailDuration = 60 * 10 * time.Second
)

Default parameter namespace

View Source
const (
	QueryParameters        = "parameters"
	QuerySigningInfo       = "signingInfo"
	QuerySigningInfos      = "signingInfos"
	QuerySlashingInfo      = "slashingInfo"
	QuerySlashingInfos     = "slashingInfos"
	QuerySlashingInfoBytes = "slashingInfoBytes"
	QueryTickSlashingInfos = "tickSlashingInfos"
	QuerySlashingSequence  = "slashing-sequence"
	QueryTickCount         = "tick-count"
)

Query endpoints supported by the slashing querier

Variables

View Source
var (
	DefaultValue = []byte{0x01} // Value to store for slashing sequence

	ValidatorSigningInfoKey         = []byte{0x01} // Prefix for signing info
	ValidatorMissedBlockBitArrayKey = []byte{0x02} // Prefix for missed block bit array
	AddrPubkeyRelationKey           = []byte{0x03} // Prefix for address-pubkey relation
	TotalSlashedAmountKey           = []byte{0x04} // Prefix for total slashed amount stored in buffer
	BufferValSlashingInfoKey        = []byte{0x05} // Prefix for Slashing Info stored in buffer
	TickValSlashingInfoKey          = []byte{0x06} // Prefix for Slashing Info stored after tick tx
	SlashingSequenceKey             = []byte{0x07} // prefix for each key for slashing sequence map
	TickCountKey                    = []byte{0x08} // key to store Tick counts
)

Keys for slashing store Items are stored with the following key: values

- 0x01<consAddress_Bytes>: ValidatorSigningInfo

- 0x02<consAddress_Bytes><period_Bytes>: bool

- 0x03<accAddr_Bytes>: crypto.PubKey

View Source
var (
	DefaultMinSignedPerWindow      = sdk.NewDecWithPrec(5, 1)
	DefaultSlashFractionDoubleSign = sdk.NewDec(1).Quo(sdk.NewDec(20))
	DefaultSlashFractionDowntime   = sdk.NewDec(1).Quo(sdk.NewDec(100))
	DefaultSlashFractionLimit      = sdk.NewDec(1).Quo(sdk.NewDec(3))
	DefaultJailFractionLimit       = sdk.NewDec(1).Quo(sdk.NewDec(3))
	DefaultMaxEvidenceAge          = 60 * 2 * time.Second
	DefaultEnableSlashing          = false
)
View Source
var (
	KeySignedBlocksWindow      = []byte("SignedBlocksWindow")
	KeyMinSignedPerWindow      = []byte("MinSignedPerWindow")
	KeyDowntimeJailDuration    = []byte("DowntimeJailDuration")
	KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign")
	KeySlashFractionDowntime   = []byte("SlashFractionDowntime")
	KeySlashFractionLimit      = []byte("SlashFractionLimit")
	KeyJailFractionLimit       = []byte("JailFractionLimit")
	KeyMaxEvidenceAge          = []byte("MaxEvidenceAge")
	KeyEnableSlashing          = []byte("EnableSlashing")
)

Parameter store keys

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func GetBufferValSlashingInfoKey

func GetBufferValSlashingInfoKey(id []byte) []byte

GetBufferValSlashingInfoKey - gets buffer val slashing info key

func GetSlashingSequenceKey

func GetSlashingSequenceKey(sequence string) []byte

GetSlashingSequenceKey returns slashing sequence key

func GetTickValSlashingInfoKey

func GetTickValSlashingInfoKey(id []byte) []byte

func GetValidatorMissedBlockBitArrayKey

func GetValidatorMissedBlockBitArrayKey(valID []byte, i int64) []byte

GetValidatorMissedBlockBitArrayKey - stored by *Consensus* address (not operator address)

func GetValidatorMissedBlockBitArrayPrefixKey

func GetValidatorMissedBlockBitArrayPrefixKey(valID []byte) []byte

GetValidatorMissedBlockBitArrayPrefixKey - stored by *Consensus* address (not operator address)

func GetValidatorSigningInfoKey

func GetValidatorSigningInfoKey(valID []byte) []byte

GetValidatorSigningInfoKey - stored by *valID*

func ParamKeyTable

func ParamKeyTable() subspace.KeyTable

ParamKeyTable for slashing module

func RLPDecodeSlashInfos

func RLPDecodeSlashInfos(encodedSlashInfo []byte) ([]*hmTypes.ValidatorSlashingInfo, error)

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

func SetGenesisStateToAppState

func SetGenesisStateToAppState(appState map[string]json.RawMessage, valSigningInfo map[string]hmTypes.ValidatorSigningInfo) (map[string]json.RawMessage, error)

SetGenesisStateToAppState sets state into app state

func SortAndRLPEncodeSlashInfos

func SortAndRLPEncodeSlashInfos(slashingInfos []*hmTypes.ValidatorSlashingInfo) ([]byte, error)

SortAndRLPEncodeSlashInfos - RLP encoded slashing infos

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the slashing genesis parameters

Types

type Equivocation

type Equivocation struct {
	Height           int64     `json:"height,omitempty"`
	Time             time.Time `json:"time"`
	Power            int64     `json:"power,omitempty"`
	ConsensusAddress []byte    `json:"address,omitempty"`
}

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() []byte

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 Evidence

type Evidence interface {
	Route() string
	Type() string
	String() string
	Hash() []byte
	ValidateBasic() error

	// The consensus address of the malicious validator at time of infraction
	GetConsensusAddress() sdk.ConsAddress

	// Height at which the infraction occurred
	GetHeight() int64

	// The total power of the malicious validator at time of infraction
	GetValidatorPower() int64

	// The total validator set power at time of infraction
	GetTotalPower() int64
}

Evidence defines the contract which concrete evidence types of misbehavior must implement.

func ConvertDuplicateVoteEvidence

func ConvertDuplicateVoteEvidence(dupVote abci.Evidence) Evidence

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

type GenesisState

type GenesisState struct {
	Params                Params                                  `json:"params" yaml:"params"`
	SigningInfos          map[string]hmTypes.ValidatorSigningInfo `json:"signing_infos" yaml:"signing_infos"`
	MissedBlocks          map[string][]MissedBlock                `json:"missed_blocks" yaml:"missed_blocks"`
	BufferValSlashingInfo []*hmTypes.ValidatorSlashingInfo        `json:"buffer_val_slash_info" yaml:"buffer_val_slash_info"`
	TickValSlashingInfo   []*hmTypes.ValidatorSlashingInfo        `json:"tick_val_slash_info" yaml:"tick_val_slash_info"`
	TickCount             uint64                                  `json:"tick_count" yaml:"tick_count"`
}

GenesisState - all slashing state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - default GenesisState used by Cosmos Hub

func GetGenesisStateFromAppState

func GetGenesisStateFromAppState(appState map[string]json.RawMessage) GenesisState

GetGenesisStateFromAppState returns staking GenesisState given raw application genesis state

func NewGenesisState

func NewGenesisState(
	params Params,
	signingInfos map[string]hmTypes.ValidatorSigningInfo,
	missedBlocks map[string][]MissedBlock,
	bufferValSlashingInfo []*hmTypes.ValidatorSlashingInfo,
	tickValSlashingInfo []*hmTypes.ValidatorSlashingInfo,
	tickCount uint64,
) GenesisState

NewGenesisState creates a new GenesisState object

type MissedBlock

type MissedBlock struct {
	Index  int64 `json:"index" yaml:"index"`
	Missed bool  `json:"missed" yaml:"missed"`
}

MissedBlock

func NewMissedBlock

func NewMissedBlock(index int64, missed bool) MissedBlock

NewMissedBlock creates a new MissedBlock instance

type ModifiedSlashInfo

type ModifiedSlashInfo struct {
	ID            hmTypes.ValidatorID `json:"ID"`
	SlashedAmount *big.Int            `json:"SlashedAmount"`
	IsJailed      []byte              `json:"IsJailed"`
}

type MsgSubmitEvidence

type MsgSubmitEvidence interface {
	sdk.Msg

	GetEvidence() Evidence
	GetSubmitter() sdk.AccAddress
}

MsgSubmitEvidence defines the specific interface a concrete message must implement in order to process submitted evidence. The concrete MsgSubmitEvidence must be defined at the application-level.

type MsgTick

type MsgTick struct {
	ID                uint64                `json:"id"`
	Proposer          types.HeimdallAddress `json:"proposer"`
	SlashingInfoBytes types.HexBytes        `json:"slashinginfobytes"`
}

TickMsg - struct for unjailing jailed validator

func NewMsgTick

func NewMsgTick(id uint64, proposer types.HeimdallAddress, slashingInfoBytes types.HexBytes) MsgTick

func (MsgTick) GetSideSignBytes

func (msg MsgTick) GetSideSignBytes() []byte

GetSideSignBytes returns side sign bytes

func (MsgTick) GetSignBytes

func (msg MsgTick) GetSignBytes() []byte

func (MsgTick) GetSigners

func (msg MsgTick) GetSigners() []sdk.AccAddress

GetSigners returns address of the signer

func (MsgTick) Route

func (msg MsgTick) Route() string

func (MsgTick) Type

func (msg MsgTick) Type() string

Type returns message type

func (MsgTick) ValidateBasic

func (msg MsgTick) ValidateBasic() sdk.Error

type MsgTickAck

type MsgTickAck struct {
	From          types.HeimdallAddress `json:"from"`
	ID            uint64                `json:"tick_id"`
	SlashedAmount uint64                `json:"slashed_amount"`
	TxHash        types.HeimdallHash    `json:"tx_hash"`
	LogIndex      uint64                `json:"log_index"`
	BlockNumber   uint64                `json:"block_number"`
}

func NewMsgTickAck

func NewMsgTickAck(from types.HeimdallAddress, id uint64, slashedAmount uint64, txHash types.HeimdallHash, logIndex uint64, blockNumber uint64) MsgTickAck

func (MsgTickAck) GetLogIndex

func (msg MsgTickAck) GetLogIndex() uint64

GetLogIndex Returns log index

func (MsgTickAck) GetSideSignBytes

func (msg MsgTickAck) GetSideSignBytes() []byte

GetSideSignBytes returns side sign bytes

func (MsgTickAck) GetSignBytes

func (msg MsgTickAck) GetSignBytes() []byte

func (MsgTickAck) GetSigners

func (msg MsgTickAck) GetSigners() []sdk.AccAddress

GetSigners returns address of the signer

func (MsgTickAck) GetTxHash

func (msg MsgTickAck) GetTxHash() types.HeimdallHash

GetTxHash Returns tx hash

func (MsgTickAck) Route

func (msg MsgTickAck) Route() string

func (MsgTickAck) Type

func (msg MsgTickAck) Type() string

Type returns message type

func (MsgTickAck) ValidateBasic

func (msg MsgTickAck) ValidateBasic() sdk.Error

type MsgUnjail

type MsgUnjail struct {
	From        types.HeimdallAddress `json:"from"`
	ID          hmTypes.ValidatorID   `json:"id"`
	TxHash      types.HeimdallHash    `json:"tx_hash"`
	LogIndex    uint64                `json:"log_index"`
	BlockNumber uint64                `json:"block_number"`
}

MsgUnjail - struct for unjailing jailed validator

func NewMsgUnjail

func NewMsgUnjail(from types.HeimdallAddress, id uint64, txHash types.HeimdallHash, logIndex uint64, blockNumber uint64) MsgUnjail

func (MsgUnjail) GetSignBytes

func (msg MsgUnjail) GetSignBytes() []byte

GetSignBytes gets the bytes for the message signer to sign on

func (MsgUnjail) GetSigners

func (msg MsgUnjail) GetSigners() []sdk.AccAddress

func (MsgUnjail) Route

func (msg MsgUnjail) Route() string

nolint

func (MsgUnjail) Type

func (msg MsgUnjail) Type() string

func (MsgUnjail) ValidateBasic

func (msg MsgUnjail) ValidateBasic() sdk.Error

ValidateBasic validity check for the AnteHandler

type Params

type Params struct {
	SignedBlocksWindow      int64         `json:"signed_blocks_window" yaml:"signed_blocks_window"`
	MinSignedPerWindow      sdk.Dec       `json:"min_signed_per_window" yaml:"min_signed_per_window"`
	DowntimeJailDuration    time.Duration `json:"downtime_jail_duration" yaml:"downtime_jail_duration"`
	SlashFractionDoubleSign sdk.Dec       `json:"slash_fraction_double_sign" yaml:"slash_fraction_double_sign"` // fraction amount to slash on double sign
	SlashFractionDowntime   sdk.Dec       `json:"slash_fraction_downtime" yaml:"slash_fraction_downtime"`       // fraction amount to slash on downtime
	SlashFractionLimit      sdk.Dec       `json:"slash_fraction_limit" yaml:"slash_fraction_limit"`             // if totalSlashedAmount crossed SlashFraction of totalValidatorPower, emit Slash-limit event
	JailFractionLimit       sdk.Dec       `json:"jail_fraction_limit" yaml:"jail_fraction_limit"`               // if slashedAmount crossed JailFraction of validatorPower, Jail him
	MaxEvidenceAge          time.Duration `json:"max_evidence_age" yaml:"max_evidence_age"`
	EnableSlashing          bool          `json:"enable_slashing" yaml:"enable_slashing"`
}

Params - used for initializing default parameter for slashing at genesis

func DefaultParams

func DefaultParams() Params

DefaultParams defines the parameters for this module

func NewParams

func NewParams(
	signedBlocksWindow int64, minSignedPerWindow sdk.Dec, downtimeJailDuration time.Duration,
	slashFractionDoubleSign, slashFractionDowntime sdk.Dec, slashFractionLimit sdk.Dec, jailFractionLimit sdk.Dec, maxEvidenceAge time.Duration, enableSlashing bool,
) Params

NewParams creates a new Params object

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() subspace.ParamSetPairs

ParamSetPairs - Implements params.ParamSet

func (Params) String

func (p Params) String() string

String implements the stringer interface for Params

type QuerySigningInfoParams

type QuerySigningInfoParams struct {
	ValidatorID hmTypes.ValidatorID
}

QuerySigningInfoParams defines the params for the following queries: - 'custom/slashing/signingInfo'

func NewQuerySigningInfoParams

func NewQuerySigningInfoParams(valID hmTypes.ValidatorID) QuerySigningInfoParams

NewQuerySigningInfoParams creates a new QuerySigningInfoParams instance

type QuerySigningInfosParams

type QuerySigningInfosParams struct {
	Page, Limit int
}

QuerySigningInfosParams defines the params for the following queries: - 'custom/slashing/signingInfos'

func NewQuerySigningInfosParams

func NewQuerySigningInfosParams(page, limit int) QuerySigningInfosParams

NewQuerySigningInfosParams creates a new QuerySigningInfosParams instance

type QuerySlashingInfoParams

type QuerySlashingInfoParams struct {
	ValidatorID hmTypes.ValidatorID
}

QuerySlashingInfoParams defines the params for the following queries: - 'custom/slashing/slashingInfo'

func NewQuerySlashingInfoParams

func NewQuerySlashingInfoParams(valID hmTypes.ValidatorID) QuerySlashingInfoParams

NewQuerySlashingInfoParams creates a new QuerySlashingInfoParams instance

type QuerySlashingInfosParams

type QuerySlashingInfosParams struct {
	Page, Limit int
}

QuerySlashingInfosParams defines the params for the following queries: - 'custom/slashing/slashingInfos'

func NewQuerySlashingInfosParams

func NewQuerySlashingInfosParams(page, limit int) QuerySlashingInfosParams

NewQuerySlashingInfosParams creates a new QuerySlashingInfosParams instance

type QuerySlashingSequenceParams

type QuerySlashingSequenceParams struct {
	TxHash   string
	LogIndex uint64
}

QuerySlashingSequenceParams defines the params for querying an account Sequence.

func NewQuerySlashingSequenceParams

func NewQuerySlashingSequenceParams(txHash string, logIndex uint64) QuerySlashingSequenceParams

NewQuerySlashingSequenceParams creates a new instance of QuerySlashingSequenceParams.

type QueryTickSlashingInfosParams

type QueryTickSlashingInfosParams struct {
	Page, Limit int
}

QueryTickSlashingInfosParams defines the params for the following queries: - 'custom/slashing/tick_slash_infos'

func NewQueryTickSlashingInfosParams

func NewQueryTickSlashingInfosParams(page, limit int) QueryTickSlashingInfosParams

NewQueryTickSlashingInfosParams creates a new QueryTickSlashingInfosParams instance

Jump to

Keyboard shortcuts

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