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.AccAddress, i int64) []byte
- func ValidatorMissedBlockBitArrayPrefixKey(v sdk.AccAddress) []byte
- func ValidatorSigningInfoAddress(key []byte) (v sdk.AccAddress)
- func ValidatorSigningInfoKey(v sdk.AccAddress) []byte
- type AccountKeeper
- type BankKeeper
- type GenesisState
- type MissedBlock
- type MsgServer
- type MsgUnjail
- type MsgUnjailResponse
- type ParamSubspace
- type Params
- type QueryParamsRequest
- type QueryParamsResponse
- type QuerySigningInfoRequest
- type QuerySigningInfoResponse
- type QuerySigningInfosParams
- type QuerySigningInfosRequest
- type QuerySigningInfosResponse
- type SigningInfo
- type StakingHooks
- type StakingKeeper
- type UnimplementedMsgServer
- type ValidatorMissedBlocks
- 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 DefaultCodespace = ModuleName )
const ( 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
const (
TypeMsgUnjail = "unjail"
)
slashing message types
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 SlashingCodec *codec.Codec
Functions ¶
func AddrPubkeyRelationKey ¶
AddrPubkeyRelationKey gets pubkey relation key used to get the pubkey from the address
func RegisterCodec ¶
RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the slashing genesis parameters
func ValidatorMissedBlockBitArrayKey ¶
func ValidatorMissedBlockBitArrayKey(v sdk.AccAddress, i int64) []byte
ValidatorMissedBlockBitArrayKey - stored by *Consensus* address (not operator address)
func ValidatorMissedBlockBitArrayPrefixKey ¶
func ValidatorMissedBlockBitArrayPrefixKey(v sdk.AccAddress) []byte
ValidatorMissedBlockBitArrayPrefixKey - stored by *Consensus* address (not operator address)
func ValidatorSigningInfoAddress ¶
func ValidatorSigningInfoAddress(key []byte) (v sdk.AccAddress)
ValidatorSigningInfoAddress - extract the address from a validator signing info key
func ValidatorSigningInfoKey ¶
func ValidatorSigningInfoKey(v sdk.AccAddress) []byte
ValidatorSigningInfoKey - stored by *Consensus* address (not operator address)
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) exported.Account IterateAccounts(ctx sdk.Context, process func(exported.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 defines all the paramaters of related to deposit. Params Params `json:"params"` // signing_infos represents a map between validator addresses and their // signing infos. SigningInfos []SigningInfo `json:"signing_infos" yaml:"signing_infos"` // signing_infos represents a map between validator addresses and their // missed blocks. MissedBlocks []ValidatorMissedBlocks `json:"missed_blocks" yaml:"missed_blocks"` }
func DefaultGenesisState ¶
func DefaultGenesisState() *GenesisState
DefaultGenesisState - default GenesisState used by Cosmos Hub
func NewGenesisState ¶
func NewGenesisState( params Params, signingInfos []SigningInfo, missedBlocks []ValidatorMissedBlocks, ) *GenesisState
NewGenesisState creates a new GenesisState object
type MissedBlock ¶
type MissedBlock struct { // index is the height at which the block was missed. Index int64 `json:"index,omitempty"` // missed is the missed status. Missed bool `json:"missed,omitempty"` }
MissedBlock contains height and missed status as boolean.
func NewMissedBlock ¶
func NewMissedBlock(index int64, missed bool) MissedBlock
NewMissedBlock creates a new MissedBlock instance
type MsgServer ¶
type MsgServer interface { // Unjail defines a method for unjailing a jailed validator, thus returning // them into the bonded validator set, so they can begin receiving provisions // and rewards again. Unjail(context.Context, *MsgUnjail) (*MsgUnjailResponse, error) }
type MsgUnjail ¶
type MsgUnjail struct {
ValidatorAddr string `json:"validator_addr"`
}
func NewMsgUnjail ¶
func NewMsgUnjail(validatorAddr sdk.AccAddress) *MsgUnjail
NewMsgUnjail creates a new MsgUnjail instance
func (MsgUnjail) GetFromAddress ¶
func (msg MsgUnjail) GetFromAddress() sdk.AccAddress
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 MsgUnjailResponse ¶
type MsgUnjailResponse struct { }
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,omitempty" 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 represents the parameters used for by the slashing module.
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 QueryParamsRequest ¶
type QueryParamsRequest struct { }
type QueryParamsResponse ¶
type QueryParamsResponse struct {
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
}
type QuerySigningInfoRequest ¶
type QuerySigningInfoRequest struct { // cons_address is the address to query signing info of ConsAddress string `protobuf:"bytes,1,opt,name=cons_address,json=consAddress,proto3" json:"cons_address,omitempty"` }
QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC method
func (*QuerySigningInfoRequest) GetConsAddress ¶
func (m *QuerySigningInfoRequest) GetConsAddress() string
type QuerySigningInfoResponse ¶
type QuerySigningInfoResponse struct { // val_signing_info is the signing info of requested val cons address ValSigningInfo ValidatorSigningInfo `protobuf:"bytes,1,opt,name=val_signing_info,json=valSigningInfo,proto3" json:"val_signing_info"` }
func (*QuerySigningInfoResponse) GetValSigningInfo ¶
func (m *QuerySigningInfoResponse) GetValSigningInfo() ValidatorSigningInfo
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 QuerySigningInfosRequest ¶
type QuerySigningInfosRequest struct {
Pagination *pagination.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"`
}
QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC method
func (*QuerySigningInfosRequest) GetPagination ¶
func (m *QuerySigningInfosRequest) GetPagination() *pagination.PageRequest
type QuerySigningInfosResponse ¶
type QuerySigningInfosResponse struct { // info is the signing info of all validators Info []ValidatorSigningInfo `protobuf:"bytes,1,rep,name=info,proto3" json:"info"` Pagination *pagination.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` }
func (*QuerySigningInfosResponse) GetInfo ¶
func (m *QuerySigningInfosResponse) GetInfo() []ValidatorSigningInfo
func (*QuerySigningInfosResponse) GetPagination ¶
func (m *QuerySigningInfosResponse) GetPagination() *pagination.PageResponse
type SigningInfo ¶
type SigningInfo struct { // address is the validator address. Address string `json:"address,omitempty"` // validator_signing_info represents the signing info of this validator. ValidatorSigningInfo ValidatorSigningInfo `json:"validator_signing_info" yaml:"validator_signing_info"` }
SigningInfo stores validator signing info of corresponding address.
type StakingHooks ¶
type StakingHooks interface { AfterValidatorCreated(ctx sdk.Context, valAddr sdk.AccAddress) // Must be called when a validator is created AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress) // Must be called when a validator is deleted AfterValidatorBonded(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress) // 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 stakingtypes.Validator) (stop bool)) Validator(sdk.Context, sdk.AccAddress) stakingtypes.Validator // get a particular validator by operator address ValidatorByConsAddr(sdk.Context, sdk.AccAddress) stakingtypes.Validator // 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.AccAddress, int64, int64, sdk.Dec) Jail(sdk.Context, sdk.AccAddress) // jail a validator Unjail(sdk.Context, sdk.AccAddress) // 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.AccAddress) stakingtypes.Delegation // MaxValidators returns the maximum amount of bonded validators MaxValidators(sdk.Context) uint32 }
StakingKeeper expected staking keeper
type UnimplementedMsgServer ¶
type UnimplementedMsgServer struct { }
UnimplementedMsgServer can be embedded to have forward compatible implementations.
func (*UnimplementedMsgServer) Unjail ¶
func (*UnimplementedMsgServer) Unjail(ctx context.Context, req *MsgUnjail) (*MsgUnjailResponse, error)
type ValidatorMissedBlocks ¶
type ValidatorMissedBlocks struct { // address is the validator address. Address string `json:"address,omitempty"` // missed_blocks is an array of missed blocks by the validator. MissedBlocks []MissedBlock `json:"missed_blocks" yaml:"missed_blocks"` }
ValidatorMissedBlocks contains array of missed blocks of corresponding address.
type ValidatorSigningInfo ¶
type ValidatorSigningInfo struct { Address string `json:"address,omitempty"` // Height at which validator was first a candidate OR was unjailed StartHeight int64 `json:"start_height,omitempty" yaml:"start_height"` // Index which is incremented each time the validator was a bonded // in a block and may have signed a precommit or not. This in conjunction with the // `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. IndexOffset int64 `json:"index_offset,omitempty" yaml:"index_offset"` // Timestamp until which the validator is jailed due to liveness downtime. JailedUntil time.Time `json:"jailed_until" yaml:"jailed_until"` // Whether or not a validator has been tombstoned (killed out of validator set). It is set // once the validator commits an equivocation or for any other configured misbehiavor. Tombstoned bool `json:"tombstoned,omitempty"` // A counter kept to avoid unnecessary array reads. // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. MissedBlocksCounter int64 `json:"missed_blocks_counter,omitempty" yaml:"missed_blocks_counter"` }
ValidatorSigningInfo defines a validator's signing info for monitoring their liveness activity.
func NewValidatorSigningInfo ¶
func NewValidatorSigningInfo( condAddr sdk.AccAddress, startHeight, indexOffset int64, jailedUntil time.Time, tombstoned bool, missedBlocksCounter int64, ) ValidatorSigningInfo
NewValidatorSigningInfo creates a new ValidatorSigningInfo instance
func UnmarshalValSigningInfo ¶
func UnmarshalValSigningInfo(cdc *codec.Codec, value []byte) (signingInfo ValidatorSigningInfo, err error)
unmarshal a validator signing info from a store value
func (ValidatorSigningInfo) String ¶
func (i ValidatorSigningInfo) String() string
String implements the stringer interface for ValidatorSigningInfo