keeper

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEpochNumber = 0
)

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func VerifyAppHashInclusion

func VerifyAppHashInclusion(appHash []byte, appHashRoot []byte, proof *tmcrypto.Proof) error

VerifyAppHashInclusion verifies whether the given appHash is in the Merkle tree w.r.t. the appHashRoot

Types

type DropValidatorMsgDecorator

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

DropValidatorMsgDecorator defines an AnteHandler decorator that rejects all messages that might change the validator set.

func NewDropValidatorMsgDecorator

func NewDropValidatorMsgDecorator(ek Keeper) *DropValidatorMsgDecorator

NewDropValidatorMsgDecorator creates a new DropValidatorMsgDecorator

func (DropValidatorMsgDecorator) AnteHandle

func (qmd DropValidatorMsgDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

AnteHandle performs an AnteHandler check that rejects all non-wrapped validator-related messages. It will reject the following types of messages: - MsgCreateValidator - MsgDelegate - MsgUndelegate - MsgBeginRedelegate TODO (non-urgent): after we bump to Cosmos SDK v0.46, add MsgCancelUnbondingDelegation

func (DropValidatorMsgDecorator) IsValidatorRelatedMsg

func (qmd DropValidatorMsgDecorator) IsValidatorRelatedMsg(msg sdk.Msg) bool

IsValidatorRelatedMsg checks if the given message is of non-wrapped type, which should be rejected

type Hooks

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

Wrapper struct

func (Hooks) AfterBlsKeyRegistered

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

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) AfterRawCheckpointBlsSigVerified

func (h Hooks) AfterRawCheckpointBlsSigVerified(ctx sdk.Context, ckpt *checkpointingtypes.RawCheckpoint) error

func (Hooks) AfterRawCheckpointConfirmed

func (h Hooks) AfterRawCheckpointConfirmed(ctx sdk.Context, epoch uint64) error

func (Hooks) AfterRawCheckpointFinalized

func (h Hooks) AfterRawCheckpointFinalized(ctx sdk.Context, epoch uint64) error

func (Hooks) AfterRawCheckpointForgotten

func (h Hooks) AfterRawCheckpointForgotten(ctx sdk.Context, ckpt *checkpointingtypes.RawCheckpoint) error

func (Hooks) AfterUnbondingInitiated added in v0.6.0

func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error

func (Hooks) AfterValidatorBeginUnbonding

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

func (Hooks) AfterValidatorBonded

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

func (Hooks) AfterValidatorCreated

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

func (Hooks) AfterValidatorRemoved

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

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeValidatorModified

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

Other hooks that are not used in the epoching module

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error

BeforeValidatorSlashed records the slash event

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey storetypes.StoreKey,
	bk types.BankKeeper,
	stk types.StakingKeeper,
	authority string,
) Keeper

func (Keeper) AddSlashedValidator

func (k Keeper) AddSlashedValidator(ctx sdk.Context, valAddr sdk.ValAddress) error

AddSlashedValidator adds a slashed validator to the set of the current epoch This is called upon hook `BeforeValidatorSlashed` exposed by the staking module

func (Keeper) AfterEpochBegins

func (k Keeper) AfterEpochBegins(ctx sdk.Context, epoch uint64)

AfterEpochBegins - call hook if registered

func (Keeper) AfterEpochEnds

func (k Keeper) AfterEpochEnds(ctx sdk.Context, epoch uint64)

AfterEpochEnds - call hook if registered

func (Keeper) ApplyAndReturnValidatorSetUpdates

func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) []abci.ValidatorUpdate

ApplyAndReturnValidatorSetUpdates applies and return accumulated updates to the bonded validator set, including * Updates the active validator set as keyed by LastValidatorPowerKey. * Updates the total power as keyed by LastTotalPowerKey. * Updates validator status' according to updated powers. * Updates the fee pool bonded vs not-bonded tokens. * Updates relevant indices. Triggered upon every epoch. (adapted from https://github.com/cosmos/cosmos-sdk/blob/v0.45.5/x/staking/keeper/val_state_change.go#L18-L30)

func (Keeper) ApplyMatureUnbonding

func (k Keeper) ApplyMatureUnbonding(ctx sdk.Context, epochNumber uint64)

ApplyMatureUnbonding - unbonds all mature validators/delegations, and - finishes all mature redelegations in the corresponding queues, where - an unbonding/redelegation becomes mature when its corresponding epoch and all previous epochs have been checkpointed. Triggered by the checkpointing module upon the above condition. (adapted from https://github.com/cosmos/cosmos-sdk/blob/v0.45.5/x/staking/keeper/val_state_change.go#L32-L91)

func (Keeper) BeforeSlashThreshold

func (k Keeper) BeforeSlashThreshold(ctx sdk.Context, valSet types.ValidatorSet)

BeforeSlashThreshold triggers the BeforeSlashThreshold hook for other modules that register this hook

func (Keeper) CheckMsgCreateValidator added in v0.6.0

func (k Keeper) CheckMsgCreateValidator(ctx sdk.Context, msg *stakingtypes.MsgCreateValidator) error

CheckMsgCreateValidator performs checks on a given `MsgCreateValidator` message The checkpointing module will use this function to verify the `MsgCreateValidator` message inside a `MsgWrappedCreateValidator` message. (adapted from https://github.com/cosmos/cosmos-sdk/blob/v0.46.10/x/staking/keeper/msg_server.go#L34-L108)

func (Keeper) ClearSlashedValidators

func (k Keeper) ClearSlashedValidators(ctx sdk.Context, epochNumber uint64)

ClearSlashedValidators removes all slashed validators in the set TODO: This is called upon the epoch is checkpointed

func (Keeper) ClearValidatorSet

func (k Keeper) ClearValidatorSet(ctx sdk.Context, epochNumber uint64)

ClearValidatorSet removes the validator set of a given epoch TODO: This is called upon the epoch is checkpointed

func (Keeper) CurrentEpoch

CurrentEpoch handles the QueryCurrentEpochRequest query

func (Keeper) DelegationLifecycle

DelegationLifecycle handles the QueryDelegationLifecycleRequest query TODO: test this API

func (Keeper) EnqueueMsg

func (k Keeper) EnqueueMsg(ctx sdk.Context, msg types.QueuedMessage)

EnqueueMsg enqueues a message to the queue of the current epoch

func (Keeper) EpochInfo

EpochInfo handles the QueryEpochInfoRequest query

func (Keeper) EpochMsgs

EpochMsgs handles the QueryEpochMsgsRequest query

func (Keeper) EpochsInfo

EpochsInfo handles the QueryEpochsInfoRequest query

func (Keeper) GetAllAppHashsForEpoch

func (k Keeper) GetAllAppHashsForEpoch(ctx sdk.Context, epoch *types.Epoch) ([][]byte, error)

GetAllAppHashsForEpoch fetches all AppHashs in the given epoch

func (Keeper) GetAppHash

func (k Keeper) GetAppHash(ctx sdk.Context, height uint64) ([]byte, error)

GetAppHash gets the AppHash of the header at the given height

func (Keeper) GetCurrentEpochMsgs

func (k Keeper) GetCurrentEpochMsgs(ctx sdk.Context) []*types.QueuedMessage

GetCurrentEpochMsgs returns the set of messages queued in the current epoch

func (Keeper) GetCurrentQueueLength

func (k Keeper) GetCurrentQueueLength(ctx sdk.Context) uint64

GetQueueLength fetches the number of queued messages of the current epoch

func (Keeper) GetCurrentValidatorSet

func (k Keeper) GetCurrentValidatorSet(ctx sdk.Context) types.ValidatorSet

func (Keeper) GetCurrentValidatorVotingPower

func (k Keeper) GetCurrentValidatorVotingPower(ctx sdk.Context, valAddr sdk.ValAddress) (int64, error)

func (Keeper) GetDelegationLifecycle

func (k Keeper) GetDelegationLifecycle(ctx sdk.Context, delAddr sdk.AccAddress) *types.DelegationLifecycle

func (Keeper) GetEpoch

func (k Keeper) GetEpoch(ctx sdk.Context) *types.Epoch

GetEpoch fetches the current epoch

func (Keeper) GetEpochMsgs

func (k Keeper) GetEpochMsgs(ctx sdk.Context, epochNumber uint64) []*types.QueuedMessage

GetEpochMsgs returns the set of messages queued in a given epoch

func (Keeper) GetHistoricalEpoch

func (k Keeper) GetHistoricalEpoch(ctx sdk.Context, epochNumber uint64) (*types.Epoch, error)

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (p types.Params)

GetParams returns the current x/epoching module parameters.

func (Keeper) GetQueueLength

func (k Keeper) GetQueueLength(ctx sdk.Context, epochNumber uint64) uint64

GetQueueLength fetches the number of queued messages of a given epoch

func (Keeper) GetSlashedValidators

func (k Keeper) GetSlashedValidators(ctx sdk.Context, epochNumber uint64) types.ValidatorSet

GetSlashedValidators returns the set of slashed validators of a given epoch

func (Keeper) GetSlashedVotingPower

func (k Keeper) GetSlashedVotingPower(ctx sdk.Context, epochNumber uint64) int64

GetSlashedVotingPower fetches the amount of slashed voting power of a given epoch

func (Keeper) GetTotalVotingPower

func (k Keeper) GetTotalVotingPower(ctx sdk.Context, epochNumber uint64) int64

GetTotalVotingPower returns the total voting power of a given epoch

func (Keeper) GetValLifecycle

func (k Keeper) GetValLifecycle(ctx sdk.Context, valAddr sdk.ValAddress) *types.ValidatorLifecycle

func (Keeper) GetValidatorPubkey

func (k Keeper) GetValidatorPubkey(ctx sdk.Context, valAddr sdk.ValAddress) (cryptotypes.PubKey, bool)

func (Keeper) GetValidatorSet

func (k Keeper) GetValidatorSet(ctx sdk.Context, epochNumber uint64) types.ValidatorSet

GetValidatorSet returns the set of validators of a given epoch, where the validators are ordered by their address in ascending order

func (Keeper) GetValidatorVotingPower

func (k Keeper) GetValidatorVotingPower(ctx sdk.Context, epochNumber uint64, valAddr sdk.ValAddress) (int64, error)

GetValidatorVotingPower returns the voting power of a given validator in a given epoch

func (Keeper) HandleQueuedMsg

func (k Keeper) HandleQueuedMsg(ctx sdk.Context, msg *types.QueuedMessage) (*sdk.Result, error)

HandleQueuedMsg unwraps a QueuedMessage and forwards it to the staking module

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Create new distribution hooks

func (Keeper) IncEpoch

func (k Keeper) IncEpoch(ctx sdk.Context) types.Epoch

IncEpoch adds epoch number by 1 CONTRACT: can only be invoked at the first block of an epoch

func (Keeper) InitEpoch

func (k Keeper) InitEpoch(ctx sdk.Context)

InitEpoch sets the zero epoch number to DB

func (Keeper) InitMsgQueue

func (k Keeper) InitMsgQueue(ctx sdk.Context)

InitMsgQueue initialises the msg queue length of the current epoch to 0

func (Keeper) InitSlashedVotingPower

func (k Keeper) InitSlashedVotingPower(ctx sdk.Context)

InitSlashedVotingPower sets the slashed voting power of the current epoch to 0 This is called upon initialising the genesis state and upon a new epoch

func (Keeper) InitValidatorSet

func (k Keeper) InitValidatorSet(ctx sdk.Context)

InitValidatorSet stores the validator set in the beginning of the current epoch This is called upon BeginBlock

func (Keeper) LatestEpochMsgs

LatestEpochMsgs handles the QueryLatestEpochMsgsRequest query TODO: test this API

func (Keeper) Logger

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

func (Keeper) Params

func (Keeper) ProveAppHashInEpoch

func (k Keeper) ProveAppHashInEpoch(ctx sdk.Context, height uint64, epochNumber uint64) (*tmcrypto.Proof, error)

ProveAppHashInEpoch generates a proof that the given appHash is in a given epoch

func (Keeper) RecordAppHash

func (k Keeper) RecordAppHash(ctx sdk.Context)

RecordAppHash stores the AppHash of the current header to KVStore

func (Keeper) RecordLastHeaderAndAppHashRoot

func (k Keeper) RecordLastHeaderAndAppHashRoot(ctx sdk.Context) error

RecordLastHeaderAndAppHashRoot records the last header and Merkle root of all AppHashs for the current epoch, and stores the epoch metadata to KVStore

func (Keeper) RecordNewDelegationState

func (k Keeper) RecordNewDelegationState(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, state types.BondState) error

RecordNewDelegationState adds a state for a delegation lifecycle, including created, bonded, unbonding and unbonded

func (Keeper) RecordNewValState

func (k Keeper) RecordNewValState(ctx sdk.Context, valAddr sdk.ValAddress, state types.BondState) error

RecordNewValState adds a state for a validator lifecycle, including bonded, unbonding and unbonded

func (Keeper) RecordSealerHeaderForPrevEpoch

func (k Keeper) RecordSealerHeaderForPrevEpoch(ctx sdk.Context) *types.Epoch

RecordSealerHeaderForPrevEpoch records the sealer header for the previous epoch, where the sealer header of an epoch is the 2nd header of the next epoch This validator set of the epoch has generated a BLS multisig on `last_commit_hash` of the sealer header

func (Keeper) SetDelegationLifecycle

func (k Keeper) SetDelegationLifecycle(ctx sdk.Context, delAddr sdk.AccAddress, lc *types.DelegationLifecycle)

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(eh types.EpochingHooks) *Keeper

SetHooks sets the validator hooks

func (*Keeper) SetMsgServiceRouter

func (k *Keeper) SetMsgServiceRouter(router *baseapp.MsgServiceRouter) *Keeper

SetMsgServiceRouter sets the msgServiceRouter

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error

GetParams get all parameters as types.Params SetParams sets the x/epoching module parameters.

func (Keeper) SetValLifecycle

func (k Keeper) SetValLifecycle(ctx sdk.Context, valAddr sdk.ValAddress, lc *types.ValidatorLifecycle)

func (Keeper) ValidatorLifecycle

ValidatorLifecycle handles the QueryValidatorLifecycleRequest query TODO: test this API

type Querier

type Querier struct {
	Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper

Jump to

Keyboard shortcuts

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