keeper

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 23 Imported by: 4

Documentation

Index

Constants

This section is empty.

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.

func RawBundleToQueryBundle added in v1.2.3

func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap map[int32]uint64) (queryBundle queryTypes.FinalizedBundle)

Types

type Keeper

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

func NewKeeper

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

	authority string,

	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	distrkeeper types.DistrKeeper,
	poolKeeper types.PoolKeeper,
	stakerKeeper types.StakerKeeper,
	delegationKeeper types.DelegationKeeper,
	fundersKeeper types.FundersKeeper,
) *Keeper

func (Keeper) AssertCanPropose

func (k Keeper) AssertCanPropose(ctx sdk.Context, poolId uint64, staker string, proposer string, fromIndex uint64) error

AssertCanPropose checks whether a participant can submit the next bundle proposal in a storage pool

func (Keeper) AssertCanVote

func (k Keeper) AssertCanVote(ctx sdk.Context, poolId uint64, staker string, voter string, storageId string) error

AssertCanVote checks whether a participant in the network can vote on a bundle proposal in a storage pool

func (Keeper) AssertPoolCanRun

func (k Keeper) AssertPoolCanRun(ctx sdk.Context, poolId uint64) error

AssertPoolCanRun checks whether the given pool fulfils all technical/formal requirements to produce bundles

func (Keeper) GetAllBundleProposals

func (k Keeper) GetAllBundleProposals(ctx sdk.Context) (list []types.BundleProposal)

GetAllBundleProposals returns all bundle proposals of all pools

func (Keeper) GetAllFinalizedBundles

func (k Keeper) GetAllFinalizedBundles(ctx sdk.Context) (list []types.FinalizedBundle)

func (Keeper) GetAllRoundRobinProgress added in v1.3.0

func (k Keeper) GetAllRoundRobinProgress(ctx sdk.Context) (list []types.RoundRobinProgress)

GetAllRoundRobinProgress returns the round-robin progress of all pools

func (Keeper) GetBundleProposal

func (k Keeper) GetBundleProposal(ctx sdk.Context, poolId uint64) (val types.BundleProposal, found bool)

GetBundleProposal returns the bundle proposal for the given pool with id `poolId`

func (Keeper) GetBundleVersionMap added in v1.2.3

func (k Keeper) GetBundleVersionMap(ctx sdk.Context) (val types.BundleVersionMap)

GetBundleVersionMap returns the bundle version map

func (Keeper) GetFinalizedBundle

func (k Keeper) GetFinalizedBundle(ctx sdk.Context, poolId, id uint64) (val types.FinalizedBundle, found bool)

GetFinalizedBundle returns a finalized bundle by its identifier

func (Keeper) GetFinalizedBundleByIndex added in v1.2.3

func (k Keeper) GetFinalizedBundleByIndex(ctx sdk.Context, poolId, index uint64) (val queryTypes.FinalizedBundle, found bool)

func (Keeper) GetFinalizedBundlesByPool

func (k Keeper) GetFinalizedBundlesByPool(ctx sdk.Context, poolId uint64) (list []types.FinalizedBundle)

func (Keeper) GetMaxPoints

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

GetMaxPoints returns the MaxPoints param

func (Keeper) GetNetworkFee

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

GetNetworkFee returns the NetworkFee param

func (Keeper) GetPaginatedFinalizedBundleQuery

func (k Keeper) GetPaginatedFinalizedBundleQuery(ctx sdk.Context, pagination *query.PageRequest, poolId uint64) ([]queryTypes.FinalizedBundle, *query.PageResponse, error)

GetPaginatedFinalizedBundleQuery parses a paginated request and builds a valid response out of the raw finalized bundles. It uses the fact that the ID of a bundle increases incrementally (starting with 0) and allows therefore for efficient queries using `offset`.

func (Keeper) GetParams

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

GetParams returns the current x/bundles module parameters.

func (Keeper) GetRoundRobinProgress added in v1.3.0

func (k Keeper) GetRoundRobinProgress(ctx sdk.Context, poolId uint64) (val types.RoundRobinProgress, found bool)

GetRoundRobinProgress returns the round-robin progress for a pool

func (Keeper) GetStorageCost

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

GetStorageCost returns the StorageCost param

func (Keeper) GetUploadTimeout

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

GetUploadTimeout returns the UploadTimeout param

func (Keeper) GetVoteDistribution

func (k Keeper) GetVoteDistribution(ctx sdk.Context, poolId uint64) (voteDistribution types.VoteDistribution)

GetVoteDistribution is an internal function evaluates the quorum status based on the voting power of the current bundle proposal.

func (Keeper) HandleUploadTimeout

func (k Keeper) HandleUploadTimeout(goCtx context.Context)

HandleUploadTimeout is an end block hook that triggers an upload timeout for every pool (if applicable).

func (Keeper) InitMemStore

func (k Keeper) InitMemStore(gasCtx sdk.Context)

func (Keeper) LoadRoundRobinValidatorSet added in v1.3.0

func (k Keeper) LoadRoundRobinValidatorSet(ctx sdk.Context, poolId uint64) RoundRobinValidatorSet

LoadRoundRobinValidatorSet initialises a validator set for the given pool id. If available it fetches the current round-robin state. Then it iterates all current pool validators and initialises the set accordingly. If a validator left the pool, the progress will be ignored. If new validators joined the pool, their progress will -1.125 * total_pool_delegation. The -1 is necessary to put them at the end of the queue (as the queue is centered around zero). The additional -0.125 are added as a penalty factor.

func (Keeper) Logger

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

func (Keeper) Params

func (Keeper) SaveRoundRobinValidatorSet added in v1.3.0

func (k Keeper) SaveRoundRobinValidatorSet(ctx sdk.Context, vs RoundRobinValidatorSet)

SaveRoundRobinValidatorSet saves the current round-robin progress for the given poolId to the KV-Store

func (Keeper) SetBundleProposal

func (k Keeper) SetBundleProposal(ctx sdk.Context, bundleProposal types.BundleProposal)

SetBundleProposal stores a current bundle proposal in the KV-Store. There is only one bundle proposal per pool

func (Keeper) SetBundleVersionMap added in v1.2.3

func (k Keeper) SetBundleVersionMap(ctx sdk.Context, bundleVersionMap types.BundleVersionMap)

SetBundleVersionMap stores the bundle version map

func (Keeper) SetFinalizedBundle

func (k Keeper) SetFinalizedBundle(ctx sdk.Context, finalizedBundle types.FinalizedBundle)

SetFinalizedBundle stores a finalized bundle identified by its `poolId` and `id`.

func (Keeper) SetFinalizedBundleIndexes

func (k Keeper) SetFinalizedBundleIndexes(ctx sdk.Context, finalizedBundle types.FinalizedBundle)

SetFinalizedBundleIndexes sets an in-memory reference for every bundle sorted by pool/fromIndex to allow querying for specific bundle ranges.

func (Keeper) SetParams

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

SetParams sets the x/bundles module parameters.

func (Keeper) SetRoundRobinProgress added in v1.3.0

func (k Keeper) SetRoundRobinProgress(ctx sdk.Context, roundRobinProgress types.RoundRobinProgress)

SetRoundRobinProgress stores the round-robin progress for a pool

type RoundRobinValidatorPower added in v1.3.0

type RoundRobinValidatorPower struct {
	Address string
	Power   int64
}

RoundRobinValidatorPower contains the total delegation of a protocol validator. It is used as a cache because the calculation of the total delegation needs to access the KV-Store and therefore consumes gas everytime it is called. This value is only stored for the current round and only lives inside the memory.

type RoundRobinValidatorSet added in v1.3.0

type RoundRobinValidatorSet struct {
	PoolId     uint64
	Validators []RoundRobinValidatorPower
	Progress   map[string]int64
}

RoundRobinValidatorSet is the in memory-object for working with the round-robin state It can not be stored to the KV-Store as the Go map iterator is non-deterministic. To obtain a deterministic state of the current state call GetRoundRobinProgress().

func (*RoundRobinValidatorSet) GetRoundRobinProgress added in v1.3.0

func (vs *RoundRobinValidatorSet) GetRoundRobinProgress() []*types.RoundRobinSingleValidatorProgress

GetRoundRobinProgress returns a deterministic (sorted) list of the current round-robin progress. Due to the fact that maps have no order in Go, we must introduce one by ourselves. This is done by sorting all entries by their addresses alphabetically.

func (*RoundRobinValidatorSet) NextProposer added in v1.3.0

func (vs *RoundRobinValidatorSet) NextProposer(excludedAddresses ...string) string

NextProposer advances the current round-robin state by one round, i.e. adjusting the progress of all (non-excluded) validators of the set. It then picks the top validator (if not excluded) and puts it to the end of the queue. This validator is the then returned as the "nextProposer". If the entire set is excluded then the algorithm proceeds as if nobody were excluded.

Jump to

Keyboard shortcuts

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