Documentation
¶
Overview ¶
noalias
noalias DONTCOVER
Index ¶
- Constants
- Variables
- func AddrPubkeyRelationKey(address []byte) []byte
- func ParamKeyTable() paramtypes.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- func ValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte
- func ValidatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte
- func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress)
- func ValidatorSigningInfoKey(v sdk.ConsAddress) []byte
- type AccountKeeper
- type BankKeeper
- type GenesisState
- type MissedBlock
- type MsgUnjail
- func (*MsgUnjail) Descriptor() ([]byte, []int)
- func (this *MsgUnjail) Equal(that interface{}) bool
- func (msg MsgUnjail) GetSignBytes() []byte
- func (msg MsgUnjail) GetSigners() []sdk.AccAddress
- func (m *MsgUnjail) GetValidatorAddr() github_com_cosmos_cosmos_sdk_types.ValAddress
- func (m *MsgUnjail) Marshal() (dAtA []byte, err error)
- func (m *MsgUnjail) MarshalTo(dAtA []byte) (int, error)
- func (m *MsgUnjail) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*MsgUnjail) ProtoMessage()
- func (m *MsgUnjail) Reset()
- func (msg MsgUnjail) Route() string
- func (m *MsgUnjail) Size() (n int)
- func (m *MsgUnjail) String() string
- func (msg MsgUnjail) Type() string
- func (m *MsgUnjail) Unmarshal(dAtA []byte) error
- func (msg MsgUnjail) ValidateBasic() error
- func (m *MsgUnjail) XXX_DiscardUnknown()
- func (m *MsgUnjail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *MsgUnjail) XXX_Merge(src proto.Message)
- func (m *MsgUnjail) XXX_Size() int
- func (m *MsgUnjail) XXX_Unmarshal(b []byte) error
- type ParamSubspace
- type Params
- type QuerySigningInfoParams
- type QuerySigningInfosParams
- type StakingHooks
- type StakingKeeper
- type ValidatorSigningInfo
- func (*ValidatorSigningInfo) Descriptor() ([]byte, []int)
- func (this *ValidatorSigningInfo) Equal(that interface{}) bool
- func (m *ValidatorSigningInfo) GetAddress() github_com_cosmos_cosmos_sdk_types.ConsAddress
- func (m *ValidatorSigningInfo) GetIndexOffset() int64
- func (m *ValidatorSigningInfo) GetJailedUntil() time.Time
- func (m *ValidatorSigningInfo) GetMissedBlocksCounter() int64
- func (m *ValidatorSigningInfo) GetStartHeight() int64
- func (m *ValidatorSigningInfo) GetTombstoned() bool
- func (m *ValidatorSigningInfo) Marshal() (dAtA []byte, err error)
- func (m *ValidatorSigningInfo) MarshalTo(dAtA []byte) (int, error)
- func (m *ValidatorSigningInfo) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ValidatorSigningInfo) ProtoMessage()
- func (m *ValidatorSigningInfo) Reset()
- func (m *ValidatorSigningInfo) Size() (n int)
- func (i ValidatorSigningInfo) String() string
- func (m *ValidatorSigningInfo) Unmarshal(dAtA []byte) error
- func (m *ValidatorSigningInfo) XXX_DiscardUnknown()
- func (m *ValidatorSigningInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ValidatorSigningInfo) XXX_Merge(src proto.Message)
- func (m *ValidatorSigningInfo) XXX_Size() int
- func (m *ValidatorSigningInfo) XXX_Unmarshal(b []byte) error
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(100) DefaultDowntimeJailDuration = 60 * 10 * time.Second )
Default parameter namespace
const ( QueryParameters = "parameters" QuerySigningInfo = "signingInfo" QuerySigningInfos = "signingInfos" )
Query endpoints supported by the slashing querier
Variables ¶
var ( ErrNoValidatorForAddress = sdkerrors.Register(ModuleName, 2, "address is not associated with any known validator") ErrBadValidatorAddr = sdkerrors.Register(ModuleName, 3, "validator does not exist for that address") ErrValidatorJailed = sdkerrors.Register(ModuleName, 4, "validator still jailed; cannot be unjailed") ErrValidatorNotJailed = sdkerrors.Register(ModuleName, 5, "validator not jailed; cannot be unjailed") ErrMissingSelfDelegation = sdkerrors.Register(ModuleName, 6, "validator has no self-delegation; cannot be unjailed") ErrSelfDelegationTooLowToUnjail = sdkerrors.Register(ModuleName, 7, "validator's self delegation less than minimum; cannot be unjailed") ErrNoSigningInfoFound = sdkerrors.Register(ModuleName, 8, "no validator signing info found") )
x/slashing module sentinel errors
var ( ValidatorSigningInfoKeyPrefix = []byte{0x01} // Prefix for signing info ValidatorMissedBlockBitArrayKeyPrefix = []byte{0x02} // Prefix for missed block bit array AddrPubkeyRelationKeyPrefix = []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 ( ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") )
var ( // ModuleCdc references the global x/slashing module codec. Note, the codec // should ONLY be used in certain instances of tests and for JSON encoding as Amino // is still used for that purpose. // // The actual codec used for serialization should be provided to x/slashing and // defined at the application level. ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) )
Functions ¶
func AddrPubkeyRelationKey ¶
AddrPubkeyRelationKey gets pubkey relation key used to get the pubkey from the address
func RegisterCodec ¶
RegisterCodec registers concrete types on codec
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the slashing genesis parameters
func ValidatorMissedBlockBitArrayKey ¶
func ValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte
ValidatorMissedBlockBitArrayKey - stored by *Consensus* address (not operator address)
func ValidatorMissedBlockBitArrayPrefixKey ¶
func ValidatorMissedBlockBitArrayPrefixKey(v sdk.ConsAddress) []byte
ValidatorMissedBlockBitArrayPrefixKey - stored by *Consensus* address (not operator address)
func ValidatorSigningInfoAddress ¶
func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress)
ValidatorSigningInfoAddress - extract the address from a validator signing info key
func ValidatorSigningInfoKey ¶
func ValidatorSigningInfoKey(v sdk.ConsAddress) []byte
ValidatorSigningInfoKey - stored by *Consensus* address (not operator address)
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 BankKeeper ¶
type BankKeeper interface {
GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
SetBalances(ctx sdk.Context, addr sdk.AccAddress, balances sdk.Coins) error
LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
}
BankKeeper defines the expected interface needed to retrieve account balances.
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 github_com_cosmos_cosmos_sdk_types.ValAddress `` /* 153-byte string literal not displayed */
}
MsgUnjail - struct for unjailing jailed validator
func NewMsgUnjail ¶
func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail
NewMsgUnjail creates a new MsgUnjail instance
func (*MsgUnjail) Descriptor ¶
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) GetValidatorAddr ¶
func (m *MsgUnjail) GetValidatorAddr() github_com_cosmos_cosmos_sdk_types.ValAddress
func (*MsgUnjail) MarshalToSizedBuffer ¶
func (*MsgUnjail) ProtoMessage ¶
func (*MsgUnjail) ProtoMessage()
func (MsgUnjail) ValidateBasic ¶
ValidateBasic validity check for the AnteHandler
func (*MsgUnjail) XXX_DiscardUnknown ¶
func (m *MsgUnjail) XXX_DiscardUnknown()
func (*MsgUnjail) XXX_Marshal ¶
func (*MsgUnjail) XXX_Unmarshal ¶
type ParamSubspace ¶
type ParamSubspace interface {
HasKeyTable() bool
WithKeyTable(table paramtypes.KeyTable) paramtypes.Subspace
Get(ctx sdk.Context, key []byte, ptr interface{})
GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet)
SetParamSet(ctx sdk.Context, ps paramtypes.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() paramtypes.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) uint32
}
StakingKeeper expected staking keeper
type ValidatorSigningInfo ¶
type ValidatorSigningInfo struct {
Address github_com_cosmos_cosmos_sdk_types.ConsAddress `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ConsAddress" json:"address,omitempty"`
// height at which validator was first a candidate OR was unjailed
StartHeight int64 `protobuf:"varint,2,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty" yaml:"start_height"`
// index offset into signed block bit array
IndexOffset int64 `protobuf:"varint,3,opt,name=index_offset,json=indexOffset,proto3" json:"index_offset,omitempty" yaml:"index_offset"`
// timestamp validator cannot be unjailed until
JailedUntil time.Time `protobuf:"bytes,4,opt,name=jailed_until,json=jailedUntil,proto3,stdtime" json:"jailed_until" yaml:"jailed_until"`
// whether or not a validator has been tombstoned (killed out of validator set)
Tombstoned bool `protobuf:"varint,5,opt,name=tombstoned,proto3" json:"tombstoned,omitempty"`
// missed blocks counter (to avoid scanning the array every time)
MissedBlocksCounter int64 `` /* 150-byte string literal not displayed */
}
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 UnmarshalValSigningInfo ¶
func UnmarshalValSigningInfo(cdc codec.Marshaler, value []byte) (signingInfo ValidatorSigningInfo, err error)
unmarshal a validator signing info from a store value
func (*ValidatorSigningInfo) Descriptor ¶
func (*ValidatorSigningInfo) Descriptor() ([]byte, []int)
func (*ValidatorSigningInfo) Equal ¶
func (this *ValidatorSigningInfo) Equal(that interface{}) bool
func (*ValidatorSigningInfo) GetAddress ¶
func (m *ValidatorSigningInfo) GetAddress() github_com_cosmos_cosmos_sdk_types.ConsAddress
func (*ValidatorSigningInfo) GetIndexOffset ¶
func (m *ValidatorSigningInfo) GetIndexOffset() int64
func (*ValidatorSigningInfo) GetJailedUntil ¶
func (m *ValidatorSigningInfo) GetJailedUntil() time.Time
func (*ValidatorSigningInfo) GetMissedBlocksCounter ¶
func (m *ValidatorSigningInfo) GetMissedBlocksCounter() int64
func (*ValidatorSigningInfo) GetStartHeight ¶
func (m *ValidatorSigningInfo) GetStartHeight() int64
func (*ValidatorSigningInfo) GetTombstoned ¶
func (m *ValidatorSigningInfo) GetTombstoned() bool
func (*ValidatorSigningInfo) Marshal ¶
func (m *ValidatorSigningInfo) Marshal() (dAtA []byte, err error)
func (*ValidatorSigningInfo) MarshalTo ¶
func (m *ValidatorSigningInfo) MarshalTo(dAtA []byte) (int, error)
func (*ValidatorSigningInfo) MarshalToSizedBuffer ¶
func (m *ValidatorSigningInfo) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*ValidatorSigningInfo) ProtoMessage ¶
func (*ValidatorSigningInfo) ProtoMessage()
func (*ValidatorSigningInfo) Reset ¶
func (m *ValidatorSigningInfo) Reset()
func (*ValidatorSigningInfo) Size ¶
func (m *ValidatorSigningInfo) Size() (n int)
func (ValidatorSigningInfo) String ¶
func (i ValidatorSigningInfo) String() string
String implements the stringer interface for ValidatorSigningInfo
func (*ValidatorSigningInfo) Unmarshal ¶
func (m *ValidatorSigningInfo) Unmarshal(dAtA []byte) error
func (*ValidatorSigningInfo) XXX_DiscardUnknown ¶
func (m *ValidatorSigningInfo) XXX_DiscardUnknown()
func (*ValidatorSigningInfo) XXX_Marshal ¶
func (m *ValidatorSigningInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ValidatorSigningInfo) XXX_Merge ¶
func (m *ValidatorSigningInfo) XXX_Merge(src proto.Message)
func (*ValidatorSigningInfo) XXX_Size ¶
func (m *ValidatorSigningInfo) XXX_Size() int
func (*ValidatorSigningInfo) XXX_Unmarshal ¶
func (m *ValidatorSigningInfo) XXX_Unmarshal(b []byte) error