keeper

package
v0.55.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 24 Imported by: 1,900

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl added in v0.40.0

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the slashing MsgServer interface for the provided Keeper.

Types

type Hooks

type Hooks struct {
	// contains filtered or unexported fields
}

Hooks is a wrapper struct for slashing keeper

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) AfterUnbondingInitiated added in v0.47.0

func (h Hooks) AfterUnbondingInitiated(_ context.Context, _ uint64) error

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(ctx context.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error

AfterValidatorBonded updates the signing info start height or create a new signing info

func (Hooks) AfterValidatorConsKeyUpdated added in v0.55.0

func (h Hooks) AfterValidatorConsKeyUpdated(ctx context.Context, oldConsAddr, newConsAddr sdk.ConsAddress, valAddr sdk.ValAddress) error

AfterValidatorConsKeyUpdated moves signing state to the new consensus key.

func (Hooks) AfterValidatorCreated

func (h Hooks) AfterValidatorCreated(ctx context.Context, valAddr sdk.ValAddress) error

AfterValidatorCreated adds the address-pubkey relation when a validator is created.

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx context.Context, consAddr sdk.ConsAddress, _ sdk.ValAddress) error

AfterValidatorRemoved deletes the address-pubkey relation when a validator is removed,

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(_ context.Context, _ sdk.ValAddress) error

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(_ context.Context, _ sdk.ValAddress, _ sdkmath.LegacyDec) error

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper of the slashing store

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, storeService storetypes.KVStoreService, sk types.StakingKeeper, authority string) Keeper

NewKeeper creates a slashing keeper

func (Keeper) AddPubkey

func (k Keeper) AddPubkey(ctx context.Context, pubkey cryptotypes.PubKey) error

AddPubkey sets a address-pubkey relation

func (Keeper) DeleteMissedBlockBitmap added in v0.50.1

func (k Keeper) DeleteMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddress) error

DeleteMissedBlockBitmap removes a validator's missed block bitmap from state.

func (Keeper) DeleteValidatorSigningInfo added in v0.55.0

func (k Keeper) DeleteValidatorSigningInfo(ctx context.Context, address sdk.ConsAddress) error

DeleteValidatorSigningInfo deletes the signing info for a consensus address.

func (Keeper) DowntimeJailDuration

func (k Keeper) DowntimeJailDuration(ctx context.Context) (time.Duration, error)

DowntimeJailDuration - Downtime unbond duration

func (Keeper) ExportGenesis added in v0.46.0

func (keeper Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState)

ExportGenesis writes the current store values to a genesis file, which can be imported again with InitGenesis

func (Keeper) GetAuthority added in v0.47.0

func (k Keeper) GetAuthority() string

GetAuthority returns the x/slashing module's authority.

func (Keeper) GetMissedBlockBitmapValue added in v0.50.1

func (k Keeper) GetMissedBlockBitmapValue(ctx context.Context, addr sdk.ConsAddress, index int64) (bool, error)

GetMissedBlockBitmapValue returns true if a validator missed signing a block at the given index and false otherwise. The index provided is assumed to be the index in the range [0, SignedBlocksWindow), which represents the bitmap where each bit represents a height, and is determined by the validator's IndexOffset modulo SignedBlocksWindow. This index is used to fetch the chunk in the bitmap and the relative bit in that chunk.

func (Keeper) GetParams

func (k Keeper) GetParams(ctx context.Context) (params types.Params, err error)

GetParams returns the current x/slashing module parameters.

func (Keeper) GetPubkey

GetPubkey returns the pubkey from the address-pubkey relation

func (Keeper) GetValidatorMissedBlocks added in v0.40.0

func (k Keeper) GetValidatorMissedBlocks(ctx context.Context, addr sdk.ConsAddress) ([]types.MissedBlock, error)

GetValidatorMissedBlocks returns array of missed blocks for given validator.

func (Keeper) GetValidatorSigningInfo

func (k Keeper) GetValidatorSigningInfo(ctx context.Context, address sdk.ConsAddress) (types.ValidatorSigningInfo, error)

GetValidatorSigningInfo returns the ValidatorSigningInfo for a specific validator ConsAddress. If not found it returns ErrNoSigningInfoFound, but other errors may be returned if there is an error reading from the store.

func (Keeper) HandleValidatorSignature

func (k Keeper) HandleValidatorSignature(ctx context.Context, addr cryptotypes.Address, power int64, signed comet.BlockIDFlag) error

HandleValidatorSignature handles a validator signature, must be called once per validator per block.

func (Keeper) HasValidatorSigningInfo

func (k Keeper) HasValidatorSigningInfo(ctx context.Context, consAddr sdk.ConsAddress) bool

HasValidatorSigningInfo returns if a given validator has signing information persisted.

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Hooks returns the slashing hooks

func (Keeper) InitGenesis added in v0.46.0

func (keeper Keeper) InitGenesis(ctx sdk.Context, stakingKeeper types.StakingKeeper, data *types.GenesisState)

InitGenesis initializes default parameters and the keeper's address to pubkey map.

func (Keeper) IsTombstoned

func (k Keeper) IsTombstoned(ctx context.Context, consAddr sdk.ConsAddress) bool

IsTombstoned returns if a given validator by consensus address is tombstoned.

func (Keeper) IterateMissedBlockBitmap added in v0.50.1

func (k Keeper) IterateMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddress, cb func(index int64, missed bool) (stop bool)) error

IterateMissedBlockBitmap iterates over a validator's signed blocks window bitmap and performs a callback function on each index, i.e. block height, in the range [0, SignedBlocksWindow).

Note: A callback will only be executed over all bitmap chunks that exist in state.

func (Keeper) IterateValidatorSigningInfos

func (k Keeper) IterateValidatorSigningInfos(ctx context.Context,
	handler func(address sdk.ConsAddress, info types.ValidatorSigningInfo) (stop bool),
) error

IterateValidatorSigningInfos iterates over the stored ValidatorSigningInfo

func (Keeper) Jail

func (k Keeper) Jail(ctx context.Context, consAddr sdk.ConsAddress) error

Jail attempts to jail a validator. The slash is delegated to the staking module to make the necessary validator changes. The consensus address must be the validator's current consensus address.

func (Keeper) JailUntil

func (k Keeper) JailUntil(ctx context.Context, consAddr sdk.ConsAddress, jailTime time.Time) error

JailUntil attempts to set a validator's JailedUntil attribute in its signing info. It returns an error if the signing info does not exist for the validator.

func (Keeper) Logger

func (k Keeper) Logger(ctx context.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MinSignedPerWindow

func (k Keeper) MinSignedPerWindow(ctx context.Context) (int64, error)

MinSignedPerWindow - minimum blocks signed per window

func (Keeper) MoveMissedBlockBitmap added in v0.55.0

func (k Keeper) MoveMissedBlockBitmap(ctx context.Context, oldAddr, newAddr sdk.ConsAddress) (err error)

MoveMissedBlockBitmap moves missed block bitmap chunks from one consensus address to another.

func (Keeper) MoveValidatorSigningInfo added in v0.55.0

func (k Keeper) MoveValidatorSigningInfo(ctx context.Context, oldAddr, newAddr sdk.ConsAddress) error

MoveValidatorSigningInfo moves signing info from one consensus address to another.

func (Keeper) Params added in v0.40.0

Params returns parameters of x/slashing module

func (Keeper) SetMissedBlockBitmapValue added in v0.50.1

func (k Keeper) SetMissedBlockBitmapValue(ctx context.Context, addr sdk.ConsAddress, index int64, missed bool) error

SetMissedBlockBitmapValue sets, i.e. flips, a bit in the validator's missed block bitmap. When missed=true, the bit is set, otherwise it set to zero. The index provided is assumed to be the index in the range [0, SignedBlocksWindow), which represents the bitmap where each bit represents a height, and is determined by the validator's IndexOffset modulo SignedBlocksWindow. This index is used to fetch the chunk in the bitmap and the relative bit in that chunk.

func (Keeper) SetParams

func (k Keeper) SetParams(ctx context.Context, params types.Params) error

SetParams sets the x/slashing module parameters. CONTRACT: This method performs no validation of the parameters.

func (Keeper) SetValidatorSigningInfo

func (k Keeper) SetValidatorSigningInfo(ctx context.Context, address sdk.ConsAddress, info types.ValidatorSigningInfo) error

SetValidatorSigningInfo sets the validator signing info to a consensus address key

func (Keeper) SignedBlocksWindow

func (k Keeper) SignedBlocksWindow(ctx context.Context) (int64, error)

SignedBlocksWindow - sliding window for downtime slashing

func (Keeper) SigningInfo added in v0.40.0

SigningInfo returns signing-info of a specific validator.

func (Keeper) SigningInfos added in v0.40.0

SigningInfos returns signing-infos of all validators.

func (Keeper) Slash

func (k Keeper) Slash(ctx context.Context, consAddr sdk.ConsAddress, fraction sdkmath.LegacyDec, power, distributionHeight int64) error

Slash attempts to slash a validator. The slash is delegated to the staking module to make the necessary validator changes. The consensus address must be the validator's current consensus address. It specifies no infraction reason.

func (Keeper) SlashFractionDoubleSign

func (k Keeper) SlashFractionDoubleSign(ctx context.Context) (sdkmath.LegacyDec, error)

SlashFractionDoubleSign - fraction of power slashed in case of double sign

func (Keeper) SlashFractionDowntime

func (k Keeper) SlashFractionDowntime(ctx context.Context) (sdkmath.LegacyDec, error)

SlashFractionDowntime - fraction of power slashed for downtime

func (Keeper) SlashWithInfractionReason added in v0.47.0

func (k Keeper) SlashWithInfractionReason(ctx context.Context, consAddr sdk.ConsAddress, fraction sdkmath.LegacyDec, power, distributionHeight int64, infraction stakingtypes.Infraction) error

SlashWithInfractionReason attempts to slash a validator. The slash is delegated to the staking module to make the necessary validator changes. The consensus address must be the validator's current consensus address. It specifies an infraction reason.

func (Keeper) Tombstone

func (k Keeper) Tombstone(ctx context.Context, consAddr sdk.ConsAddress) error

Tombstone attempts to tombstone a validator. It returns an error if signing info for the given validator does not exist or if the validator is already tombstoned.

func (Keeper) Unjail

func (k Keeper) Unjail(ctx context.Context, validatorAddr sdk.ValAddress) error

Unjail calls the staking Unjail function to unjail a validator if the jailed period has concluded

type Querier added in v0.50.1

type Querier struct {
	Keeper
}

func NewQuerier

func NewQuerier(keeper Keeper) Querier

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址