Documentation ¶
Overview ¶
noalias
noalias DONTCOVER
Index ¶
- Constants
- Variables
- func GetAddrPubkeyRelationKey(address []byte) []byte
- func GetValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte
- func GetValidatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte
- func GetValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress)
- func GetValidatorSigningInfoKey(v sdk.ConsAddress) []byte
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type AccountKeeper
- type GenesisState
- type MissedBlock
- type MsgUnjail
- type ParamSubspace
- type Params
- type QuerySigningInfoParams
- type QuerySigningInfosParams
- type StakingHooks
- type StakingKeeper
- type ValidatorSigningInfo
Constants ¶
const ( EventTypeSlash = "slash" EventTypeLiveness = "liveness" AttributeKeyAddress = "address" AttributeKeyHeight = "height" AttributeKeyPower = "power" AttributeKeyReason = "reason" AttributeKeyJailed = "jailed" AttributeKeyMissedBlocks = "missed_blocks" AttributeValueDoubleSign = "double_sign" AttributeValueMissingSignature = "missing_signature" AttributeValueCategory = ModuleName )
Slashing module event types
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 )
const ( DefaultParamspace = ModuleName DefaultSignedBlocksWindow = int64(1800) // mainnet: 100 DefaultDowntimeJailDuration = 60 * 10 * time.Second //devnet: time.Second * 60 )
Default parameter namespace
const ( QueryParameters = "parameters" QuerySigningInfo = "signingInfo" QuerySigningInfos = "signingInfos" )
Query endpoints supported by the slashing querier
Variables ¶
var ( ErrNoValidatorForAddress = sdkerrors.Register(ModuleName, 1, "address is not associated with any known validator") ErrBadValidatorAddr = sdkerrors.Register(ModuleName, 2, "validator does not exist for that address") ErrValidatorJailed = sdkerrors.Register(ModuleName, 3, "validator still jailed; cannot be unjailed") ErrValidatorNotJailed = sdkerrors.Register(ModuleName, 4, "validator not jailed; cannot be unjailed") ErrMissingSelfDelegation = sdkerrors.Register(ModuleName, 5, "validator has no self-delegation; cannot be unjailed") ErrSelfDelegationTooLowToUnjail = sdkerrors.Register(ModuleName, 6, "validator's self delegation less than minimum; cannot be unjailed") ErrNoSigningInfoFound = sdkerrors.Register(ModuleName, 7, "no validator signing info found") )
x/slashing module sentinel errors
var ( ValidatorSigningInfoKey = []byte{0x01} // Prefix for signing info ValidatorMissedBlockBitArrayKey = []byte{0x02} // Prefix for missed block bit array AddrPubkeyRelationKey = []byte{0x03} // Prefix for address-pubkey relation )
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
var ( DefaultMinSignedPerWindow = sdk.NewDecWithPrec(5, 1) DefaultSlashFractionDoubleSign = sdk.NewDec(1).Quo(sdk.NewDec(20)) DefaultSlashFractionDowntime = sdk.NewDec(1).Quo(sdk.NewDec(100)) )
var ( KeySignedBlocksWindow = []byte("SignedBlocksWindow") KeyMinSignedPerWindow = []byte("MinSignedPerWindow") KeyDowntimeJailDuration = []byte("DowntimeJailDuration") KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign") KeySlashFractionDowntime = []byte("SlashFractionDowntime") )
Parameter store keys
var ModuleCdc *codec.Codec
ModuleCdc defines the module codec
Functions ¶
func GetAddrPubkeyRelationKey ¶
GetAddrPubkeyRelationKey gets pubkey relation key used to get the pubkey from the address
func GetValidatorMissedBlockBitArrayKey ¶
func GetValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte
GetValidatorMissedBlockBitArrayKey - stored by *Consensus* address (not operator address)
func GetValidatorMissedBlockBitArrayPrefixKey ¶
func GetValidatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte
GetValidatorMissedBlockBitArrayPrefixKey - stored by *Consensus* address (not operator address)
func GetValidatorSigningInfoAddress ¶
func GetValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress)
GetValidatorSigningInfoAddress - extract the address from a validator signing info key
func GetValidatorSigningInfoKey ¶
func GetValidatorSigningInfoKey(v sdk.ConsAddress) []byte
GetValidatorSigningInfoKey - stored by *Consensus* address (not operator address)
func RegisterCodec ¶
RegisterCodec registers concrete types on codec
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the slashing genesis parameters
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) authexported.Account IterateAccounts(ctx sdk.Context, process func(authexported.Account) (stop bool)) }
AccountKeeper expected account keeper
type GenesisState ¶
type GenesisState struct { Params Params `json:"params" yaml:"params"` SigningInfos map[string]ValidatorSigningInfo `json:"signing_infos" yaml:"signing_infos"` MissedBlocks map[string][]MissedBlock `json:"missed_blocks" yaml:"missed_blocks"` }
GenesisState - all slashing state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState - default GenesisState used by Cosmos Hub
func NewGenesisState ¶
func NewGenesisState( params Params, signingInfos map[string]ValidatorSigningInfo, missedBlocks map[string][]MissedBlock, ) 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 MsgUnjail ¶
type MsgUnjail struct {
ValidatorAddr sdk.ValAddress `json:"address" yaml:"address"` // address of the validator operator
}
MsgUnjail - struct for unjailing jailed validator
func NewMsgUnjail ¶
func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail
NewMsgUnjail creates a new MsgUnjail instance
func (MsgUnjail) GetSignBytes ¶
GetSignBytes gets the bytes for the message signer to sign on
func (MsgUnjail) GetSigners ¶
func (msg MsgUnjail) GetSigners() []sdk.AccAddress
func (MsgUnjail) ValidateBasic ¶
ValidateBasic validity check for the AnteHandler
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) }
ParamSubspace defines the expected Subspace interfacace
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"` SlashFractionDowntime sdk.Dec `json:"slash_fraction_downtime" yaml:"slash_fraction_downtime"` }
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, ) Params
NewParams creates a new Params object
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs - Implements params.ParamSet
type QuerySigningInfoParams ¶
type QuerySigningInfoParams struct {
ConsAddress sdk.ConsAddress
}
QuerySigningInfoParams defines the params for the following queries: - 'custom/slashing/signingInfo'
func NewQuerySigningInfoParams ¶
func NewQuerySigningInfoParams(consAddr sdk.ConsAddress) 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 StakingHooks ¶
type StakingHooks interface { AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is bonded }
StakingHooks event hooks for staking validator object (noalias)
type StakingKeeper ¶
type StakingKeeper interface { // iterate through validators by operator address, execute func for each validator IterateValidators(sdk.Context, func(index int64, validator stakingexported.ValidatorI) (stop bool)) Validator(sdk.Context, sdk.ValAddress) stakingexported.ValidatorI // get a particular validator by operator address ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingexported.ValidatorI // get a particular validator by consensus address // slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) Jail(sdk.Context, sdk.ConsAddress) // jail a validator Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator // Delegation allows for getting a particular delegation for a given validator // and delegator outside the scope of the staking module. Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingexported.DelegationI // MaxValidators returns the maximum amount of bonded validators MaxValidators(sdk.Context) uint16 }
StakingKeeper expected staking keeper
type ValidatorSigningInfo ¶
type ValidatorSigningInfo struct { Address sdk.ConsAddress `json:"address" yaml:"address"` // validator consensus address StartHeight int64 `json:"start_height" yaml:"start_height"` // height at which validator was first a candidate OR was unjailed IndexOffset int64 `json:"index_offset" yaml:"index_offset"` // index offset into signed block bit array JailedUntil time.Time `json:"jailed_until" yaml:"jailed_until"` // timestamp validator cannot be unjailed until Tombstoned bool `json:"tombstoned" yaml:"tombstoned"` // whether or not a validator has been tombstoned (killed out of validator set) MissedBlocksCounter int64 `json:"missed_blocks_counter" yaml:"missed_blocks_counter"` // missed blocks counter (to avoid scanning the array every time) }
ValidatorSigningInfo defines the signing info for a validator
func NewValidatorSigningInfo ¶
func NewValidatorSigningInfo( condAddr sdk.ConsAddress, startHeight, indexOffset int64, jailedUntil time.Time, tombstoned bool, missedBlocksCounter int64, ) ValidatorSigningInfo
NewValidatorSigningInfo creates a new ValidatorSigningInfo instance
func (ValidatorSigningInfo) String ¶
func (i ValidatorSigningInfo) String() string
String implements the stringer interface for ValidatorSigningInfo