keeper

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TODO_UPNEXT(@olshansk): Make all of the governance params
	MintAllocationDAO         = 0.1
	MintAllocationProposer    = 0.05
	MintAllocationSupplier    = 0.7
	MintAllocationSourceOwner = 0.15
	MintAllocationApplication = 0.0
	// TODO_UPNEXT(@olshansk): Remove this. An ephemeral placeholder before
	// real values are introduced. When this is changed to a governance param,
	// make sure to also add the necessary unit tests.
	MintGlobalAllocation = 0.0000000
)
View Source
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

This section is empty.

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

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func (k Keeper) ComputeUnitsToTokensMultiplier(ctx context.Context) uint64

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

func (k Keeper) GetAuthority() string

GetAuthority returns the x/tokenomics module's authority.

func (Keeper) GetParams

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

GetParams get all parameters as types.Params

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

func (k Keeper) Logger() log.Logger

Logger returns a module-specific logger.

func (Keeper) Params

func (Keeper) ProcessTokenLogicModules added in v0.0.6

func (k Keeper) ProcessTokenLogicModules(
	ctx context.Context,
	claim *prooftypes.Claim,
) (err error)

ProcessTokenLogicModules is responsible for calling all of the token logic modules (i.e. post session claim accounting) necessary to burn, mint or transfer tokens as a result of the amount of work (i.e. compute units) done.

func (Keeper) RelayMiningDifficultyAll added in v0.0.3

func (Keeper) RemoveRelayMiningDifficulty added in v0.0.3

func (k Keeper) RemoveRelayMiningDifficulty(
	ctx context.Context,
	serviceId string,
)

RemoveRelayMiningDifficulty removes a relayMiningDifficulty from the store

func (Keeper) SetParams

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

SetParams set the params

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,
	application *apptypes.Application,
	supplier *sharedtypes.Supplier,
	settlementCoins cosmostypes.Coin,
	relayMiningDifficulty *tokenomictypes.RelayMiningDifficulty,
) error

TokenLogicModuleGlobalMint processes the business logic for the GlobalMint TLM. TODO_UPNEXT(@olshansk): Delete this in favor of a real TLM that mints tokens and distributes them to the appropriate accounts via boosts.

func (Keeper) TokenLogicModuleRelayBurnEqualsMint added in v0.0.6

func (k Keeper) TokenLogicModuleRelayBurnEqualsMint(
	ctx context.Context,
	service *sharedtypes.Service,
	application *apptypes.Application,
	supplier *sharedtypes.Supplier,
	settlementCoin 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 TokenLogicModule = iota
	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

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. However, this IS NOT persisted. The persistence to the keeper is currently done by ProcessTokenLogicModules only. This may be an interim state of the implementation and may change in the future.

Jump to

Keyboard shortcuts

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