Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeNewDifficultyTargetHash(prevTargetHash []byte, targetNumRelays, newRelaysEma uint64) []byte
- func GetShareAmountMap(serviceRevShare []*sharedtypes.ServiceRevenueShare, amountToDistribute uint64) (shareAmountMap map[string]uint64)
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- type Keeper
- func (k Keeper) ComputeUnitsToTokensMultiplier(ctx context.Context) uint64
- func (k Keeper) GetAllRelayMiningDifficulty(ctx context.Context) (list []types.RelayMiningDifficulty)
- func (k Keeper) GetAuthority() string
- func (k Keeper) GetParams(ctx context.Context) (params types.Params)
- func (k Keeper) GetRelayMiningDifficulty(ctx context.Context, serviceId string) (difficulty types.RelayMiningDifficulty, found bool)
- func (k Keeper) Logger() log.Logger
- func (k Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) ProcessTokenLogicModules(ctx context.Context, claim *prooftypes.Claim) (err error)
- func (k Keeper) RelayMiningDifficulty(ctx context.Context, req *types.QueryGetRelayMiningDifficultyRequest) (*types.QueryGetRelayMiningDifficultyResponse, error)
- func (k Keeper) RelayMiningDifficultyAll(ctx context.Context, req *types.QueryAllRelayMiningDifficultyRequest) (*types.QueryAllRelayMiningDifficultyResponse, error)
- func (k Keeper) RemoveRelayMiningDifficulty(ctx context.Context, serviceId string)
- func (k Keeper) SetParams(ctx context.Context, params types.Params) error
- func (k Keeper) SetRelayMiningDifficulty(ctx context.Context, relayMiningDifficulty types.RelayMiningDifficulty)
- func (k Keeper) SettlePendingClaims(ctx sdk.Context) (settledResult types.PendingClaimsResult, ...)
- func (k Keeper) TokenLogicModuleGlobalMint(ctx context.Context, service *sharedtypes.Service, ...) error
- func (k Keeper) TokenLogicModuleRelayBurnEqualsMint(ctx context.Context, service *sharedtypes.Service, ...) error
- func (k Keeper) UpdateRelayMiningDifficulty(ctx context.Context, relaysPerServiceMap map[string]uint64) (difficultyPerServiceMap map[string]types.RelayMiningDifficulty, err error)
- type TokenLogicModule
- type TokenLogicModuleProcessor
Constants ¶
const ( // TODO_BETA(@bryanchriswhite): Make all of these governance params MintAllocationDAO = 0.1 MintAllocationProposer = 0.05 MintAllocationSupplier = 0.7 MintAllocationSourceOwner = 0.15 MintAllocationApplication = 0.0 // MintDistributionAllowableTolerancePercent is the percent difference that is allowable // between the number of minted/ tokens in the tokenomics module and what is distributed // to pocket network participants. // This internal constant SHOULD ONLY be used in TokenLogicModuleGlobalMint. // Due to floating point arithmetic, the total amount of minted coins may be slightly // larger than what is distributed to pocket network participants // TODO_MAINNET: Figure out if we can avoid this tolerance and use fixed point arithmetic. MintDistributionAllowableTolerancePercent = 0.02 // 2% // MintDistributionAllowableToleranceAbsolution is similar to MintDistributionAllowableTolerancePercent // but provides an absolute number where the % difference might no be // meaningful for small absolute numbers. // TODO_MAINNET: Figure out if we can avoid this tolerance and use fixed point arithmetic. MintDistributionAllowableToleranceAbs = 5.0 // 5 uPOKT )
const TargetNumRelays = uint64(10e4)
TargetNumRelays is the target number of relays we want the network to mine for a specific service across all applications & suppliers per session. This number determines the total number of leafs to be created across in the off-chain SMTs, across all suppliers, for each service. It indirectly drives the off-chain resource requirements of the network in additional to playing a critical role in Relay Mining. TODO_BLOCKER(@Olshansk, #542): Make this a governance parameter.
Variables ¶
var ( // Governance parameters for the TLMGlobalMint module // TODO_UPNEXT(@olshansk, #732): Make this a governance parameter and give it a non-zero value + tests. MintPerClaimedTokenGlobalInflation = 0.1 )
Functions ¶
func ComputeNewDifficultyTargetHash ¶ added in v0.0.3
func ComputeNewDifficultyTargetHash(prevTargetHash []byte, targetNumRelays, newRelaysEma uint64) []byte
ComputeNewDifficultyTargetHash computes the new difficulty target hash based on the target number of relays we want the network to mine and the new EMA of the number of relays. NB: Exported for testing purposes only.
func GetShareAmountMap ¶ added in v0.0.6
func GetShareAmountMap( serviceRevShare []*sharedtypes.ServiceRevenueShare, amountToDistribute uint64, ) (shareAmountMap map[string]uint64)
GetShareAmountMap calculates the amount of uPOKT to distribute to each revenue shareholder based on the rev share percentage of the service. It returns a map of the shareholder address to the amount of uPOKT to distribute. The first shareholder gets any remainder due to floating point arithmetic. NB: It is publically exposed to be used in the tests.
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeService store.KVStoreService, logger log.Logger, authority string, bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, applicationKeeper types.ApplicationKeeper, supplierKeeper types.SupplierKeeper, proofKeeper types.ProofKeeper, sharedKeeper types.SharedKeeper, sessionKeeper types.SessionKeeper, serviceKeeper types.ServiceKeeper, ) Keeper
func (Keeper) ComputeUnitsToTokensMultiplier ¶
ComputeUnitsToTokensMultiplier returns the ComputeUnitsToTokensMultiplier param
func (Keeper) GetAllRelayMiningDifficulty ¶ added in v0.0.3
func (k Keeper) GetAllRelayMiningDifficulty(ctx context.Context) (list []types.RelayMiningDifficulty)
GetAllRelayMiningDifficulty returns all relayMiningDifficulty
func (Keeper) GetAuthority ¶
GetAuthority returns the x/tokenomics module's authority.
func (Keeper) GetRelayMiningDifficulty ¶ added in v0.0.3
func (k Keeper) GetRelayMiningDifficulty( ctx context.Context, serviceId string, ) (difficulty types.RelayMiningDifficulty, found bool)
GetRelayMiningDifficulty returns a relayMiningDifficulty from its index
func (Keeper) Params ¶
func (k Keeper) Params( ctx context.Context, req *types.QueryParamsRequest, ) (*types.QueryParamsResponse, error)
func (Keeper) ProcessTokenLogicModules ¶ added in v0.0.6
func (k Keeper) ProcessTokenLogicModules( ctx context.Context, claim *prooftypes.Claim, ) (err error)
ProcessTokenLogicModules is the entrypoint for all TLM processing.
It is responsible for running all the independent TLMs necessary to limit, burn, mint or transfer tokens as a result of the amount of work (i.e. relays, compute units) done in proportion to the global governance parameters.
Prior to running the TLMs, it handles the business logic of converting the claimed amount to the actual settlement amount and handling the case for overserviced applications.
IMPORTANT: It is assumed that the proof for the claim has been validated BEFORE calling this function.
func (Keeper) RelayMiningDifficulty ¶ added in v0.0.3
func (k Keeper) RelayMiningDifficulty(ctx context.Context, req *types.QueryGetRelayMiningDifficultyRequest) (*types.QueryGetRelayMiningDifficultyResponse, error)
func (Keeper) RelayMiningDifficultyAll ¶ added in v0.0.3
func (k Keeper) RelayMiningDifficultyAll(ctx context.Context, req *types.QueryAllRelayMiningDifficultyRequest) (*types.QueryAllRelayMiningDifficultyResponse, error)
func (Keeper) RemoveRelayMiningDifficulty ¶ added in v0.0.3
RemoveRelayMiningDifficulty removes a relayMiningDifficulty from the store
func (Keeper) SetRelayMiningDifficulty ¶ added in v0.0.3
func (k Keeper) SetRelayMiningDifficulty(ctx context.Context, relayMiningDifficulty types.RelayMiningDifficulty)
SetRelayMiningDifficulty set a specific relayMiningDifficulty in the store from its index
func (Keeper) SettlePendingClaims ¶
func (k Keeper) SettlePendingClaims(ctx sdk.Context) ( settledResult types.PendingClaimsResult, expiredResult types.PendingClaimsResult, err error, )
SettlePendingClaims settles all pending (i.e. expiring) claims. If a claim is expired and requires a proof and a proof IS available -> it's settled. If a claim is expired and requires a proof and a proof IS NOT available -> it's deleted. If a claim is expired and does NOT require a proof -> it's settled. Events are emitted for each claim that is settled or removed. On-chain Claims & Proofs are deleted after they're settled or expired to free up space.
TODO_TECHDEBT: Refactor this function to return a struct instead of multiple return values.
func (Keeper) TokenLogicModuleGlobalMint ¶ added in v0.0.6
func (k Keeper) TokenLogicModuleGlobalMint( ctx context.Context, service *sharedtypes.Service, _ *sessiontypes.SessionHeader, application *apptypes.Application, supplier *sharedtypes.Supplier, actualSettlementCoin cosmostypes.Coin, relayMiningDifficulty *tokenomictypes.RelayMiningDifficulty, ) error
TokenLogicModuleGlobalMint processes the business logic for the GlobalMint TLM.
func (Keeper) TokenLogicModuleRelayBurnEqualsMint ¶ added in v0.0.6
func (k Keeper) TokenLogicModuleRelayBurnEqualsMint( ctx context.Context, service *sharedtypes.Service, _ *sessiontypes.SessionHeader, application *apptypes.Application, supplier *sharedtypes.Supplier, actualSettlementCoin cosmostypes.Coin, relayMiningDifficulty *tokenomictypes.RelayMiningDifficulty, ) error
TokenLogicModuleRelayBurnEqualsMint processes the business logic for the RelayBurnEqualsMint TLM.
func (Keeper) UpdateRelayMiningDifficulty ¶ added in v0.0.3
func (k Keeper) UpdateRelayMiningDifficulty( ctx context.Context, relaysPerServiceMap map[string]uint64, ) (difficultyPerServiceMap map[string]types.RelayMiningDifficulty, err error)
UpdateRelayMiningDifficulty updates the on-chain relay mining difficulty based on the amount of on-chain relays for each service, given a map of serviceId->numRelays.
type TokenLogicModule ¶ added in v0.0.6
type TokenLogicModule int
const ( // TLMRelayBurnEqualsMint is the token logic module that burns the application's // stake balance based on the amount of work done by the supplier. // The same amount of tokens is minted and added to the supplier account balance. // When the network achieves maturity in the far future, this is theoretically // the only TLM that will be necessary. TLMRelayBurnEqualsMint TokenLogicModule = iota // TLMGlobalMint is the token logic module that mints new tokens based on the // global governance parameters in order to reward the participants providing // services while keeping inflation in check. TLMGlobalMint )
func (TokenLogicModule) EnumIndex ¶ added in v0.0.6
func (tlm TokenLogicModule) EnumIndex() int
func (TokenLogicModule) String ¶ added in v0.0.6
func (tlm TokenLogicModule) String() string
type TokenLogicModuleProcessor ¶ added in v0.0.6
type TokenLogicModuleProcessor func( Keeper, context.Context, *sharedtypes.Service, *sessiontypes.SessionHeader, *apptypes.Application, *sharedtypes.Supplier, cosmostypes.Coin, *tokenomictypes.RelayMiningDifficulty, ) error
TokenLogicModuleProcessor is the method signature that all token logic modules are expected to implement. IMPORTANT_SIDE_EFFECTS: Please note that TLMs may update the application and supplier objects, which is why they are passed in as pointers. NOTE: TLMs SHOULD NOT persist any state changes. Persistence of updated application and supplier to the keeper is currently done by the TLM processor in `ProcessTokenLogicModules()`. This design and separation of concerns may change in the future. DEV_NOTE: As of writing this, this is only in anticipation of potentially unstaking actors if their stake falls below a certain threshold.