Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func ErrBadValidatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrMissingSelfDelegation(codespace sdk.CodespaceType) sdk.Error
- func ErrNoSigningInfoFound(codespace sdk.CodespaceType, consAddr sdk.ConsAddress) sdk.Error
- func ErrNoValidatorForAddress(codespace sdk.CodespaceType) sdk.Error
- func ErrSelfDelegationTooLowToUnjail(codespace sdk.CodespaceType) sdk.Error
- func ErrValidatorJailed(codespace sdk.CodespaceType) sdk.Error
- func ErrValidatorNotJailed(codespace sdk.CodespaceType) sdk.Error
- 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 CodeType
- type GenesisState
- type MissedBlock
- type MsgUnjail
- type Params
- type QuerySigningInfoParams
- type QuerySigningInfosParams
- type StakingHooks
- type StakingKeeper
- type ValidatorSigningInfo
Constants ¶
const ( // module name 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 ( QueryParameters = "parameters" QuerySigningInfo = "signingInfo" QuerySigningInfos = "signingInfos" )
Query endpoints supported by the slashing querier
const ( DefaultParamspace = ModuleName DefaultMaxEvidenceAge = 60 * 2 * time.Second DefaultSignedBlocksWindow = int64(100) DefaultDowntimeJailDuration = 60 * 10 * time.Second )
Default parameter namespace
Variables ¶
var ( 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
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 ( DoubleSignJailEndTime = time.Unix(253402300799, 0) DefaultMinSignedPerWindow = sdk.NewDecWithPrec(5, 1) DefaultSlashFractionDoubleSign = sdk.NewDec(1).Quo(sdk.NewDec(20)) DefaultSlashFractionDowntime = sdk.NewDec(1).Quo(sdk.NewDec(100)) )
The Double Sign Jail period ends at Max Time supported by Amino (Dec 31, 9999 - 23:59:59 GMT)
var ( KeyMaxEvidenceAge = []byte("MaxEvidenceAge") KeySignedBlocksWindow = []byte("SignedBlocksWindow") KeyMinSignedPerWindow = []byte("MinSignedPerWindow") KeyDowntimeJailDuration = []byte("DowntimeJailDuration") KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign") KeySlashFractionDowntime = []byte("SlashFractionDowntime") )
Parameter store keys
var ModuleCdc *codec.Codec
module codec
Functions ¶
func ErrBadValidatorAddr ¶
func ErrBadValidatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrMissingSelfDelegation ¶
func ErrMissingSelfDelegation(codespace sdk.CodespaceType) sdk.Error
func ErrNoSigningInfoFound ¶
func ErrNoSigningInfoFound(codespace sdk.CodespaceType, consAddr sdk.ConsAddress) sdk.Error
func ErrNoValidatorForAddress ¶
func ErrNoValidatorForAddress(codespace sdk.CodespaceType) sdk.Error
func ErrSelfDelegationTooLowToUnjail ¶
func ErrSelfDelegationTooLowToUnjail(codespace sdk.CodespaceType) sdk.Error
func ErrValidatorJailed ¶
func ErrValidatorJailed(codespace sdk.CodespaceType) sdk.Error
func ErrValidatorNotJailed ¶
func ErrValidatorNotJailed(codespace sdk.CodespaceType) sdk.Error
func GetAddrPubkeyRelationKey ¶ added in v0.36.0
get pubkey relation key used to get the pubkey from the address
func GetValidatorMissedBlockBitArrayKey ¶ added in v0.36.0
func GetValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte
stored by *Consensus* address (not operator address)
func GetValidatorMissedBlockBitArrayPrefixKey ¶ added in v0.36.0
func GetValidatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte
stored by *Consensus* address (not operator address)
func GetValidatorSigningInfoAddress ¶ added in v0.36.0
func GetValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress)
extract the address from a validator signing info key
func GetValidatorSigningInfoKey ¶ added in v0.36.0
func GetValidatorSigningInfoKey(v sdk.ConsAddress) []byte
stored by *Consensus* address (not operator address)
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the slashing genesis parameters
Types ¶
type AccountKeeper ¶
type AccountKeeper interface {
IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool))
}
AccountKeeper expected account keeper
type CodeType ¶ added in v0.36.0
Local code type
const ( // Default slashing codespace DefaultCodespace sdk.CodespaceType = ModuleName CodeInvalidValidator CodeType = 101 CodeValidatorJailed CodeType = 102 CodeValidatorNotJailed CodeType = 103 CodeMissingSelfDelegation CodeType = 104 CodeSelfDelegationTooLow CodeType = 105 CodeMissingSigningInfo CodeType = 106 )
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
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
func (MsgUnjail) GetSignBytes ¶
get the bytes for the message signer to sign on
func (MsgUnjail) GetSigners ¶
func (msg MsgUnjail) GetSigners() []sdk.AccAddress
func (MsgUnjail) ValidateBasic ¶
quick validity check
type Params ¶
type Params struct { MaxEvidenceAge time.Duration `json:"max_evidence_age" yaml:"max_evidence_age"` 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 NewParams ¶
func NewParams(maxEvidenceAge time.Duration, signedBlocksWindow int64, minSignedPerWindow sdk.Dec, downtimeJailDuration time.Duration, slashFractionDoubleSign sdk.Dec, slashFractionDowntime sdk.Dec) Params
NewParams creates a new Params object
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.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
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
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
type StakingKeeper ¶
type StakingKeeper interface { // iterate through validators by operator address, execute func for each validator IterateValidators(sdk.Context, func(index int64, validator exported.ValidatorI) (stop bool)) Validator(sdk.Context, sdk.ValAddress) exported.ValidatorI // get a particular validator by operator address ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) exported.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) exported.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) }
Signing info for a validator
func NewValidatorSigningInfo ¶
func NewValidatorSigningInfo( condAddr sdk.ConsAddress, startHeight, indexOffset int64, jailedUntil time.Time, tombstoned bool, missedBlocksCounter int64, ) ValidatorSigningInfo
Construct a new `ValidatorSigningInfo` struct
func (ValidatorSigningInfo) String ¶
func (i ValidatorSigningInfo) String() string
Return human readable signing info