keeper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default paramspace for params keeper
	DefaultParamspace = types.ModuleName
)

Variables

View Source
var (
	FeePoolKey                        = []byte{0x00} // key for global distribution state
	ProposerKey                       = []byte{0x01} // key for the proposer operator address
	ValidatorOutstandingRewardsPrefix = []byte{0x02} // key for outstanding rewards

	DelegatorWithdrawAddrPrefix          = []byte{0x03} // key for delegator withdraw address
	DelegatorStartingInfoPrefix          = []byte{0x04} // key for delegator starting info
	ValidatorHistoricalRewardsPrefix     = []byte{0x05} // key for historical validators rewards / stake
	ValidatorCurrentRewardsPrefix        = []byte{0x06} // key for current validator rewards
	ValidatorAccumulatedCommissionPrefix = []byte{0x07} // key for accumulated validator commission
	ValidatorSlashEventPrefix            = []byte{0x08} // key for validator slash fraction

	ParamStoreKeyCommunityTax        = []byte("communitytax")
	ParamStoreKeyBaseProposerReward  = []byte("baseproposerreward")
	ParamStoreKeyBonusProposerReward = []byte("bonusproposerreward")
	ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled")
)

Keys for distribution store Items are stored with the following key: values

- 0x00<proposalID_Bytes>: FeePol

- 0x01: sdk.ConsAddress

- 0x02<valAddr_Bytes>: ValidatorOutstandingRewards

- 0x03<accAddr_Bytes>: sdk.AccAddress

- 0x04<valAddr_Bytes><accAddr_Bytes>: DelegatorStartingInfo

- 0x05<valAddr_Bytes><period_Bytes>: ValidatorHistoricalRewards

- 0x06<valAddr_Bytes>: ValidatorCurrentRewards

- 0x07<valAddr_Bytes>: ValidatorCurrentRewards

- 0x08<valAddr_Bytes><height>: ValidatorSlashEvent

View Source
var (

	// TODO move to common testing package for all modules
	// test addresses
	TestAddrs = []sdk.AccAddress{
		delAddr1, delAddr2, delAddr3,
		valAccAddr1, valAccAddr2, valAccAddr3,
	}
)

nolint: deadcode unused

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 GetDelegatorStartingInfoAddresses

func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress)

gets the addresses from a delegator starting info key

func GetDelegatorStartingInfoKey

func GetDelegatorStartingInfoKey(v sdk.ValAddress, d sdk.AccAddress) []byte

gets the key for a delegator's starting info

func GetDelegatorWithdrawAddrKey

func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte

gets the key for a delegator's withdraw addr

func GetDelegatorWithdrawInfoAddress

func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress)

gets an address from a delegator's withdraw info key

func GetValidatorAccumulatedCommissionAddress

func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress)

gets the address from a validator's accumulated commission key

func GetValidatorAccumulatedCommissionKey

func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte

gets the key for a validator's current commission

func GetValidatorCurrentRewardsAddress

func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress)

gets the address from a validator's current rewards key

func GetValidatorCurrentRewardsKey

func GetValidatorCurrentRewardsKey(v sdk.ValAddress) []byte

gets the key for a validator's current rewards

func GetValidatorHistoricalRewardsAddressPeriod

func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64)

gets the address & period from a validator's historical rewards key

func GetValidatorHistoricalRewardsKey

func GetValidatorHistoricalRewardsKey(v sdk.ValAddress, k uint64) []byte

gets the key for a validator's historical rewards

func GetValidatorHistoricalRewardsPrefix

func GetValidatorHistoricalRewardsPrefix(v sdk.ValAddress) []byte

gets the prefix key for a validator's historical rewards

func GetValidatorOutstandingRewardsAddress

func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress)

gets an address from a validator's outstanding rewards key

func GetValidatorOutstandingRewardsKey

func GetValidatorOutstandingRewardsKey(valAddr sdk.ValAddress) []byte

gets the outstanding rewards key for a validator

func GetValidatorSlashEventAddressHeight

func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64)

gets the height from a validator's slash event key

func GetValidatorSlashEventKey

func GetValidatorSlashEventKey(v sdk.ValAddress, height, period uint64) []byte

gets the key for a validator's slash fraction

func GetValidatorSlashEventKeyPrefix

func GetValidatorSlashEventKeyPrefix(v sdk.ValAddress, height uint64) []byte

gets the prefix key for a validator's slash fraction (ValidatorSlashEventPrefix + height)

func GetValidatorSlashEventPrefix

func GetValidatorSlashEventPrefix(v sdk.ValAddress) []byte

gets the prefix key for a validator's slash fractions

func HandleCommunityPoolSpendProposal

func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p types.CommunityPoolSpendProposal) sdk.Error

HandleCommunityPoolSpendProposal is a handler for executing a passed community spend proposal

func MakeTestCodec

func MakeTestCodec() *codec.Codec

create a codec used only for testing

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 NewQuerier

func NewQuerier(k Keeper) sdk.Querier

func NonNegativeOutstandingInvariant

func NonNegativeOutstandingInvariant(k Keeper) sdk.Invariant

NonNegativeOutstandingInvariant checks that outstanding unwithdrawn fees are never negative

func ParamKeyTable

func ParamKeyTable() params.KeyTable

type declaration for parameters

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

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

create new delegation period record

func (Hooks) AfterValidatorBeginUnbonding

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

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)

func (Hooks) AfterValidatorCreated

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

initialize validator distribution record

func (Hooks) AfterValidatorRemoved

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

cleanup for after validator is removed

func (Hooks) BeforeDelegationCreated

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

increment period

func (Hooks) BeforeDelegationRemoved

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

func (Hooks) BeforeDelegationSharesModified

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

withdraw delegation rewards (which also increments period)

func (Hooks) BeforeValidatorModified

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

nolint - unused hooks

func (Hooks) BeforeValidatorSlashed

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

record the slash event

type Keeper

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

Keeper of the distribution store

func CreateTestInputAdvanced

func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initPower int64,
	communityTax sdk.Dec) (sdk.Context, auth.AccountKeeper, bank.Keeper,
	Keeper, staking.Keeper, params.Keeper, types.SupplyKeeper)

hogpodge of all sorts of input required for testing

func CreateTestInputDefault

func CreateTestInputDefault(t *testing.T, isCheckTx bool, initPower int64) (
	sdk.Context, auth.AccountKeeper, Keeper, staking.Keeper, types.SupplyKeeper)

test input with default values

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace,
	sk types.StakingKeeper, supplyKeeper types.SupplyKeeper, codespace sdk.CodespaceType,
	feeCollectorName string, blacklistedAddrs map[string]bool) Keeper

NewKeeper creates a new distribution Keeper instance

func (Keeper) AllocateTokens

func (k Keeper) AllocateTokens(
	ctx sdk.Context, sumPreviousPrecommitPower, totalPreviousPower int64,
	previousProposer sdk.ConsAddress, previousVotes []abci.VoteInfo,
)

AllocateTokens handles distribution of the collected fees

func (Keeper) AllocateTokensToValidator

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

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

func (Keeper) DeleteAllValidatorHistoricalRewards

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

delete all historical rewards

func (Keeper) DeleteAllValidatorSlashEvents

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

delete all slash events

func (Keeper) DeleteDelegatorStartingInfo

func (k Keeper) DeleteDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress)

delete the starting info associated with a delegator

func (Keeper) DeleteDelegatorWithdrawAddr

func (k Keeper) DeleteDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress)

delete a delegator withdraw addr

func (Keeper) DeleteValidatorAccumulatedCommission

func (k Keeper) DeleteValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress)

delete accumulated commission for a validator

func (Keeper) DeleteValidatorCurrentRewards

func (k Keeper) DeleteValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress)

delete current rewards for a validator

func (Keeper) DeleteValidatorHistoricalReward

func (k Keeper) DeleteValidatorHistoricalReward(ctx sdk.Context, val sdk.ValAddress, period uint64)

delete a historical reward

func (Keeper) DeleteValidatorHistoricalRewards

func (k Keeper) DeleteValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress)

delete historical rewards for a validator

func (Keeper) DeleteValidatorOutstandingRewards

func (k Keeper) DeleteValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress)

delete validator outstanding rewards

func (Keeper) DeleteValidatorSlashEvents

func (k Keeper) DeleteValidatorSlashEvents(ctx sdk.Context, val sdk.ValAddress)

delete slash events for a particular validator

func (Keeper) DistributeFromFeePool

func (k Keeper) DistributeFromFeePool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) sdk.Error

DistributeFromFeePool distributes funds from the distribution module account to a receiver address while updating the community pool

func (Keeper) GetBaseProposerReward

func (k Keeper) GetBaseProposerReward(ctx sdk.Context) sdk.Dec

returns the current BaseProposerReward rate from the global param store nolint: errcheck

func (Keeper) GetBonusProposerReward

func (k Keeper) GetBonusProposerReward(ctx sdk.Context) sdk.Dec

returns the current BaseProposerReward rate from the global param store nolint: errcheck

func (Keeper) GetCommunityTax

func (k Keeper) GetCommunityTax(ctx sdk.Context) sdk.Dec

returns the current CommunityTax rate from the global param store nolint: errcheck

func (Keeper) GetDelegatorStartingInfo

func (k Keeper) GetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) (period types.DelegatorStartingInfo)

get the starting info associated with a delegator

func (Keeper) GetDelegatorWithdrawAddr

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

get the delegator withdraw address, defaulting to the delegator address

func (Keeper) GetDistributionAccount

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

GetDistributionAccount returns the distribution ModuleAccount

func (Keeper) GetFeePool

func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool)

get the global fee pool distribution info

func (Keeper) GetFeePoolCommunityCoins

func (k Keeper) GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins

get the community coins

func (Keeper) GetPreviousProposerConsAddr

func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) (consAddr sdk.ConsAddress)

get the proposer public key for this block

func (Keeper) GetTotalRewards

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

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

func (Keeper) GetValidatorAccumulatedCommission

func (k Keeper) GetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress) (commission types.ValidatorAccumulatedCommission)

get accumulated commission for a validator

func (Keeper) GetValidatorCurrentRewards

func (k Keeper) GetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress) (rewards types.ValidatorCurrentRewards)

get current rewards for a validator

func (Keeper) GetValidatorHistoricalReferenceCount

func (k Keeper) GetValidatorHistoricalReferenceCount(ctx sdk.Context) (count uint64)

historical reference count (used for testcases)

func (Keeper) GetValidatorHistoricalRewards

func (k Keeper) GetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64) (rewards types.ValidatorHistoricalRewards)

get historical rewards for a particular period

func (Keeper) GetValidatorOutstandingRewards

func (k Keeper) GetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress) (rewards types.ValidatorOutstandingRewards)

get validator outstanding rewards

func (Keeper) GetValidatorOutstandingRewardsCoins

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

get outstanding rewards

func (Keeper) GetValidatorSlashEvent

func (k Keeper) GetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, height, period uint64) (event types.ValidatorSlashEvent, found bool)

get slash event for height

func (Keeper) GetWithdrawAddrEnabled

func (k Keeper) GetWithdrawAddrEnabled(ctx sdk.Context) bool

returns the current WithdrawAddrEnabled nolint: errcheck

func (Keeper) HasDelegatorStartingInfo

func (k Keeper) HasDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) bool

check existence of the starting info associated with a delegator

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Create new distribution hooks

func (Keeper) IterateDelegatorStartingInfos

func (k Keeper) IterateDelegatorStartingInfos(ctx sdk.Context, handler func(val sdk.ValAddress, del sdk.AccAddress, info types.DelegatorStartingInfo) (stop bool))

iterate over delegator starting infos

func (Keeper) IterateDelegatorWithdrawAddrs

func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool))

iterate over delegator withdraw addrs

func (Keeper) IterateValidatorAccumulatedCommissions

func (k Keeper) IterateValidatorAccumulatedCommissions(ctx sdk.Context, handler func(val sdk.ValAddress, commission types.ValidatorAccumulatedCommission) (stop bool))

iterate over accumulated commissions

func (Keeper) IterateValidatorCurrentRewards

func (k Keeper) IterateValidatorCurrentRewards(ctx sdk.Context, handler func(val sdk.ValAddress, rewards types.ValidatorCurrentRewards) (stop bool))

iterate over current rewards

func (Keeper) IterateValidatorHistoricalRewards

func (k Keeper) IterateValidatorHistoricalRewards(ctx sdk.Context, handler func(val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) (stop bool))

iterate over historical rewards

func (Keeper) IterateValidatorOutstandingRewards

func (k Keeper) IterateValidatorOutstandingRewards(ctx sdk.Context, handler func(val sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool))

iterate validator outstanding rewards

func (Keeper) IterateValidatorSlashEvents

func (k Keeper) IterateValidatorSlashEvents(ctx sdk.Context, handler func(val sdk.ValAddress, height uint64, event types.ValidatorSlashEvent) (stop bool))

iterate over all slash events

func (Keeper) IterateValidatorSlashEventsBetween

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

iterate over slash events between heights, inclusive

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) SetBaseProposerReward

func (k Keeper) SetBaseProposerReward(ctx sdk.Context, percent sdk.Dec)

nolint: errcheck

func (Keeper) SetBonusProposerReward

func (k Keeper) SetBonusProposerReward(ctx sdk.Context, percent sdk.Dec)

nolint: errcheck

func (Keeper) SetCommunityTax

func (k Keeper) SetCommunityTax(ctx sdk.Context, percent sdk.Dec)

nolint: errcheck

func (Keeper) SetDelegatorStartingInfo

func (k Keeper) SetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress, period types.DelegatorStartingInfo)

set the starting info associated with a delegator

func (Keeper) SetDelegatorWithdrawAddr

func (k Keeper) SetDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress)

set the delegator withdraw address

func (Keeper) SetFeePool

func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool)

set the global fee pool distribution info

func (Keeper) SetPreviousProposerConsAddr

func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress)

set the proposer public key for this block

func (Keeper) SetValidatorAccumulatedCommission

func (k Keeper) SetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress, commission types.ValidatorAccumulatedCommission)

set accumulated commission for a validator

func (Keeper) SetValidatorCurrentRewards

func (k Keeper) SetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorCurrentRewards)

set current rewards for a validator

func (Keeper) SetValidatorHistoricalRewards

func (k Keeper) SetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards)

set historical rewards for a particular period

func (Keeper) SetValidatorOutstandingRewards

func (k Keeper) SetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorOutstandingRewards)

set validator outstanding rewards

func (Keeper) SetValidatorSlashEvent

func (k Keeper) SetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, height, period uint64, event types.ValidatorSlashEvent)

set slash event for height

func (Keeper) SetWithdrawAddr

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

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

func (Keeper) SetWithdrawAddrEnabled

func (k Keeper) SetWithdrawAddrEnabled(ctx sdk.Context, enabled bool)

nolint: errcheck

func (Keeper) WithdrawDelegationRewards

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

withdraw rewards from a delegation

func (Keeper) WithdrawValidatorCommission

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

withdraw validator commission

Jump to

Keyboard shortcuts

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