Documentation ¶
Index ¶
- Constants
- func ChurnRequestsGetActiveTopicsAndDemand(ctx sdk.Context, k keeper.Keeper, currentTime uint64) ([]state.Topic, cosmosMath.Uint, error)
- func GetParticipantEmissionsForTopic(ctx sdk.Context, am AppModule, topicId keeper.TOPIC_ID, topicStake *Uint, ...) (rewards map[string]*Uint, err error)
- func GetRequestsThatMaxFees(ctx sdk.Context, k keeper.Keeper, currentTime uint64, ...) (bestPrice cosmosMath.Uint, maxFees cosmosMath.Uint, ...)
- func InactivateLowDemandTopics(ctx context.Context, k keeper.Keeper) (remainingActiveTopics []*state.Topic, err error)
- func IsValidAtPrice(ctx sdk.Context, k keeper.Keeper, req state.InferenceRequest, ...) (bool, error)
- func MaskWeightsIfInsufficientLiveness(ctx sdk.Context, am AppModule, topicId keeper.TOPIC_ID, ...) (map[string]map[string]*Uint, error)
- func SortTopicsByReturnDescWithRandomTiebreaker(valsToSort []state.Topic, weights map[TopicId]PriceAndReturn, randSeed uint64) []state.Topic
- type AppModule
- func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions
- func (AppModule) ConsensusVersion() uint64
- func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
- func (am AppModule) EndBlock(ctx context.Context) error
- func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage)
- func (am AppModule) IsAppModule()
- func (am AppModule) IsOnePerModuleType()
- func (AppModule) Name() string
- func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux)
- func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry)
- func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
- func (am AppModule) RegisterServices(cfg module.Configurator)
- func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error
- type BlocklessRequest
- type Config
- type Demand
- type EnvVar
- type Float
- type InferenceItem
- type LatestInferences
- type ModuleInputs
- type ModuleOutputs
- type Number
- type PriceAndReturn
- type RequestId
- type SortableItem
- type TopicId
- type Uint
- type WeightInferencePayload
Constants ¶
const ConsensusVersion = 1
ConsensusVersion defines the current module consensus version.
Variables ¶
This section is empty.
Functions ¶
func ChurnRequestsGetActiveTopicsAndDemand ¶
func ChurnRequestsGetActiveTopicsAndDemand(ctx sdk.Context, k keeper.Keeper, currentTime uint64) ([]state.Topic, cosmosMath.Uint, error)
The price of inference for a topic is determined by the price that maximizes the demand drawn from valid requests. Which topics get processed (inference solicitation and weight-adjustment) is based on ordering topics by their return at their optimal prices and then skimming the top.
func GetParticipantEmissionsForTopic ¶
func GetParticipantEmissionsForTopic( ctx sdk.Context, am AppModule, topicId keeper.TOPIC_ID, topicStake *Uint, cumulativeEmission *Uint, accumulatedMetDemand *Uint, totalStake *Uint) (rewards map[string]*Uint, err error)
******************************************************** * PUBLIC EXPORTED READ-ONLY FUNCTIONS * ******************************************************** For a given topic: given the sum total of all stake in that topic, given the amount of new tokens scheduled to be emitted this epoch, given the total amount of stake in the network, return the amount of new tokens to be emitted to each partipicant in that topic
func GetRequestsThatMaxFees ¶
func GetRequestsThatMaxFees( ctx sdk.Context, k keeper.Keeper, currentTime uint64, requestsForGivenTopic []state.InferenceRequest) ( bestPrice cosmosMath.Uint, maxFees cosmosMath.Uint, requests []state.InferenceRequest, err error)
Generate a demand curve, which is a data structure that captures the price that maximizes the demand drawn from valid requests. Each price is mapped to the list of people willing to pay AT LEAST that price for inference. Then the maximum amount of fees is found by multiplying the price by the number of requests willing to pay at least that price. TODO: think if we can sort the data structure first, then process it in order to do O(2*n) probably we can use some kind of ordered tree to do this instead of what we are currently doing which is O(n^2)
func InactivateLowDemandTopics ¶
func InactivateLowDemandTopics(ctx context.Context, k keeper.Keeper) (remainingActiveTopics []*state.Topic, err error)
Inactivates topics with below keeper.MIN_TOPIC_UNMET_DEMAND demand returns a list of topics that are still active after this operation
func IsValidAtPrice ¶
func IsValidAtPrice( ctx sdk.Context, k keeper.Keeper, req state.InferenceRequest, price cosmosMath.Uint, currentTime uint64) (bool, error)
Check that a request:
should be checked in this timestep AND did not expire AND would have enough funds to cover the potential next price AND admits and acceptable max price per inference
func MaskWeightsIfInsufficientLiveness ¶ added in v0.0.1
func MaskWeightsIfInsufficientLiveness( ctx sdk.Context, am AppModule, topicId keeper.TOPIC_ID, weights map[string]map[string]*Uint) (map[string]map[string]*Uint, error)
This function checks topic weights and then masks them if not enough inferences were collected in that timestep It should:
mask the inputted weights above with GetNumInferencesInRewardEpoch(), checking inference cadence by reward epoch length / topic inference cadence simple forgiveness check (only if many inferences are missing, don't reward)
func SortTopicsByReturnDescWithRandomTiebreaker ¶
func SortTopicsByReturnDescWithRandomTiebreaker(valsToSort []state.Topic, weights map[TopicId]PriceAndReturn, randSeed uint64) []state.Topic
Sorts the given slice of topics in descending order according to their corresponding return, using randomness as tiebreaker e.g. ([]uint64{1, 2, 3}, map[uint64]uint64{1: 2, 2: 2, 3: 3}, 0) -> [3, 1, 2] or [3, 2, 1]
Types ¶
type AppModule ¶
type AppModule struct {
// contains filtered or unexported fields
}
func NewAppModule ¶
NewAppModule creates a new AppModule object
func (AppModule) AutoCLIOptions ¶
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions
AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
func (AppModule) ConsensusVersion ¶
ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) DefaultGenesis ¶
func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
DefaultGenesis returns default genesis state as raw bytes for the module.
func (AppModule) ExportGenesis ¶
ExportGenesis returns the exported genesis state as raw bytes for the circuit module.
func (AppModule) InitGenesis ¶
InitGenesis performs genesis initialization for the state module. It returns no validator updates.
func (AppModule) IsAppModule ¶
func (am AppModule) IsAppModule()
IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsOnePerModuleType ¶
func (am AppModule) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModule) RegisterGRPCGatewayRoutes ¶
RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the state module.
func (AppModule) RegisterInterfaces ¶
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry)
RegisterInterfaces registers interfaces and implementations of the state module.
func (AppModule) RegisterLegacyAminoCodec ¶
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
RegisterLegacyAminoCodec registers the state module's types on the LegacyAmino codec. New modules do not need to support Amino.
func (AppModule) RegisterServices ¶
func (am AppModule) RegisterServices(cfg module.Configurator)
RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries.
func (AppModule) ValidateGenesis ¶
func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error
ValidateGenesis performs genesis state validation for the circuit module.
type BlocklessRequest ¶
type Demand ¶
type Demand struct { Requests []state.InferenceRequest FeesGenerated cosmosMath.Uint }
type InferenceItem ¶
type LatestInferences ¶
type LatestInferences struct { Timestamp string `json:"timestamp"` Inferences []InferenceItem `json:"inferences"` }
type ModuleInputs ¶
type ModuleInputs struct { depinject.In Cdc codec.Codec StoreService store.KVStoreService AddressCodec address.Codec AccountKeeper keeper.AccountKeeper BankKeeper keeper.BankKeeper Config *modulev1.Module }
type ModuleOutputs ¶
func ProvideModule ¶
func ProvideModule(in ModuleInputs) ModuleOutputs
type Number ¶
type Number interface { *Float | *cosmosMath.Uint }
type PriceAndReturn ¶
type PriceAndReturn = struct { Price cosmosMath.Uint Return cosmosMath.Uint }
type SortableItem ¶
A structure to hold the original value and a random tiebreaker
type Uint ¶
type Uint = cosmosMath.Uint
type WeightInferencePayload ¶
type WeightInferencePayload struct { Inferences []LatestInferences `json:"inferences"` LatestWeights map[string]string `json:"latest_weights"` }