Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, sk Keeper) (tags sdk.Tags)
- func ErrBadValidatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrMissingSelfDelegation(codespace sdk.CodespaceType) sdk.Error
- func ErrNoValidatorForAddress(codespace sdk.CodespaceType) sdk.Error
- func ErrValidatorJailed(codespace sdk.CodespaceType) sdk.Error
- func ErrValidatorNotJailed(codespace sdk.CodespaceType) sdk.Error
- func GetValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte
- func GetValidatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte
- func GetValidatorSigningInfoKey(v sdk.ConsAddress) []byte
- func GetValidatorSlashingPeriodKey(v sdk.ConsAddress, startHeight int64) []byte
- func GetValidatorSlashingPeriodPrefix(v sdk.ConsAddress) []byte
- func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState, sdata types.GenesisState)
- func NewHandler(k Keeper) sdk.Handler
- func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) stake.MsgCreateValidator
- func ParamTypeTable() params.TypeTable
- func RegisterCodec(cdc *codec.Codec)
- type CodeType
- type GenesisState
- type Hooks
- func (h Hooks) OnDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)
- func (h Hooks) OnDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)
- func (h Hooks) OnDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)
- func (h Hooks) OnValidatorBeginUnbonding(ctx sdk.Context, address sdk.ConsAddress, operator sdk.ValAddress)
- func (h Hooks) OnValidatorBonded(ctx sdk.Context, address sdk.ConsAddress, operator sdk.ValAddress)
- func (h Hooks) OnValidatorCreated(_ sdk.Context, _ sdk.ValAddress)
- func (h Hooks) OnValidatorModified(_ sdk.Context, _ sdk.ValAddress)
- func (h Hooks) OnValidatorRemoved(_ sdk.Context, _ sdk.ValAddress)
- type Keeper
- func (k Keeper) AddValidators(ctx sdk.Context, vals []abci.ValidatorUpdate)
- func (k Keeper) DoubleSignUnbondDuration(ctx sdk.Context) (res time.Duration)
- func (k Keeper) DowntimeUnbondDuration(ctx sdk.Context) (res time.Duration)
- func (k Keeper) Hooks() Hooks
- func (k Keeper) MaxEvidenceAge(ctx sdk.Context) (res time.Duration)
- func (k Keeper) MinSignedPerWindow(ctx sdk.Context) int64
- func (k Keeper) SignedBlocksWindow(ctx sdk.Context) (res int64)
- func (k Keeper) SlashFractionDoubleSign(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) SlashFractionDowntime(ctx sdk.Context) (res sdk.Dec)
- type MsgUnjail
- type Params
- type ValidatorSigningInfo
- type ValidatorSlashingPeriod
- type ValidatorSlashingPeriodValue
Constants ¶
const (
DefaultParamspace = "slashing"
)
Default parameter namespace
const MsgRoute = "slashing"
name to identify transaction types
Variables ¶
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
var ( KeyMaxEvidenceAge = []byte("MaxEvidenceAge") KeySignedBlocksWindow = []byte("SignedBlocksWindow") KeyMinSignedPerWindow = []byte("MinSignedPerWindow") KeyDoubleSignUnbondDuration = []byte("DoubleSignUnbondDuration") KeyDowntimeUnbondDuration = []byte("DowntimeUnbondDuration") KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign") KeySlashFractionDowntime = []byte("SlashFractionDowntime") )
Parameter store key
Functions ¶
func BeginBlocker ¶
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 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 NewTestMsgCreateValidator ¶ added in v0.25.0
func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) stake.MsgCreateValidator
func ParamTypeTable ¶ added in v0.25.0
ParamTypeTable for slashing module
func RegisterCodec ¶ added in v0.25.0
Register concrete types on codec codec
Types ¶
type GenesisState ¶ added in v0.25.0
type GenesisState struct {
Params Params
}
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
type Hooks ¶ added in v0.25.0
type Hooks struct {
// contains filtered or unexported fields
}
Wrapper struct
func (Hooks) OnDelegationCreated ¶ added in v0.25.0
func (h Hooks) OnDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)
func (Hooks) OnDelegationRemoved ¶ added in v0.25.0
func (h Hooks) OnDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)
func (Hooks) OnDelegationSharesModified ¶ added in v0.25.0
func (h Hooks) OnDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress)
func (Hooks) OnValidatorBeginUnbonding ¶ added in v0.25.0
func (h Hooks) OnValidatorBeginUnbonding(ctx sdk.Context, address sdk.ConsAddress, operator sdk.ValAddress)
Implements sdk.ValidatorHooks
func (Hooks) OnValidatorBonded ¶ added in v0.25.0
func (h Hooks) OnValidatorBonded(ctx sdk.Context, address sdk.ConsAddress, operator sdk.ValAddress)
Implements sdk.ValidatorHooks
func (Hooks) OnValidatorCreated ¶ added in v0.25.0
func (h Hooks) OnValidatorCreated(_ sdk.Context, _ sdk.ValAddress)
nolint - unused hooks
func (Hooks) OnValidatorModified ¶ added in v0.25.0
func (h Hooks) OnValidatorModified(_ sdk.Context, _ sdk.ValAddress)
func (Hooks) OnValidatorRemoved ¶ added in v0.25.0
func (h Hooks) OnValidatorRemoved(_ sdk.Context, _ sdk.ValAddress)
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) AddValidators ¶ added in v0.24.0
func (k Keeper) AddValidators(ctx sdk.Context, vals []abci.ValidatorUpdate)
AddValidators adds the validators to the keepers validator addr to pubkey mapping.
func (Keeper) DoubleSignUnbondDuration ¶ added in v0.24.0
Double-sign unbond duration
func (Keeper) DowntimeUnbondDuration ¶ added in v0.24.0
Downtime unbond duration
func (Keeper) MaxEvidenceAge ¶ added in v0.24.0
MaxEvidenceAge - Max age for evidence - 21 days (3 weeks) MaxEvidenceAge = 60 * 60 * 24 * 7 * 3
func (Keeper) MinSignedPerWindow ¶ added in v0.24.0
Downtime slashing thershold - default 50% of the SignedBlocksWindow
func (Keeper) SignedBlocksWindow ¶ added in v0.24.0
SignedBlocksWindow - sliding window for downtime slashing
func (Keeper) SlashFractionDoubleSign ¶ added in v0.24.0
SlashFractionDoubleSign - currently default 5%
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
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) ValidateBasic ¶ added in v0.25.0
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"` DoubleSignUnbondDuration time.Duration `json:"double-sign-unbond-duration"` DowntimeUnbondDuration time.Duration `json:"downtime-unbond-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
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 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, missedBlocksCounter int64) ValidatorSigningInfo
Construct a new `ValidatorSigningInfo` struct
func (ValidatorSigningInfo) HumanReadableString ¶
func (i ValidatorSigningInfo) HumanReadableString() string
Return human readable signing info
type ValidatorSlashingPeriod ¶ added in v0.25.0
type ValidatorSlashingPeriod struct { ValidatorAddr sdk.ConsAddress `json:"validator_addr"` // validator which this slashing period is for StartHeight int64 `json:"start_height"` // starting height of the slashing period EndHeight int64 `json:"end_height"` // ending height of the slashing period, or sentinel value of 0 for in-progress SlashedSoFar sdk.Dec `json:"slashed_so_far"` // fraction of validator stake slashed so far in this slashing period }
Slashing period for a validator
func NewValidatorSlashingPeriod ¶ added in v0.25.0
func NewValidatorSlashingPeriod(startHeight int64, endHeight int64, slashedSoFar sdk.Dec) ValidatorSlashingPeriod
Construct a new `ValidatorSlashingPeriod` struct
func (ValidatorSlashingPeriod) HumanReadableString ¶ added in v0.25.0
func (p ValidatorSlashingPeriod) HumanReadableString() string
Return human readable slashing period
type ValidatorSlashingPeriodValue ¶ added in v0.25.0
type ValidatorSlashingPeriodValue struct { EndHeight int64 `json:"end_height"` SlashedSoFar sdk.Dec `json:"slashed_so_far"` }
Value part of slashing period (validator address & start height are stored in the key)