slashing

package
v0.30.0-dev0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Overview

nolint

nolint

Index

Constants

View Source
const (
	// StoreKey is the store key string for slashing
	StoreKey = "slashing"

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

	// QuerierRoute is the querier route for slashing
	QuerierRoute = "slashing"
)
View Source
const (
	DefaultParamspace = "slashing"
)

Default parameter namespace

View Source
const (
	QueryParameters = "parameters"
)

Query endpoints supported by the slashing querier

Variables

View Source
var (
	ValidatorSigningInfoKey         = []byte{0x01} // Prefix for signing info
	ValidatorMissedBlockBitArrayKey = []byte{0x02} // Prefix for missed block bit array
	ValidatorSlashingPeriodKey      = []byte{0x03} // Prefix for slashing period
	AddrPubkeyRelationKey           = []byte{0x04} // Prefix for address-pubkey relation
)

key prefix bytes

View Source
var (
	KeyMaxEvidenceAge          = []byte("MaxEvidenceAge")
	KeySignedBlocksWindow      = []byte("SignedBlocksWindow")
	KeyMinSignedPerWindow      = []byte("MinSignedPerWindow")
	KeyDowntimeJailDuration    = []byte("DowntimeJailDuration")
	KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign")
	KeySlashFractionDowntime   = []byte("SlashFractionDowntime")
)

Parameter store key

View Source
var (
	DoubleSignJailEndTime = time.Unix(253402300799, 0)
)

The Double Sign Jail period ends at Max Time supported by Amino (Dec 31, 9999 - 23:59:59 GMT)

Functions

func BeginBlocker

func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, sk Keeper) sdk.Tags

slashing begin block functionality

func ErrBadValidatorAddr

func ErrBadValidatorAddr(codespace sdk.CodespaceType) sdk.Error

func ErrMissingSelfDelegation added in v0.25.0

func ErrMissingSelfDelegation(codespace sdk.CodespaceType) sdk.Error

func ErrNoValidatorForAddress

func ErrNoValidatorForAddress(codespace sdk.CodespaceType) sdk.Error

func ErrValidatorJailed

func ErrValidatorJailed(codespace sdk.CodespaceType) sdk.Error

func ErrValidatorNotJailed added in v0.25.0

func ErrValidatorNotJailed(codespace sdk.CodespaceType) sdk.Error

func GetValidatorMissedBlockBitArrayKey added in v0.25.0

func GetValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte

stored by *Tendermint* address (not operator address)

func GetValidatorMissedBlockBitArrayPrefixKey added in v0.25.0

func GetValidatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte

stored by *Tendermint* address (not operator address)

func GetValidatorSigningInfoAddress added in v0.26.0

func GetValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress)

extract the address from a validator signing info key

func GetValidatorSigningInfoKey

func GetValidatorSigningInfoKey(v sdk.ConsAddress) []byte

stored by *Tendermint* address (not operator address)

func GetValidatorSlashingPeriodKey added in v0.25.0

func GetValidatorSlashingPeriodKey(v sdk.ConsAddress, startHeight int64) []byte

stored by *Tendermint* address (not operator address) followed by start height

func GetValidatorSlashingPeriodPrefix added in v0.25.0

func GetValidatorSlashingPeriodPrefix(v sdk.ConsAddress) []byte

stored by *Tendermint* address (not operator address)

func InitGenesis added in v0.24.0

func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState, sdata types.GenesisState)

InitGenesis initialize default parameters and the keeper's address to pubkey map

func NewHandler

func NewHandler(k Keeper) sdk.Handler

func NewQuerier added in v0.28.1

func NewQuerier(k Keeper, cdc *codec.Codec) sdk.Querier

NewQuerier creates a new querier for slashing clients.

func NewTestMsgCreateValidator added in v0.25.0

func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) staking.MsgCreateValidator

func ParamTypeTable added in v0.25.0

func ParamTypeTable() params.TypeTable

ParamTypeTable for slashing module

func RegisterCodec added in v0.25.0

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func ValidateGenesis added in v0.28.0

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the slashing genesis parameters

Types

type CodeType

type CodeType = sdk.CodeType

Local code type

const (
	// Default slashing codespace
	DefaultCodespace sdk.CodespaceType = "SLASH"

	CodeInvalidValidator      CodeType = 101
	CodeValidatorJailed       CodeType = 102
	CodeValidatorNotJailed    CodeType = 103
	CodeMissingSelfDelegation CodeType = 104
)

type GenesisState added in v0.25.0

type GenesisState struct {
	Params       Params                          `json:"params"`
	SigningInfos map[string]ValidatorSigningInfo `json:"signing_infos"`
	MissedBlocks map[string][]MissedBlock        `json:"missed_blocks"`
}

GenesisState - all slashing state that must be provided at genesis

func DefaultGenesisState added in v0.25.0

func DefaultGenesisState() GenesisState

HubDefaultGenesisState - default GenesisState used by Cosmos Hub

func ExportGenesis added in v0.26.0

func ExportGenesis(ctx sdk.Context, keeper Keeper) (data GenesisState)

ExportGenesis writes the current store values to a genesis file, which can be imported again with InitGenesis

type Hooks added in v0.25.0

type Hooks struct {
	// contains filtered or unexported fields
}

Wrapper struct

func (Hooks) AfterDelegationModified added in v0.30.0

func (h Hooks) AfterDelegationModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)

func (Hooks) AfterValidatorBeginUnbonding added in v0.30.0

func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)

nolint - unused hooks

func (Hooks) AfterValidatorBonded added in v0.30.0

func (h Hooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

Implements sdk.ValidatorHooks

func (Hooks) AfterValidatorCreated added in v0.30.0

func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)

Implements sdk.ValidatorHooks

func (Hooks) AfterValidatorPowerDidChange added in v0.30.0

func (h Hooks) AfterValidatorPowerDidChange(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)

func (Hooks) AfterValidatorRemoved added in v0.30.0

func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, _ sdk.ValAddress)

Implements sdk.ValidatorHooks

func (Hooks) BeforeDelegationCreated added in v0.30.0

func (h Hooks) BeforeDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)

func (Hooks) BeforeDelegationRemoved added in v0.30.0

func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)

func (Hooks) BeforeDelegationSharesModified added in v0.30.0

func (h Hooks) BeforeDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)

func (Hooks) BeforeValidatorModified added in v0.30.0

func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress)

func (Hooks) BeforeValidatorSlashed added in v0.30.0

func (h Hooks) BeforeValidatorSlashed(_ sdk.Context, _ sdk.ValAddress, _ sdk.Dec)

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper of the slashing store

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, vs sdk.ValidatorSet, paramspace params.Subspace, codespace sdk.CodespaceType) Keeper

NewKeeper creates a slashing keeper

func (Keeper) AfterValidatorBonded added in v0.30.0

func (k Keeper) AfterValidatorBonded(ctx sdk.Context, address sdk.ConsAddress, _ sdk.ValAddress)

func (Keeper) AfterValidatorCreated added in v0.30.0

func (k Keeper) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)

When a validator is created, add the address-pubkey relation.

func (Keeper) AfterValidatorRemoved added in v0.30.0

func (k Keeper) AfterValidatorRemoved(ctx sdk.Context, address sdk.ConsAddress)

When a validator is removed, delete the address-pubkey relation.

func (Keeper) DowntimeJailDuration added in v0.30.0

func (k Keeper) DowntimeJailDuration(ctx sdk.Context) (res time.Duration)

Downtime unbond duration

func (Keeper) GetParams added in v0.28.1

func (k Keeper) GetParams(ctx sdk.Context) (params Params)

GetParams returns the total set of slashing parameters.

func (Keeper) Hooks added in v0.25.0

func (k Keeper) Hooks() Hooks

Return the wrapper struct

func (Keeper) IterateValidatorMissedBlockBitArray added in v0.27.0

func (k Keeper) IterateValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.ConsAddress, handler func(index int64, missed bool) (stop bool))

Stored by *validator* address (not operator address)

func (Keeper) IterateValidatorSigningInfos added in v0.27.0

func (k Keeper) IterateValidatorSigningInfos(ctx sdk.Context, handler func(address sdk.ConsAddress, info ValidatorSigningInfo) (stop bool))

Stored by *validator* address (not operator address)

func (Keeper) MaxEvidenceAge added in v0.24.0

func (k Keeper) MaxEvidenceAge(ctx sdk.Context) (res time.Duration)

MaxEvidenceAge - Max age for evidence - 21 days (3 weeks) MaxEvidenceAge = 60 * 60 * 24 * 7 * 3

func (Keeper) MinSignedPerWindow added in v0.24.0

func (k Keeper) MinSignedPerWindow(ctx sdk.Context) int64

Downtime slashing threshold - default 50% of the SignedBlocksWindow

func (Keeper) SetValidatorSigningInfo added in v0.27.0

func (k Keeper) SetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress, info ValidatorSigningInfo)

Stored by *validator* address (not operator address)

func (Keeper) SignedBlocksWindow added in v0.24.0

func (k Keeper) SignedBlocksWindow(ctx sdk.Context) (res int64)

SignedBlocksWindow - sliding window for downtime slashing

func (Keeper) SlashFractionDoubleSign added in v0.24.0

func (k Keeper) SlashFractionDoubleSign(ctx sdk.Context) (res sdk.Dec)

SlashFractionDoubleSign - currently default 5%

func (Keeper) SlashFractionDowntime added in v0.24.0

func (k Keeper) SlashFractionDowntime(ctx sdk.Context) (res sdk.Dec)

SlashFractionDowntime - currently default 1%

type MissedBlock added in v0.26.0

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

MissedBlock

type MsgUnjail added in v0.25.0

type MsgUnjail struct {
	ValidatorAddr sdk.ValAddress `json:"address"` // address of the validator operator
}

MsgUnjail - struct for unjailing jailed validator

func NewMsgUnjail added in v0.25.0

func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail

func (MsgUnjail) GetSignBytes added in v0.25.0

func (msg MsgUnjail) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgUnjail) GetSigners added in v0.25.0

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

func (MsgUnjail) Route added in v0.25.0

func (msg MsgUnjail) Route() string

nolint

func (MsgUnjail) Type added in v0.25.0

func (msg MsgUnjail) Type() string

func (MsgUnjail) ValidateBasic added in v0.25.0

func (msg MsgUnjail) ValidateBasic() sdk.Error

quick validity check

type Params added in v0.25.0

type Params struct {
	MaxEvidenceAge          time.Duration `json:"max-evidence-age"`
	SignedBlocksWindow      int64         `json:"signed-blocks-window"`
	MinSignedPerWindow      sdk.Dec       `json:"min-signed-per-window"`
	DowntimeJailDuration    time.Duration `json:"downtime-jail-duration"`
	SlashFractionDoubleSign sdk.Dec       `json:"slash-fraction-double-sign"`
	SlashFractionDowntime   sdk.Dec       `json:"slash-fraction-downtime"`
}

Params - used for initializing default parameter for slashing at genesis

func DefaultParams added in v0.25.0

func DefaultParams() Params

Default parameters used by Cosmos Hub

func (*Params) KeyValuePairs added in v0.25.0

func (p *Params) KeyValuePairs() params.KeyValuePairs

Implements params.ParamStruct

func (Params) String added in v0.30.0

func (p Params) String() string

type ValidatorSigningInfo

type ValidatorSigningInfo struct {
	StartHeight         int64     `json:"start_height"`          // height at which validator was first a candidate OR was unjailed
	IndexOffset         int64     `json:"index_offset"`          // index offset into signed block bit array
	JailedUntil         time.Time `json:"jailed_until"`          // timestamp validator cannot be unjailed until
	Tombstoned          bool      `json:"tombstoned"`            // whether or not a validator has been tombstoned (killed out of validator set)
	MissedBlocksCounter int64     `json:"missed_blocks_counter"` // missed blocks counter (to avoid scanning the array every time)
}

Signing info for a validator

func NewValidatorSigningInfo added in v0.19.0

func NewValidatorSigningInfo(startHeight int64, indexOffset int64, jailedUntil time.Time, tombstoned bool, missedBlocksCounter int64) ValidatorSigningInfo

Construct a new `ValidatorSigningInfo` struct

func (ValidatorSigningInfo) String added in v0.30.0

func (i ValidatorSigningInfo) String() string

Return human readable signing info

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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