keeper

package
v0.0.0-...-a6871c7 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

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 wrapper struct for slashing keeper

func (Hooks) AfterConsensusPubKeyUpdate

func (h Hooks) AfterConsensusPubKeyUpdate(ctx context.Context, oldPubKey, newPubKey cryptotypes.PubKey, _ sdk.Coin) error

AfterConsensusPubKeyUpdate triggers the functions to rotate the signing-infos also sets address pubkey relation.

func (Hooks) AfterDelegationModified

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

func (Hooks) AfterUnbondingInitiated

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) 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 {
	appmodule.Environment

	Schema collections.Schema
	Params collections.Item[types.Params]
	// ValidatorSigningInfo key: ConsAddr | value: ValidatorSigningInfo
	ValidatorSigningInfo collections.Map[sdk.ConsAddress, types.ValidatorSigningInfo]
	// AddrPubkeyRelation key: address | value: PubKey
	AddrPubkeyRelation collections.Map[[]byte, cryptotypes.PubKey]
	// ValidatorMissedBlockBitmap key: ConsAddr | value: byte key for a validator's missed block bitmap chunk
	ValidatorMissedBlockBitmap collections.Map[collections.Pair[[]byte, uint64], []byte]
	// contains filtered or unexported fields
}

Keeper of the slashing store

func NewKeeper

func NewKeeper(environment appmodule.Environment, cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, sk types.StakingKeeper, authority string) Keeper

NewKeeper creates a slashing keeper

func (Keeper) DeleteMissedBlockBitmap

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

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

func (Keeper) DowntimeJailDuration

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

DowntimeJailDuration - Downtime unbond duration

func (Keeper) ExportGenesis

func (keeper Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error)

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

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the x/slashing module's authority.

func (Keeper) GetMissedBlockBitmapValue

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) GetPubkey

GetPubkey returns the pubkey from the adddress-pubkey relation

func (Keeper) GetValidatorMissedBlocks

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

GetValidatorMissedBlocks returns array of missed blocks for given validator.

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) HandleValidatorSignatureWithParams

func (k Keeper) HandleValidatorSignatureWithParams(ctx context.Context, params types.Params, addr cryptotypes.Address, power int64, signed comet.BlockIDFlag) error

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

Return the slashing hooks

func (Keeper) InitGenesis

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

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

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) 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.

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.

func (Keeper) MinSignedPerWindow

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

MinSignedPerWindow - minimum blocks signed per window

func (Keeper) SetMissedBlockBitmapChunk

func (k Keeper) SetMissedBlockBitmapChunk(ctx context.Context, addr sdk.ConsAddress, chunkIndex int64, chunk []byte) error

SetMissedBlockBitmapChunk sets the bitmap chunk at the given chunk index for a validator's missed block signing window.

func (Keeper) SetMissedBlockBitmapValue

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) SignedBlocksWindow

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

SignedBlocksWindow - sliding window for downtime slashing

func (Keeper) SigningInfo

SigningInfo returns signing-info of a specific validator.

func (Keeper) SigningInfos

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. It specifies no intraction 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

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

SlashWithInfractionReason attempts to slash a validator. The slash is delegated to the staking module to make the necessary validator changes. It specifies an intraction reason.

func (Keeper) Tombstone

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

Tombstone attempts to tombstone a validator.

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 Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper Keeper, valCodec address.ValidatorAddressCodec) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2

func (m Migrator) Migrate1to2(ctx context.Context) error

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3

func (m Migrator) Migrate2to3(ctx context.Context) error

Migrate2to3 migrates the x/slashing module state from the consensus version 2 to version 3. Specifically, it takes the parameters that are currently stored and managed by the x/params modules and stores them directly into the x/slashing module state.

func (Migrator) Migrate3to4

func (m Migrator) Migrate3to4(ctx context.Context) error

Migrate3to4 migrates the x/slashing module state from the consensus version 3 to version 4. Specifically, it migrates the validator missed block bitmap.

type Querier

type Querier struct {
	Keeper
}

func NewQuerier

func NewQuerier(keeper Keeper) Querier

func (Querier) Params

Params returns parameters of x/slashing module

Jump to

Keyboard shortcuts

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