Documentation ¶
Overview ¶
nolint
Index ¶
- Variables
- func FundAccount(input TestInput, addr sdk.AccAddress, amounts sdk.Coins) error
- func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig
- func MakeTestCodec(t *testing.T) codec.Codec
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewQuerier(keeper Keeper) types.QueryServer
- func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey cryptotypes.PubKey, amt sdk.Int) *stakingtypes.MsgCreateValidator
- type Keeper
- func (k Keeper) AddPriceSnapshot(ctx sdk.Context, snapshot types.PriceSnapshot)
- func (k Keeper) ApplyWhitelist(ctx sdk.Context, whitelist types.DenomList, voteTargets map[string]types.Denom)
- func (k Keeper) CalculateTwaps(ctx sdk.Context, lookbackSeconds uint64) (types.OracleTwaps, error)
- func (k Keeper) ClearBallots(ctx sdk.Context, _ uint64)
- func (k Keeper) ClearVoteTargets(ctx sdk.Context)
- func (k Keeper) DeleteAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress)
- func (k Keeper) DeleteBaseExchangeRate(ctx sdk.Context, denom string)
- func (k Keeper) DeletePriceSnapshot(ctx sdk.Context, timestamp int64)
- func (k Keeper) DeleteVotePenaltyCounter(ctx sdk.Context, operator sdk.ValAddress)
- func (k Keeper) GetAbstainCount(ctx sdk.Context, operator sdk.ValAddress) uint64
- func (k Keeper) GetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress) (aggregateVote types.AggregateExchangeRateVote, err error)
- func (k Keeper) GetBaseExchangeRate(ctx sdk.Context, denom string) (sdk.Dec, sdk.Int, int64, error)
- func (k Keeper) GetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress) sdk.AccAddress
- func (k Keeper) GetMissCount(ctx sdk.Context, operator sdk.ValAddress) uint64
- func (k Keeper) GetOracleAccount(ctx sdk.Context) authtypes.ModuleAccountI
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetPriceSnapshot(ctx sdk.Context, timestamp int64) types.PriceSnapshot
- func (k Keeper) GetRewardPool(ctx sdk.Context, denom string) sdk.Coin
- func (k Keeper) GetRewardPoolLegacy(ctx sdk.Context) sdk.Coins
- func (k Keeper) GetSpamPreventionCounter(ctx sdk.Context, validatorAddr sdk.ValAddress) int64
- func (k Keeper) GetSuccessCount(ctx sdk.Context, operator sdk.ValAddress) uint64
- func (k Keeper) GetVotePenaltyCounter(ctx sdk.Context, operator sdk.ValAddress) types.VotePenaltyCounter
- func (k Keeper) GetVoteTarget(ctx sdk.Context, denom string) (types.Denom, error)
- func (k Keeper) GetVoteTargets(ctx sdk.Context) (voteTargets []string)
- func (k Keeper) IncrementAbstainCount(ctx sdk.Context, operator sdk.ValAddress)
- func (k Keeper) IncrementMissCount(ctx sdk.Context, operator sdk.ValAddress)
- func (k Keeper) IncrementSuccessCount(ctx sdk.Context, operator sdk.ValAddress)
- func (k Keeper) IsVoteTarget(ctx sdk.Context, denom string) bool
- func (k Keeper) IterateAggregateExchangeRateVotes(ctx sdk.Context, ...)
- func (k Keeper) IterateBaseExchangeRates(ctx sdk.Context, ...)
- func (k Keeper) IterateFeederDelegations(ctx sdk.Context, ...)
- func (k Keeper) IteratePriceSnapshots(ctx sdk.Context, handler func(snapshot types.PriceSnapshot) (stop bool))
- func (k Keeper) IteratePriceSnapshotsReverse(ctx sdk.Context, handler func(snapshot types.PriceSnapshot) (stop bool))
- func (k Keeper) IterateVotePenaltyCounters(ctx sdk.Context, ...)
- func (k Keeper) IterateVoteTargets(ctx sdk.Context, handler func(denom string, denomInfo types.Denom) (stop bool))
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) LookbackDuration(ctx sdk.Context) (res uint64)
- func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) OrganizeBallotByDenom(ctx sdk.Context, validatorClaimMap map[string]types.Claim) (votes map[string]types.ExchangeRateBallot)
- func (k Keeper) RemoveExcessFeeds(ctx sdk.Context)
- func (k Keeper) RewardBand(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) SetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress, vote types.AggregateExchangeRateVote)
- func (k Keeper) SetBaseExchangeRate(ctx sdk.Context, denom string, exchangeRate sdk.Dec)
- func (k Keeper) SetBaseExchangeRateWithEvent(ctx sdk.Context, denom string, exchangeRate sdk.Dec)
- func (k Keeper) SetFeederDelegation(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPriceSnapshot(ctx sdk.Context, snapshot types.PriceSnapshot)
- func (k Keeper) SetSpamPreventionCounter(ctx sdk.Context, validatorAddr sdk.ValAddress)
- func (k Keeper) SetVotePenaltyCounter(ctx sdk.Context, operator sdk.ValAddress, ...)
- func (k Keeper) SetVoteTarget(ctx sdk.Context, denom string)
- func (k Keeper) SetWhitelist(ctx sdk.Context, whitelist types.DenomList)
- func (k Keeper) SlashAndResetCounters(ctx sdk.Context)
- func (k Keeper) SlashFraction(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) SlashWindow(ctx sdk.Context) (res uint64)
- func (k Keeper) ValidateFeeder(ctx sdk.Context, feederAddr sdk.AccAddress, validatorAddr sdk.ValAddress) error
- func (k Keeper) ValidateLookbackSeconds(ctx sdk.Context, lookbackSeconds uint64) error
- func (k Keeper) VotePeriod(ctx sdk.Context) (res uint64)
- func (k Keeper) VoteThreshold(ctx sdk.Context) (res sdk.Dec)
- func (k Keeper) Whitelist(ctx sdk.Context) (res types.DenomList)
- type Migrator
- type TestInput
Constants ¶
This section is empty.
Variables ¶
var ( ValPubKeys = simapp.CreateTestPubKeys(7) 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()), sdk.AccAddress(pubKeys[5].Address()), sdk.AccAddress(pubKeys[6].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()), sdk.ValAddress(pubKeys[5].Address()), sdk.ValAddress(pubKeys[6].Address()), } InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) InitCoins = sdk.NewCoins(sdk.NewCoin(utils.MicroSeiDenom, InitTokens)) OracleDecPrecision = 8 )
Test addresses
var ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, bank.AppModuleBasic{}, distribution.AppModuleBasic{}, staking.AppModuleBasic{}, params.AppModuleBasic{}, )
ModuleBasics nolint
Functions ¶
func FundAccount ¶
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 ¶
func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig
MakeEncodingConfig nolint
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the oracle MsgServer interface for the provided Keeper.
func NewQuerier ¶
func NewQuerier(keeper Keeper) types.QueryServer
NewQuerier returns an implementation of the oracle QueryServer interface for the provided Keeper.
func NewTestMsgCreateValidator ¶
func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey cryptotypes.PubKey, amt sdk.Int) *stakingtypes.MsgCreateValidator
NewTestMsgCreateValidator test msg creator
Types ¶
type Keeper ¶
type Keeper struct { StakingKeeper types.StakingKeeper // contains filtered or unexported fields }
Keeper of the oracle store
func NewKeeper ¶
func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, memKey sdk.StoreKey, paramspace paramstypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, distrKeeper types.DistributionKeeper, stakingKeeper types.StakingKeeper, distrName string, ) Keeper
NewKeeper constructs a new keeper for oracle
func (Keeper) AddPriceSnapshot ¶
func (k Keeper) AddPriceSnapshot(ctx sdk.Context, snapshot types.PriceSnapshot)
func (Keeper) ApplyWhitelist ¶
func (k Keeper) ApplyWhitelist(ctx sdk.Context, whitelist types.DenomList, voteTargets map[string]types.Denom)
ApplyWhitelist update vote target denom list with params whitelist
func (Keeper) CalculateTwaps ¶
func (Keeper) ClearBallots ¶
ClearBallots clears all tallied votes from the store
func (Keeper) ClearVoteTargets ¶
func (Keeper) DeleteAggregateExchangeRateVote ¶
func (k Keeper) DeleteAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress)
DeleteAggregateExchangeRateVote deletes an oracle vote from the store
func (Keeper) DeleteBaseExchangeRate ¶
func (Keeper) DeletePriceSnapshot ¶
func (Keeper) DeleteVotePenaltyCounter ¶
func (k Keeper) DeleteVotePenaltyCounter(ctx sdk.Context, operator sdk.ValAddress)
DeleteVotePenaltyCounter removes miss counter for the validator
func (Keeper) GetAbstainCount ¶
func (Keeper) GetAggregateExchangeRateVote ¶
func (k Keeper) GetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress) (aggregateVote types.AggregateExchangeRateVote, err error)
GetAggregateExchangeRateVote retrieves an oracle vote from the store
func (Keeper) GetBaseExchangeRate ¶
func (Keeper) GetFeederDelegation ¶
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) GetMissCount ¶
func (Keeper) GetOracleAccount ¶
func (k Keeper) GetOracleAccount(ctx sdk.Context) authtypes.ModuleAccountI
GetOracleAccount returns oracle ModuleAccount
func (Keeper) GetPriceSnapshot ¶
func (Keeper) GetRewardPool ¶
GetRewardPool retrieves the balance of the oracle module account
func (Keeper) GetRewardPoolLegacy ¶
GetRewardPool retrieves the balance of the oracle module account
func (Keeper) GetSpamPreventionCounter ¶
func (Keeper) GetSuccessCount ¶
func (Keeper) GetVotePenaltyCounter ¶
func (k Keeper) GetVotePenaltyCounter(ctx sdk.Context, operator sdk.ValAddress) types.VotePenaltyCounter
GetVotePenaltyCounter retrieves the # of vote periods missed and abstained in this oracle slash window
func (Keeper) GetVoteTarget ¶
func (Keeper) GetVoteTargets ¶
func (Keeper) IncrementAbstainCount ¶
func (k Keeper) IncrementAbstainCount(ctx sdk.Context, operator sdk.ValAddress)
func (Keeper) IncrementMissCount ¶
func (k Keeper) IncrementMissCount(ctx sdk.Context, operator sdk.ValAddress)
func (Keeper) IncrementSuccessCount ¶
func (k Keeper) IncrementSuccessCount(ctx sdk.Context, operator sdk.ValAddress)
func (Keeper) IterateAggregateExchangeRateVotes ¶
func (k Keeper) IterateAggregateExchangeRateVotes(ctx sdk.Context, handler func(voterAddr sdk.ValAddress, aggregateVote types.AggregateExchangeRateVote) (stop bool))
IterateAggregateExchangeRateVotes iterates rate over votes in the store
func (Keeper) IterateBaseExchangeRates ¶
func (Keeper) IterateFeederDelegations ¶
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) IteratePriceSnapshots ¶
func (Keeper) IteratePriceSnapshotsReverse ¶
func (Keeper) IterateVotePenaltyCounters ¶
func (k Keeper) IterateVotePenaltyCounters(ctx sdk.Context, handler func(operator sdk.ValAddress, votePenaltyCounter types.VotePenaltyCounter) (stop bool), )
IterateVotePenaltyCounters iterates over the miss counters and performs a callback function.
func (Keeper) IterateVoteTargets ¶
func (Keeper) MinValidPerWindow ¶
MinValidPerWindow returns oracle slashing threshold
func (Keeper) OrganizeBallotByDenom ¶
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
func (Keeper) RemoveExcessFeeds ¶
func (Keeper) RewardBand ¶
RewardBand returns the ratio of allowable exchange rate error that a validator can be rewared
func (Keeper) SetAggregateExchangeRateVote ¶
func (k Keeper) SetAggregateExchangeRateVote(ctx sdk.Context, voter sdk.ValAddress, vote types.AggregateExchangeRateVote)
SetAggregateExchangeRateVote adds an oracle aggregate vote to the store
func (Keeper) SetBaseExchangeRate ¶
func (Keeper) SetBaseExchangeRateWithEvent ¶
func (Keeper) SetFeederDelegation ¶
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) SetPriceSnapshot ¶
func (k Keeper) SetPriceSnapshot(ctx sdk.Context, snapshot types.PriceSnapshot)
func (Keeper) SetSpamPreventionCounter ¶
func (k Keeper) SetSpamPreventionCounter(ctx sdk.Context, validatorAddr sdk.ValAddress)
func (Keeper) SetVotePenaltyCounter ¶
func (k Keeper) SetVotePenaltyCounter(ctx sdk.Context, operator sdk.ValAddress, missCount, abstainCount, successCount uint64)
SetVotePenaltyCounter updates the # of vote periods missed in this oracle slash window
func (Keeper) SetWhitelist ¶
SetWhitelist store new whitelist to param store this function is only for test purpose
func (Keeper) SlashAndResetCounters ¶
SlashAndResetCounters do slash any operator who over criteria & clear all operators miss counter to zero
func (Keeper) SlashFraction ¶
SlashFraction returns oracle voting penalty rate
func (Keeper) SlashWindow ¶
SlashWindow returns # of vote period for oracle slashing
func (Keeper) ValidateFeeder ¶
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) ValidateLookbackSeconds ¶
func (Keeper) VotePeriod ¶
VotePeriod returns the number of blocks during which voting takes place.
func (Keeper) VoteThreshold ¶
VoteThreshold returns the minimum percentage of votes that must be received for a ballot to pass.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator is a struct for handling in-place store migrations.
func (Migrator) Migrate2to3 ¶
Migrate2to3 migrates from version 2 to 3.
func (Migrator) Migrate3to4 ¶
Migrate3to4 migrates from version 3 to 4
func (Migrator) Migrate4to5 ¶
Migrate3to4 migrates from version 4 to 5
type TestInput ¶
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