keeper

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Overview

nolint

Index

Constants

This section is empty.

Variables

View Source
var (
	ValPubKeys = simapp.CreateTestPubKeys(5)

	Addrs = []sdk.AccAddress{
		sdk.AccAddress(pubKeys[0].Address()),
		sdk.AccAddress(pubKeys[1].Address()),
		sdk.AccAddress(pubKeys[2].Address()),
		sdk.AccAddress(pubKeys[3].Address()),
		sdk.AccAddress(pubKeys[4].Address()),
	}

	ValAddrs = []sdk.ValAddress{
		sdk.ValAddress(pubKeys[0].Address()),
		sdk.ValAddress(pubKeys[1].Address()),
		sdk.ValAddress(pubKeys[2].Address()),
		sdk.ValAddress(pubKeys[3].Address()),
		sdk.ValAddress(pubKeys[4].Address()),
	}

	InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
	InitCoins  = sdk.NewCoins(sdk.NewCoin(testdenom, InitTokens))

	OracleDecPrecision = 8

	AccountAddressPrefix = "qube"
)

Test addresses

ModuleBasics nolint

Functions

func FundAccount added in v0.1.1

func FundAccount(input TestInput, addr sdk.AccAddress, amounts sdk.Coins) error

FundAccount is a utility function that funds an account by minting and sending the coins to the address. This should be used for testing purposes only!

func MakeEncodingConfig added in v0.1.1

func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig

MakeEncodingConfig nolint

func MakeTestCodec added in v0.1.1

func MakeTestCodec(t *testing.T) codec.Codec
#nosec

MakeTestCodec nolint

func ModuleAccountAddrs added in v0.1.1

func ModuleAccountAddrs(maccPerms map[string][]string) map[string]bool

#nosec

func NewLegacyQuerier added in v0.1.1

func NewLegacyQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

NewLegacyQuerier is the module level router for state queries

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewQuerier added in v0.1.1

func NewQuerier(keeper Keeper) types.QueryServer

NewQuerier returns an implementation of the oracle QueryServer interface for the provided Keeper.

func NewTestMsgCreateValidator added in v0.1.1

func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey cryptotypes.PubKey, amt sdk.Int) *stakingtypes.MsgCreateValidator

NewTestMsgCreateValidator test msg creator

Types

type Keeper

type Keeper struct {
	SlashingKeeper types.SlashingKeeper
	StakingKeeper  types.StakingKeeper
	// contains filtered or unexported fields
}

Keeper of the oracle store

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey,
	paramspace paramstypes.Subspace, accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper, distrKeeper types.DistributionKeeper,
	slashingkeeper types.SlashingKeeper, stakingKeeper types.StakingKeeper, distrName string,
) Keeper

NewKeeper constructs a new keeper for oracle

func (Keeper) ClearBallots added in v0.1.1

func (k Keeper) ClearBallots(ctx sdk.Context, votePeriod uint64)

ClearBallots clears all tallied prevotes and votes from the store

#nosec

func (Keeper) DeleteAggregateExchangeRatePrevote added in v0.1.1

func (k Keeper) DeleteAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress)

DeleteAggregateExchangeRatePrevote deletes an oracle prevote from the store

func (Keeper) DeleteAggregateExchangeRateVote added in v0.1.1

func (k Keeper) DeleteAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress)

DeleteAggregateExchangeRateVote deletes an oracle prevote from the store

func (Keeper) DeleteExchangeRate added in v0.1.1

func (k Keeper) DeleteExchangeRate(ctx sdk.Context, denom string)

DeleteExchangeRate deletes the consensus exchange rate of the denom asset from the store.

func (Keeper) DeleteMissCounter added in v0.1.1

func (k Keeper) DeleteMissCounter(ctx sdk.Context, operator sdk.ValAddress)

DeleteMissCounter removes miss counter for the validator

func (Keeper) GetAggregateExchangeRatePrevote added in v0.1.1

func (k Keeper) GetAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress) (aggregatePrevote types.AggregateExchangeRatePrevote, err error)

GetAggregateExchangeRatePrevote retrieves an oracle prevote from the store

func (Keeper) GetAggregateExchangeRateVote added in v0.1.1

func (k Keeper) GetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress) (aggregateVote types.AggregateExchangeRateVote, err error)

GetAggregateExchangeRateVote retrieves an oracle prevote from the store

func (Keeper) GetExchangeRate added in v0.1.1

func (k Keeper) GetExchangeRate(ctx sdk.Context, denom string) (sdk.Dec, error)

GetExchangeRate gets the consensus exchange rate of the denom asset from the store.

func (Keeper) GetFeederDelegation added in v0.1.1

func (k Keeper) GetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress) sdk.AccAddress

GetFeederDelegation gets the account address that the validator operator delegated oracle vote rights to

func (Keeper) GetMissCounter added in v0.1.1

func (k Keeper) GetMissCounter(ctx sdk.Context, operator sdk.ValAddress) uint64

GetMissCounter retrieves the # of vote periods missed in this oracle slash window

func (Keeper) GetOracleAccount added in v0.1.1

func (k Keeper) GetOracleAccount(ctx sdk.Context) authtypes.ModuleAccountI

GetOracleAccount returns oracle ModuleAccount

func (Keeper) GetParams

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

GetParams returns the total set of oracle parameters.

func (Keeper) GetRewardPool added in v0.1.1

func (k Keeper) GetRewardPool(ctx sdk.Context, denom string) sdk.Coin

GetRewardPool retrieves the balance of the oracle module account

func (Keeper) IterateAggregateExchangeRatePrevotes added in v0.1.1

func (k Keeper) IterateAggregateExchangeRatePrevotes(ctx sdk.Context, handler func(voterAddr sdk.ValAddress, aggregatePrevote types.AggregateExchangeRatePrevote) (stop bool))

IterateAggregateExchangeRatePrevotes iterates rate over prevotes in the store

func (Keeper) IterateAggregateExchangeRateVotes added in v0.1.1

func (k Keeper) IterateAggregateExchangeRateVotes(ctx sdk.Context, handler func(voterAddr sdk.ValAddress, aggregateVote types.AggregateExchangeRateVote) (stop bool))

IterateAggregateExchangeRateVotes iterates rate over prevotes in the store

func (Keeper) IterateExchangeRates added in v0.1.1

func (k Keeper) IterateExchangeRates(ctx sdk.Context, handler func(denom string, exchangeRate sdk.Dec) (stop bool))

IterateExchangeRates iterates over luna rates in the store

func (Keeper) IterateFeederDelegations added in v0.1.1

func (k Keeper) IterateFeederDelegations(ctx sdk.Context,
	handler func(delegator sdk.ValAddress, delegate sdk.AccAddress) (stop bool),
)

IterateFeederDelegations iterates over the feed delegates and performs a callback function.

func (Keeper) IterateMissCounters added in v0.1.1

func (k Keeper) IterateMissCounters(ctx sdk.Context,
	handler func(operator sdk.ValAddress, missCounter uint64) (stop bool),
)

IterateMissCounters iterates over the miss counters and performs a callback function.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MinValidPerWindow added in v0.1.1

func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec)

MinValidPerWindow returns oracle slashing threshold

func (Keeper) OrganizeBallotByDenom added in v0.1.1

func (k Keeper) OrganizeBallotByDenom(ctx sdk.Context, validatorClaimMap map[string]types.Claim) (votes map[string]types.ExchangeRateBallot)

OrganizeBallotByDenom collects all oracle votes for the period, categorized by the votes' denom parameter

#nosec

func (Keeper) RewardBallotWinners added in v0.1.1

func (k Keeper) RewardBallotWinners(
	ctx sdk.Context,
	votePeriod int64,
	rewardDistributionWindow int64,
	voteTargets []string,
	ballotWinners map[string]types.Claim,
)

RewardBallotWinners implements at the end of every VotePeriod, give out a portion of spread fees collected in the oracle reward pool

to the oracle voters that voted faithfully.

#nosec

func (Keeper) RewardBand added in v0.1.1

func (k Keeper) RewardBand(ctx sdk.Context) (res sdk.Dec)

RewardBand returns the ratio of allowable exchange rate error that a validator can be rewared

func (Keeper) RewardDistributionWindow added in v0.1.1

func (k Keeper) RewardDistributionWindow(ctx sdk.Context) (res uint64)

RewardDistributionWindow returns the number of vote periods during which seigiornage reward comes in and then is distributed.

func (Keeper) SetAggregateExchangeRatePrevote added in v0.1.1

func (k Keeper) SetAggregateExchangeRatePrevote(ctx sdk.Context, voter sdk.ValAddress, prevote types.AggregateExchangeRatePrevote)

SetAggregateExchangeRatePrevote set an oracle aggregate prevote to the store

func (Keeper) SetAggregateExchangeRateVote added in v0.1.1

func (k Keeper) SetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress, vote types.AggregateExchangeRateVote)

SetAggregateExchangeRateVote adds an oracle aggregate prevote to the store

func (Keeper) SetExchangeRate added in v0.1.1

func (k Keeper) SetExchangeRate(ctx sdk.Context, denom string, exchangeRate sdk.Dec)

SetExchangeRate sets the consensus exchange rate of the denom asset to the store.

func (Keeper) SetExchangeRateWithEvent added in v0.1.1

func (k Keeper) SetExchangeRateWithEvent(ctx sdk.Context, denom string, exchangeRate sdk.Dec)

SetExchangeRateWithEvent sets the consensus exchange rate of the denom asset to the store with ABCI event

func (Keeper) SetFeederDelegation added in v0.1.1

func (k Keeper) SetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress)

SetFeederDelegation sets the account address that the validator operator delegated oracle vote rights to

func (Keeper) SetMissCounter added in v0.1.1

func (k Keeper) SetMissCounter(ctx sdk.Context, operator sdk.ValAddress, missCounter uint64)

SetMissCounter updates the # of vote periods missed in this oracle slash window

func (Keeper) SetParams

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

SetParams sets the total set of oracle parameters.

func (Keeper) SetWhitelist added in v0.1.1

func (k Keeper) SetWhitelist(ctx sdk.Context, whitelist types.DenomList)

SetWhitelist store new whitelist to param store this function is only for test purpose

func (Keeper) SlashAndResetMissCounters added in v0.1.1

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

SlashAndResetMissCounters do slash any operator who over criteria & clear all operators miss counter to zero

#nosec

func (Keeper) SlashFraction added in v0.1.1

func (k Keeper) SlashFraction(ctx sdk.Context) (res sdk.Dec)

SlashFraction returns oracle voting penalty rate

func (Keeper) SlashWindow added in v0.1.1

func (k Keeper) SlashWindow(ctx sdk.Context) (res uint64)

SlashWindow returns # of vote period for oracle slashing

func (Keeper) ValidateFeeder added in v0.1.1

func (k Keeper) ValidateFeeder(ctx sdk.Context, feederAddr sdk.AccAddress, validatorAddr sdk.ValAddress) error

ValidateFeeder return the given feeder is allowed to feed the message or not

func (Keeper) VotePeriod added in v0.1.1

func (k Keeper) VotePeriod(ctx sdk.Context) (res uint64)

VotePeriod returns the number of blocks during which voting takes place.

func (Keeper) VoteThreshold added in v0.1.1

func (k Keeper) VoteThreshold(ctx sdk.Context) (res sdk.Dec)

VoteThreshold returns the minimum percentage of votes that must be received for a ballot to pass.

func (Keeper) Whitelist added in v0.1.1

func (k Keeper) Whitelist(ctx sdk.Context) (res types.DenomList)

Whitelist returns the denom list that can be activated

type TestInput added in v0.1.1

type TestInput struct {
	Ctx           sdk.Context
	Cdc           *codec.LegacyAmino
	AccountKeeper authkeeper.AccountKeeper
	BankKeeper    bankkeeper.Keeper
	OracleKeeper  Keeper
	StakingKeeper stakingkeeper.Keeper
	DistrKeeper   distrkeeper.Keeper
}

TestInput nolint

func CreateTestInput added in v0.1.1

func CreateTestInput(t *testing.T) TestInput

CreateTestInput nolint

#nosec

Jump to

Keyboard shortcuts

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