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: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the distribution module

func CanWithdrawInvariant

func CanWithdrawInvariant(k Keeper) sdk.Invariant

CanWithdrawInvariant checks that current rewards can be completely withdrawn

func ModuleAccountInvariant

func ModuleAccountInvariant(k Keeper) sdk.Invariant

ModuleAccountInvariant checks that the coins held by the distr ModuleAccount is consistent with the sum of validator outstanding rewards

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NonNegativeOutstandingInvariant

func NonNegativeOutstandingInvariant(k Keeper) sdk.Invariant

NonNegativeOutstandingInvariant checks that outstanding unwithdrawn fees are never negative

func ReferenceCountInvariant

func ReferenceCountInvariant(k Keeper) sdk.Invariant

ReferenceCountInvariant checks that the number of historical rewards records is correct

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

register all distribution invariants

Types

type Hooks

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

Wrapper struct

func (Hooks) AfterConsensusPubKeyUpdate

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

func (Hooks) AfterDelegationModified

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

create new delegation period record

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(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorCreated

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

initialize validator distribution record

func (Hooks) AfterValidatorRemoved

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

AfterValidatorRemoved performs clean up after a validator is removed

func (Hooks) BeforeDelegationCreated

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

increment period

func (Hooks) BeforeDelegationRemoved

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

func (Hooks) BeforeDelegationSharesModified

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

withdraw delegation rewards (which also increments period)

func (Hooks) BeforeValidatorModified

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

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx context.Context, valAddr sdk.ValAddress, fraction sdkmath.LegacyDec) error

record the slash event

type Keeper

type Keeper struct {
	appmodule.Environment

	Schema collections.Schema
	Params collections.Item[types.Params]
	// FeePool stores decimal tokens that cannot be yet distributed.
	// In the past it held the community pool, but it has been replaced by x/protocolpool.
	FeePool collections.Item[types.FeePool]
	// DelegatorsWithdrawAddress key: delAddr | value: withdrawAddr
	DelegatorsWithdrawAddress collections.Map[sdk.AccAddress, sdk.AccAddress]
	// ValidatorCurrentRewards key: valAddr | value: ValidatorCurrentRewards
	ValidatorCurrentRewards collections.Map[sdk.ValAddress, types.ValidatorCurrentRewards]
	// DelegatorStartingInfo key: valAddr+delAccAddr | value: DelegatorStartingInfo
	DelegatorStartingInfo collections.Map[collections.Pair[sdk.ValAddress, sdk.AccAddress], types.DelegatorStartingInfo]
	// ValidatorsAccumulatedCommission key: valAddr | value: ValidatorAccumulatedCommission
	ValidatorsAccumulatedCommission collections.Map[sdk.ValAddress, types.ValidatorAccumulatedCommission]
	// ValidatorOutstandingRewards key: valAddr | value: ValidatorOustandingRewards
	ValidatorOutstandingRewards collections.Map[sdk.ValAddress, types.ValidatorOutstandingRewards]
	// ValidatorHistoricalRewards key: valAddr+period | value: ValidatorHistoricalRewards
	ValidatorHistoricalRewards collections.Map[collections.Pair[sdk.ValAddress, uint64], types.ValidatorHistoricalRewards]
	PreviousProposer           collections.Item[sdk.ConsAddress]
	// ValidatorSlashEvents key: valAddr+height+period | value: ValidatorSlashEvent
	ValidatorSlashEvents collections.Map[collections.Triple[sdk.ValAddress, uint64, uint64], types.ValidatorSlashEvent]
	// contains filtered or unexported fields
}

Keeper of the distribution store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, env appmodule.Environment,
	ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, pk types.PoolKeeper,
	feeCollectorName, authority string,
) Keeper

NewKeeper creates a new distribution Keeper instance

func (Keeper) AllocateTokens

func (k Keeper) AllocateTokens(ctx context.Context, totalPreviousPower int64, bondedVotes []comet.VoteInfo) error

AllocateTokens performs reward and fee distribution to all validators based on the F1 fee distribution specification.

func (Keeper) AllocateTokensToValidator

func (k Keeper) AllocateTokensToValidator(ctx context.Context, val sdk.ValidatorI, tokens sdk.DecCoins) error

AllocateTokensToValidator allocate tokens to a particular validator, splitting according to commission.

func (Keeper) BeginBlocker

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

BeginBlocker sets the proposer for determining distribution during endblock and distribute rewards for the previous block. TODO: use context.Context after including the comet service

func (Keeper) CalculateDelegationRewards

func (k Keeper) CalculateDelegationRewards(ctx context.Context, val sdk.ValidatorI, del sdk.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins, err error)

calculate the total rewards accrued by a delegation

func (Keeper) ExportGenesis

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

ExportGenesis returns a GenesisState for a given context and keeper.

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the x/distribution module's authority.

func (Keeper) GetCommunityTax

func (k Keeper) GetCommunityTax(ctx context.Context) (math.LegacyDec, error)

GetCommunityTax returns the current distribution community tax.

func (Keeper) GetDelegatorWithdrawAddr

func (k Keeper) GetDelegatorWithdrawAddr(ctx context.Context, delAddr sdk.AccAddress) (sdk.AccAddress, error)

get the delegator withdraw address, defaulting to the delegator address

func (Keeper) GetDistributionAccount

func (k Keeper) GetDistributionAccount(ctx context.Context) sdk.ModuleAccountI

GetDistributionAccount returns the distribution ModuleAccount

func (Keeper) GetTotalRewards

func (k Keeper) GetTotalRewards(ctx context.Context) (totalRewards sdk.DecCoins)

GetTotalRewards returns the total amount of fee distribution rewards held in the store

func (Keeper) GetValidatorOutstandingRewardsCoins

func (k Keeper) GetValidatorOutstandingRewardsCoins(ctx context.Context, val sdk.ValAddress) (sdk.DecCoins, error)

get outstanding rewards

func (Keeper) GetWithdrawAddrEnabled

func (k Keeper) GetWithdrawAddrEnabled(ctx context.Context) (enabled bool, err error)

GetWithdrawAddrEnabled returns the current distribution withdraw address enabled parameter.

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Create new distribution hooks

func (Keeper) IncrementValidatorPeriod

func (k Keeper) IncrementValidatorPeriod(ctx context.Context, val sdk.ValidatorI) (uint64, error)

increment validator period, returning the period just ended

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) error

InitGenesis sets distribution information for genesis

func (Keeper) IterateValidatorSlashEventsBetween

func (k Keeper) IterateValidatorSlashEventsBetween(ctx context.Context, val sdk.ValAddress, startingHeight, endingHeight uint64,
	handler func(height uint64, event types.ValidatorSlashEvent) (stop bool),
) error

iterate over slash events between heights, inclusive

func (Keeper) SetWithdrawAddr

func (k Keeper) SetWithdrawAddr(ctx context.Context, delegatorAddr, withdrawAddr sdk.AccAddress) error

SetWithdrawAddr sets a new address that will receive the rewards upon withdrawal

func (Keeper) WithdrawDelegationRewards

func (k Keeper) WithdrawDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error)

withdraw rewards from a delegation

func (Keeper) WithdrawValidatorCommission

func (k Keeper) WithdrawValidatorCommission(ctx context.Context, valAddr sdk.ValAddress) (sdk.Coins, error)

withdraw validator commission

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) 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/distribution 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 module and stores them directly into the x/distribution module state.

func (Migrator) Migrate3to4

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

Migrate3to4 migrates the x/distribution module state to use collections Additionally it migrates distribution fee pool to use protocol pool module account

type Querier

type Querier struct {
	Keeper
}

func NewQuerier

func NewQuerier(keeper Keeper) Querier

func (Querier) CommunityPool deprecated

Deprecated: DO NOT USE This method uses deprecated query request. Use CommunityPool from x/protocolpool module instead. CommunityPool queries the community pool coins

func (Querier) DelegationRewards

DelegationRewards the total rewards accrued by a delegation

func (Querier) DelegationTotalRewards

DelegationTotalRewards the total rewards accrued by a each validator

func (Querier) DelegatorValidators

DelegatorValidators queries the validators list of a delegator

func (Querier) DelegatorWithdrawAddress

DelegatorWithdrawAddress queries Query/delegatorWithdrawAddress

func (Querier) Params

Params queries params of distribution module

func (Querier) ValidatorCommission

ValidatorCommission queries accumulated commission for a validator

func (Querier) ValidatorDistributionInfo

ValidatorDistributionInfo query validator's commission and self-delegation rewards

func (Querier) ValidatorOutstandingRewards

ValidatorOutstandingRewards queries rewards of a validator address

func (Querier) ValidatorSlashes

ValidatorSlashes queries slash events of a validator

Jump to

Keyboard shortcuts

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