keeper

package
v0.50.9 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

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) 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 {
	// 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

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

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

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

GetValidatorSigningInfo retruns 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

Return the slashing hooks

func (Keeper) InitGenesis

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

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.

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 will panic 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) Params

Params returns parameters of x/slashing module

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

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 stakingtypes.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. It will panic if signing info for the given validator does not exist.

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, ss exported.Subspace) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2

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

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3

func (m Migrator) Migrate2to3(ctx sdk.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 sdk.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

Jump to

Keyboard shortcuts

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