keeper

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 12 Imported by: 0

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.

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,

) Keeper

func (Keeper) EndBlocker added in v0.1.34

func (k Keeper) EndBlocker(ctx context.Context) error

EndBlocker maintains the anchored-session-grid invariant `live params == currently- effective epoch` (#543, Option B). At each block, if a params-history entry became effective at exactly the current height, that entry is promoted to the live params via SetParams. The common path (no epoch becomes effective at this height) is a pure no-op with no state write, so it does not alter app hashes on blocks without a promotion.

CRITICAL ORDERING (app/app_config.go endBlockers): the shared module MUST run AFTER every module that reads live shared params (service, session, proof, tokenomics, gateway, application, supplier). At the boundary block `anchor`, those consumers run with the OLD (current-epoch) live params; shared then promotes; block `anchor+1` onward sees the new params. Promotion fires on `effective_height == currentHeight` (NOT currentHeight+1): promoting one block early would make the LAST old-epoch block settle/unbond with the new N and lose funds. See spec §4.7.1.

func (Keeper) GetAllParamsHistory added in v0.1.31

func (k Keeper) GetAllParamsHistory(ctx context.Context) []types.ParamsUpdate

GetAllParamsHistory returns all historical session params updates. This is primarily used for genesis export and debugging.

Defensive Unmarshal: a corrupted history entry (partial write, downgrade from a newer schema, on-disk bit rot) is logged and skipped rather than allowed to halt genesis export via MustUnmarshal. The sister production readers (GetParamsAtHeight, GetParamsHistoryEntry, IterateParamsHistoryReverse) apply the same pattern; aligning this reader keeps the params-history surface uniformly halt-safe.

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the 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) GetParamsAtHeight added in v0.1.31

func (k Keeper) GetParamsAtHeight(ctx context.Context, queryHeight int64) types.Params

GetParamsAtHeight returns the session params that were effective at the given height. It finds the most recent params entry where effective_height <= queryHeight. If no historical params exist, it returns the current params (backwards compatible).

func (Keeper) GetParamsHistoryEntry added in v0.1.34

func (k Keeper) GetParamsHistoryEntry(ctx context.Context, effectiveHeight int64) (types.Params, bool)

GetParamsHistoryEntry returns the params recorded with an effective height EXACTLY equal to effectiveHeight, and whether such an entry exists. Unlike GetParamsAtHeight (which finds the most recent entry <= a height), this is an exact-key lookup used by the EndBlocker to detect an epoch that becomes effective at precisely the current block (#543 anchored grid, Option B promotion).

func (Keeper) GetProofWindowCloseHeight

func (k Keeper) GetProofWindowCloseHeight(ctx context.Context, queryHeight int64) int64

GetProofWindowCloseHeight returns the block height at which the proof window of the session that includes queryHeight closes, given the passed sharedParams.

func (Keeper) GetSessionEndHeight

func (k Keeper) GetSessionEndHeight(ctx context.Context, queryHeight int64) int64

GetSessionEndHeight returns the block height at which the session containing queryHeight ends, given the current shared onchain parameters. Returns 0 if the block height is not a consensus produced block. Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc.

func (Keeper) GetSessionNumber

func (k Keeper) GetSessionNumber(ctx context.Context, queryHeight int64) int64

GetSessionNumber returns the session number for the session containing queryHeight, given the current shared onchain parameters. Returns session number 0 if the block height is not a consensus produced block. Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc.

func (Keeper) GetSessionStartHeight

func (k Keeper) GetSessionStartHeight(ctx context.Context, queryHeight int64) int64

GetSessionStartHeight returns the block height at which the session containing queryHeight starts, given the current shared onchain parameters. Returns 0 if the block height is not a consensus produced block. Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc.

func (Keeper) HasParamsHistory added in v0.1.33

func (k Keeper) HasParamsHistory(ctx context.Context) bool

HasParamsHistory returns true if any params history entries exist. This is used to efficiently check if history needs initialization without the O(n) cost of GetAllParamsHistory.

func (Keeper) IterateParamsHistoryReverse added in v0.1.34

func (k Keeper) IterateParamsHistoryReverse(
	ctx context.Context,
	fromHeight int64,
	fn func(effectiveHeight int64, params types.Params) (stop bool),
)

IterateParamsHistoryReverse iterates params history entries in reverse order of effective_height starting from the largest entry with effective_height <= fromHeight. The callback fn is invoked for each entry; returning stop=true halts iteration.

Used by callers that need to resolve, for each historical params epoch, what claim/session timing math applies — e.g. settlement walking recent epochs to find every candidate sessionEndHeight whose proof window closes at the current block (cross-session window-offset orphan class, O2).

func (Keeper) Logger

func (k Keeper) Logger() log.Logger

Logger returns a module-specific logger.

func (Keeper) Params

func (Keeper) ParamsAtHeight added in v0.1.34

ParamsAtHeight returns the shared params that were effective at the requested height. Off-chain clients use this to compute a session's claim/proof windows with the num_blocks_per_session that was in effect when that session started (#543 anchored grid).

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) SetParamsAtHeight added in v0.1.31

func (k Keeper) SetParamsAtHeight(ctx context.Context, effectiveHeight int64, params types.Params) error

SetParamsAtHeight stores a snapshot of session params with their effective height. This enables historical lookups of params that were active at a given block height.

Jump to

Keyboard shortcuts

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