keeper

package
v3.1.7-near-hf Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EPOCH_BLOCK_DIVIDER uint64 = 5 // determines how many blocks from the previous epoch will be included in the average block time calculation
	MIN_SAMPLE_STEP     uint64 = 1 // the minimal sample step when calculating the average block time
)
View Source
const (
	MAX_CHANGE_RATE = 1
	CHANGE_WINDOW   = time.Hour * 24
)
View Source
const (
	THRESHOLD_FACTOR = 4
	SOFT_JAILS       = 2
	SOFT_JAIL_TIME   = 1 * time.Hour / time.Second
	HARD_JAIL_TIME   = 24 * time.Hour / time.Second
)

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

Types

type BadgeData

type BadgeData struct {
	Badge       types.Badge
	BadgeSigner sdk.AccAddress
}

type EpochCuCache

type EpochCuCache struct {
	Keeper
	ProviderEpochCuCache           *cachekv.Store
	ProviderEpochComplainerCuCache *cachekv.Store
	ProviderConsumerEpochCuCache   *cachekv.Store
}

########## EpochCuCache ############

func (EpochCuCache) AddEpochPayment

func (k EpochCuCache) AddEpochPayment(ctx sdk.Context, chainID string, epoch uint64, project string, provider string, cu uint64, sessionID uint64) uint64

AddEpochPayment adds a new epoch payment and returns the updated CU used between provider and project

func (EpochCuCache) Flush

func (k EpochCuCache) Flush()

func (EpochCuCache) GetProviderConsumerEpochCuCached

func (k EpochCuCache) GetProviderConsumerEpochCuCached(ctx sdk.Context, epoch uint64, provider string, project string, chainID string) (val types.ProviderConsumerEpochCu, found bool)

func (EpochCuCache) GetProviderEpochComplainerCuCached

func (k EpochCuCache) GetProviderEpochComplainerCuCached(ctx sdk.Context, epoch uint64, provider string, chainID string) (val types.ProviderEpochComplainerCu, found bool)

func (EpochCuCache) GetProviderEpochCuCached

func (k EpochCuCache) GetProviderEpochCuCached(ctx sdk.Context, epoch uint64, provider string, chainID string) (val types.ProviderEpochCu, found bool)

func (EpochCuCache) SetProviderConsumerEpochCuCached

func (k EpochCuCache) SetProviderConsumerEpochCuCached(ctx sdk.Context, epoch uint64, provider string, project string, chainID string, providerConsumerEpochCu types.ProviderConsumerEpochCu)

func (EpochCuCache) SetProviderEpochComplainerCuCached

func (k EpochCuCache) SetProviderEpochComplainerCuCached(ctx sdk.Context, epoch uint64, provider string, chainID string, providerEpochCu types.ProviderEpochComplainerCu)

func (EpochCuCache) SetProviderEpochCuCached

func (k EpochCuCache) SetProviderEpochCuCached(ctx sdk.Context, epoch uint64, provider string, chainID string, providerEpochCu types.ProviderEpochCu)

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey storetypes.StoreKey,
	ps paramtypes.Subspace,

	bankKeeper types.BankKeeper,
	accountKeeper types.AccountKeeper,
	specKeeper types.SpecKeeper,
	epochStorageKeeper types.EpochstorageKeeper,
	projectsKeeper types.ProjectsKeeper,
	subscriptionKeeper types.SubscriptionKeeper,
	planKeeper types.PlanKeeper,
	downtimeKeeper types.DowntimeKeeper,
	dualstakingKeeper types.DualstakingKeeper,
	stakingKeeper types.StakingKeeper,
	fixationStoreKeeper types.FixationStoreKeeper,
	timerStoreKeeper types.TimerStoreKeeper,
) *Keeper

func (Keeper) BadgeUsedCuExpiry

func (k Keeper) BadgeUsedCuExpiry(ctx sdk.Context, badge types.Badge) uint64

func (Keeper) BailEntry

func (k Keeper) BailEntry(ctx sdk.Context, address string, chainID string, bail sdk.Coin) error

func (Keeper) BeginBlock

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

func (Keeper) CalculateEffectiveAllowedCuPerEpochFromPolicies

func (k Keeper) CalculateEffectiveAllowedCuPerEpochFromPolicies(policies []*planstypes.Policy, cuUsedInProject, cuLeftInSubscription uint64) (allowedCUThisEpoch, allowedCUTotal uint64)

func (Keeper) CalculateEffectiveGeolocationFromPolicies

func (k Keeper) CalculateEffectiveGeolocationFromPolicies(policies []*planstypes.Policy) (int32, error)

func (Keeper) CalculateEffectiveProvidersToPairFromPolicies

func (k Keeper) CalculateEffectiveProvidersToPairFromPolicies(policies []*planstypes.Policy) (uint64, error)

func (Keeper) CalculateEffectiveSelectedProviders

func (k Keeper) CalculateEffectiveSelectedProviders(policies []*planstypes.Policy) (planstypes.SELECTED_PROVIDERS_MODE, []string)

func (Keeper) CalculatePairingChance

func (k Keeper) CalculatePairingChance(ctx sdk.Context, provider string, chainID string, policy *planstypes.Policy, cluster string) (cosmosmath.LegacyDec, error)

CalculatePairingChance calculates the chance of a provider to be picked in the pairing process for the first pairing slot

func (Keeper) CreditStakeEntry

func (k Keeper) CreditStakeEntry(ctx sdk.Context, chainID string, lookUpAddress sdk.AccAddress, creditAmount sdk.Coin) (bool, error)

func (Keeper) EndBlock

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

func (Keeper) EnforceClientCUsUsageInEpoch

func (k Keeper) EnforceClientCUsUsageInEpoch(ctx sdk.Context, relayCU, epochAllowedCU, totalCUInEpochForUserProvider uint64, clientAddr sdk.AccAddress, chainID string, epoch uint64) (uint64, error)

func (Keeper) EpochBlocksOverlap

func (k Keeper) EpochBlocksOverlap(ctx sdk.Context) uint64

func (Keeper) ExportBadgesTimers

func (k Keeper) ExportBadgesTimers(ctx sdk.Context) timertypes.GenesisState

ExportBadgesTimers exports badges timers data (for genesis)

func (Keeper) ExportProviderQoS

func (k Keeper) ExportProviderQoS(ctx sdk.Context) fixationtypes.GenesisState

func (Keeper) FreezeProvider

func (k Keeper) FreezeProvider(ctx sdk.Context, provider string, chainIDs []string, reason string) error

func (Keeper) GetAllBadgeUsedCu

func (k Keeper) GetAllBadgeUsedCu(ctx sdk.Context) (list []types.BadgeUsedCu)

GetAllBadgeUsedCu returns all badgeUsedCu

func (Keeper) GetAllChainIDs

func (k Keeper) GetAllChainIDs(ctx sdk.Context) []string

func (Keeper) GetAllProviderConsumerEpochCu

func (k Keeper) GetAllProviderConsumerEpochCu(ctx sdk.Context, epoch uint64) []types.ProviderConsumerEpochCuGenesis

GetAllProviderConsumerEpochCuStore returns all the ProviderConsumerEpochCu from the store (used for genesis)

func (Keeper) GetAllProviderConsumerEpochCuStore

func (k Keeper) GetAllProviderConsumerEpochCuStore(ctx sdk.Context) []types.ProviderConsumerEpochCuGenesis

GetAllProviderConsumerEpochCuStore returns all the ProviderConsumerEpochCu from the store (used for genesis)

func (Keeper) GetAllProviderEpochComplainerCuStore

func (k Keeper) GetAllProviderEpochComplainerCuStore(ctx sdk.Context) []types.ProviderEpochComplainerCuGenesis

GetAllProviderEpochComplainerCuStore returns all the ProviderEpochCu from the store (used for genesis)

func (Keeper) GetAllProviderEpochCuStore

func (k Keeper) GetAllProviderEpochCuStore(ctx sdk.Context) []types.ProviderEpochCuGenesis

GetAllProviderEpochCuStore returns all the ProviderEpochCu from the store (used for genesis)

func (Keeper) GetAllUniqueEpochSessionForEpoch

func (k Keeper) GetAllUniqueEpochSessionForEpoch(ctx sdk.Context, epoch uint64) []string

GetAllUniqueEpochSessionForEpoch gets all the UniqueEpochSession objects from the store for a specific epoch

func (Keeper) GetAllUniqueEpochSessionStore

func (k Keeper) GetAllUniqueEpochSessionStore(ctx sdk.Context) []types.UniqueEpochSessionGenesis

GetAllUniqueEpochSessionStore gets all the UniqueEpochSession objects from the store (used for genesis)

func (Keeper) GetBadgeUsedCu

func (k Keeper) GetBadgeUsedCu(
	ctx sdk.Context,
	badgeUsedCuKey []byte,
) (val types.BadgeUsedCu, found bool)

GetBadgeUsedCu returns a badgeUsedCu from its index

func (Keeper) GetPairing

Gets a client's provider list in a specific chain. Also returns the start block of the current epoch, time (in seconds) until there's a new pairing, the block that the chain in the request's spec was changed

func (Keeper) GetPairingForClient

func (k Keeper) GetPairingForClient(ctx sdk.Context, chainID string, clientAddress sdk.AccAddress) (providers []epochstoragetypes.StakeEntry, errorRet error)

func (Keeper) GetPairingQueryCache

func (k Keeper) GetPairingQueryCache(project string, chainID string, epoch uint64) ([]epochstoragetypes.StakeEntry, bool)

func (Keeper) GetPairingRelayCache

func (k Keeper) GetPairingRelayCache(ctx sdk.Context, project string, chainID string, epoch uint64) ([]epochstoragetypes.StakeEntry, uint64, bool)

func (Keeper) GetParams

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

GetParams get all parameters as types.Params

func (Keeper) GetProjectData

func (k Keeper) GetProjectData(ctx sdk.Context, developerKey sdk.AccAddress, chainID string, blockHeight uint64) (proj projectstypes.Project, errRet error)

func (Keeper) GetProjectStrictestPolicy

func (k Keeper) GetProjectStrictestPolicy(ctx sdk.Context, project projectstypes.Project, chainID string, block uint64) (*planstypes.Policy, string, error)

func (Keeper) GetProviderConsumerEpochCu

func (k Keeper) GetProviderConsumerEpochCu(ctx sdk.Context, epoch uint64, provider string, project string, chainID string) (val types.ProviderConsumerEpochCu, found bool)

GetProviderConsumerEpochCu returns a ProviderConsumerEpochCu for a specific epoch, provider and project

func (Keeper) GetProviderEpochComplainerCu

func (k Keeper) GetProviderEpochComplainerCu(ctx sdk.Context, epoch uint64, provider string, chainID string) (val types.ProviderEpochComplainerCu, found bool)

GetProviderEpochComplainerCu returns a ProviderEpochCu for a specific epoch and provider

func (Keeper) GetProviderEpochCu

func (k Keeper) GetProviderEpochCu(ctx sdk.Context, epoch uint64, provider string, chainID string) (val types.ProviderEpochCu, found bool)

GetProviderEpochCu returns a ProviderEpochCu for a specific epoch and provider

func (Keeper) GetQos

func (k Keeper) GetQos(ctx sdk.Context, chainID string, cluster string, provider string) (pairingtypes.QualityOfServiceReport, error)

GetQos gets a provider's QoS excellence report from the providerQosFS

func (Keeper) GetStakeEntry

func (k Keeper) GetStakeEntry(ctx sdk.Context, chainID string, provider string) (epochstoragetypes.StakeEntry, error)

func (Keeper) InitBadgeTimers

func (k Keeper) InitBadgeTimers(ctx sdk.Context, gs timertypes.GenesisState)

InitBadgeTimers imports badges timers data (from genesis)

func (Keeper) InitProviderQoS

func (k Keeper) InitProviderQoS(ctx sdk.Context, gs fixationtypes.GenesisState)

func (Keeper) IsUniqueEpochSessionExists

func (k Keeper) IsUniqueEpochSessionExists(ctx sdk.Context, epoch uint64, provider string, project string, chainID string, sessionID uint64) bool

IsUniqueEpochSessionExists checks if a UniqueEpochSession exists

func (Keeper) JailEntry

func (k Keeper) JailEntry(ctx sdk.Context, address string, chainID string, jailStartBlock, jailBlocks uint64, bail sdk.Coin) error

func (Keeper) Logger

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

func (Keeper) NewEpochCuCacheHandler

func (k Keeper) NewEpochCuCacheHandler(ctx sdk.Context) EpochCuCache

func (Keeper) Params

func (Keeper) Provider

func (Keeper) ProviderPairingChance

Gets a client's provider list in a specific chain. Also returns the start block of the current epoch, time (in seconds) until there's a new pairing, the block that the chain in the request's spec was changed

func (Keeper) Providers

func (Keeper) PunishUnresponsiveProviders

func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUForUnresponsiveProvider, epochsNumToCheckCUForComplainers uint64)

PunishUnresponsiveProviders punished unresponsive providers (current punishment: freeze)

func (Keeper) QoSWeight

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

func (Keeper) RecommendedEpochNumToCollectPayment

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

RecommendedEpochNumToCollectPayment returns the RecommendedEpochNumToCollectPayment param

func (Keeper) RemoveAllEpochPaymentsForBlockAppendAdjustments

func (k Keeper) RemoveAllEpochPaymentsForBlockAppendAdjustments(ctx sdk.Context, epochToDelete uint64)

Function to remove all epoch payments objects from a specific epoch

func (Keeper) RemoveAllProviderEpochComplainerCu

func (k Keeper) RemoveAllProviderEpochComplainerCu(ctx sdk.Context, epoch uint64)

RemoveProviderEpochComplainerCu removes a ProviderEpochCu from the store

func (Keeper) RemoveAllProviderEpochCu

func (k Keeper) RemoveAllProviderEpochCu(ctx sdk.Context, epoch uint64)

RemoveProviderEpochCu removes a ProviderEpochCu from the store

func (Keeper) RemoveAllUniqueEpochSession

func (k Keeper) RemoveAllUniqueEpochSession(ctx sdk.Context, epoch uint64)

RemoveAllUniqueEpochSession removes all the UniqueEpochSession objects from the store for a specific epoch

func (Keeper) RemoveBadgeUsedCu

func (k Keeper) RemoveBadgeUsedCu(
	ctx sdk.Context,
	badgeUsedCuKey []byte,
)

RemoveBadgeUsedCu removes a badgeUsedCu from the store

func (Keeper) RemoveOldEpochPayments

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

Function to remove epoch payment objects from deleted epochs (older than the chain's memory)

func (Keeper) RemoveProviderConsumerEpochCu

func (k Keeper) RemoveProviderConsumerEpochCu(ctx sdk.Context, epoch uint64, provider string, project string, chainID string)

RemoveProviderConsumerEpochCu removes a ProviderConsumerEpochCu from the store

func (Keeper) RemoveProviderEpochComplainerCu

func (k Keeper) RemoveProviderEpochComplainerCu(ctx sdk.Context, epoch uint64, provider string, chainID string)

RemoveProviderEpochComplainerCu deletes a ProviderEpochComplainerCu in the store

func (Keeper) ResetPairingRelayCache

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

ResetPairingRelayCache is used to remove all entries from the PairingRelayCache KV store this function is called in the module's EndBlock so the data written in the KV store will be deleted before it's written to the state

func (Keeper) SdkPairing

func (Keeper) SetBadgeUsedCu

func (k Keeper) SetBadgeUsedCu(ctx sdk.Context, badgeUsedCu types.BadgeUsedCu)

SetBadgeUsedCu set a specific badgeUsedCu in the store from its index

func (Keeper) SetPairingQueryCache

func (k Keeper) SetPairingQueryCache(project string, chainID string, epoch uint64, pairedProviders []epochstoragetypes.StakeEntry)

the cache used for the query, does not write into state

func (Keeper) SetPairingRelayCache

func (k Keeper) SetPairingRelayCache(ctx sdk.Context, project string, chainID string, epoch uint64, pairedProviders []epochstoragetypes.StakeEntry, allowedCu uint64)

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) SetProviderConsumerEpochCu

func (k Keeper) SetProviderConsumerEpochCu(ctx sdk.Context, epoch uint64, provider string, project string, chainID string, providerConsumerEpochCu types.ProviderConsumerEpochCu)

SetProviderConsumerEpochCu sets a ProviderConsumerEpochCu in the store

func (Keeper) SetProviderEpochComplainerCu

func (k Keeper) SetProviderEpochComplainerCu(ctx sdk.Context, epoch uint64, provider string, chainID string, providerEpochCu types.ProviderEpochComplainerCu)

SetProviderEpochComplainerCu sets a ProviderEpochComplainerCu in the store

func (Keeper) SetProviderEpochCu

func (k Keeper) SetProviderEpochCu(ctx sdk.Context, epoch uint64, provider string, chainID string, providerEpochCu types.ProviderEpochCu)

SetProviderEpochCu sets a ProviderEpochCu in the store

func (Keeper) SetRecommendedEpochNumToCollectPayment

func (k Keeper) SetRecommendedEpochNumToCollectPayment(ctx sdk.Context, val uint64)

func (Keeper) SetUniqueEpochSession

func (k Keeper) SetUniqueEpochSession(ctx sdk.Context, epoch uint64, provider string, project string, chainID string, sessionID uint64)

SetUniqueEpochSession sets a UniqueEpochSession in the store

func (Keeper) SlashDelegator

func (k Keeper) SlashDelegator(ctx sdk.Context, slashingInfo types.DelegatorSlashing) error

func (Keeper) SlashEntry

func (k Keeper) SlashEntry(ctx sdk.Context, address string, chainID string, percentage sdk.Dec) (sdk.Coin, error)

func (Keeper) StakeNewEntry

func (k Keeper) StakeNewEntry(ctx sdk.Context, validator, creator, chainID string, amount sdk.Coin, endpoints []epochstoragetypes.Endpoint, geolocation int32, delegationLimit sdk.Coin, delegationCommission uint64, provider string, description stakingtypes.Description) error

func (Keeper) UnstakeEntry

func (k Keeper) UnstakeEntry(ctx sdk.Context, validator, chainID, creator, unstakeDescription string) error

func (Keeper) UnstakeEntryForce

func (k Keeper) UnstakeEntryForce(ctx sdk.Context, chainID, provider, unstakeDescription string) error

func (Keeper) UserEntry

func (Keeper) ValidatePairingForClient

func (k Keeper) ValidatePairingForClient(ctx sdk.Context, chainID string, providerAddress sdk.AccAddress, reqEpoch uint64, project projectstypes.Project) (isValidPairing bool, allowedCU uint64, pairedProviders []epochstoragetypes.StakeEntry, errorRet error)

func (Keeper) VerifyPairingData

func (k Keeper) VerifyPairingData(ctx sdk.Context, chainID string, block uint64) (epoch uint64, providersType spectypes.Spec_ProvidersTypes, errorRet error)

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(keeper Keeper) Migrator

func (Migrator) MigrateVersion2To3

func (m Migrator) MigrateVersion2To3(ctx sdk.Context) error

MigrateVersion2To3 removes all the old payment objects (to get a fresh start for the new ones)

func (Migrator) MigrateVersion3To4

func (m Migrator) MigrateVersion3To4(ctx sdk.Context) error

MigrateVersion3To4 fix delegation total in the stake entries

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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