keeper

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 16 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 module MsgServer interface.

Types

type Keeper

type Keeper struct {

	// state management
	Params collections.Item[types.Params]
	// TODO: write the migration from sdk.ValAddress to current structure
	UniversalValidatorSet collections.Map[sdk.ValAddress, types.UniversalValidator] // Set of all registered Universal Validator addresses

	// Ballots management
	Ballots            collections.Map[string, types.Ballot] // stores the actual ballot object, keyed by ballot ID
	ActiveBallotIDs    collections.KeySet[string]            // set of ballot IDs currently collecting votes
	ExpiredBallotIDs   collections.KeySet[string]            // set of ballot IDs that have expired (not yet pruned)
	FinalizedBallotIDs collections.KeySet[string]            // set of ballot IDs that are PASSED or REJECTED

	StakingKeeper      types.StakingKeeper
	SlashingKeeper     types.SlashingKeeper
	UtssKeeper         types.UtssKeeper
	BankKeeper         types.BankKeeper
	AuthKeeper         types.AccountKeeper
	DistributionKeeper types.DistributionKeeper
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService storetypes.KVStoreService,
	logger log.Logger,
	authority string,
	bankKeeper types.BankKeeper,
	authKeeper types.AccountKeeper,
	distributionKeeper types.DistributionKeeper,
	stakingKeeper types.StakingKeeper,
	slashingKeeper types.SlashingKeeper,
	utssKeeper types.UtssKeeper,
) Keeper

NewKeeper creates a new Keeper instance

func (Keeper) AddUniversalValidator

func (k Keeper) AddUniversalValidator(
	ctx context.Context,
	coreValidatorAddr string,
	networkInfo types.NetworkInfo,
) error

new validator -> added as a PENDING_JOIN status if existing: inactive -> added as a PENDING_JOIN status any other status -> revert AddUniversalValidator registers or reactivates a core validator as a universal validator. It ensures the core validator exists, is bonded, and handles lifecycle reactivation.

func (Keeper) AddVoteToBallot

func (k Keeper) AddVoteToBallot(
	ctx context.Context,
	ballot types.Ballot,
	address string,
	voteResult types.VoteResult,
) (types.Ballot, error)

func (Keeper) AllActiveBallotIDs

AllActiveBallotIDs implements types.QueryServer.

func (Keeper) CheckIfFinalizingVote

func (k Keeper) CheckIfFinalizingVote(ctx context.Context, b types.Ballot) (types.Ballot, bool, error)

func (Keeper) CreateBallot

func (k Keeper) CreateBallot(
	ctx context.Context,
	id string,
	ballotType types.BallotObservationType,
	eligibleVoters []string,
	votingThreshold int64,
	expiryAfterBlocks int64,
) (types.Ballot, error)

CreateBallot creates a new ballot with the given parameters, stores it, and marks it as active.

func (Keeper) DeleteBallot

func (k Keeper) DeleteBallot(ctx context.Context, id string) error

DeleteBallot removes a ballot and its ID from all collections

func (Keeper) ExpireBallotsBeforeHeight

func (k Keeper) ExpireBallotsBeforeHeight(ctx context.Context, currentHeight int64) error

ExpireBallotsBeforeHeight checks active ballots and marks expired ones

func (*Keeper) ExportGenesis

func (k *Keeper) ExportGenesis(ctx context.Context) *types.GenesisState

ExportGenesis exports the module's state to a genesis state.

func (Keeper) GetAllUniversalValidators

func (k Keeper) GetAllUniversalValidators(ctx context.Context) ([]types.UniversalValidator, error)

GetAllUniversalValidators returns all validators in the UniversalValidatorSet.

func (Keeper) GetBallot

func (k Keeper) GetBallot(ctx context.Context, id string) (types.Ballot, error)

GetBallot retrieves a ballot by ID

func (Keeper) GetBlockHeight

func (k Keeper) GetBlockHeight(ctx context.Context) (int64, error)

func (Keeper) GetEligibleVoters

func (k Keeper) GetEligibleVoters(ctx context.Context) ([]types.UniversalValidator, error)

GetEligibleVoters returns all validators that are eligible to vote on external transactions. Eligibility: validators with status ACTIVE or PENDING_JOIN.

func (Keeper) GetOrCreateBallot

func (k Keeper) GetOrCreateBallot(
	ctx context.Context,
	id string,
	ballotType types.BallotObservationType,
	voters []string,
	votesNeeded int64,
	expiryAfterBlocks int64,
) (types.Ballot, bool, error)

GetOrCreateBallot returns the ballot if it exists, otherwise creates it.

func (Keeper) GetUniversalValidator

func (k Keeper) GetUniversalValidator(
	ctx context.Context,
	addr sdk.ValAddress,
) (types.UniversalValidator, bool, error)

GetUniversalValidator returns a single UniversalValidator by address.

func (Keeper) GetValidatorsByStatus

func (k Keeper) GetValidatorsByStatus(ctx context.Context, status types.UVStatus) ([]types.UniversalValidator, error)

GetValidatorsByStatus returns a list of validators filtered by status (ACTIVE, PENDING_JOIN, etc.).

func (Keeper) HasUniversalValidatorInSet

func (k Keeper) HasUniversalValidatorInSet(ctx context.Context, uvAddr sdk.ValAddress) (bool, error)

func (*Keeper) InitGenesis

func (k *Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error

InitGenesis initializes the module's state from a genesis state.

func (Keeper) IsActiveUniversalValidator added in v0.0.13

func (k Keeper) IsActiveUniversalValidator(
	ctx context.Context,
	validatorOperatorAddr string,
) (bool, error)

IsActiveUniversalValidator returns true if the given validator address is currently registered as an active universal validator.

func (Keeper) IsBondedUniversalValidator

func (k Keeper) IsBondedUniversalValidator(ctx context.Context, universalValidator string) (bool, error)

func (Keeper) IsTombstonedUniversalValidator

func (k Keeper) IsTombstonedUniversalValidator(ctx context.Context, universalValidator string) (bool, error)

func (Keeper) Logger

func (k Keeper) Logger() log.Logger

func (Keeper) MarkBallotExpired

func (k Keeper) MarkBallotExpired(ctx context.Context, id string) error

MarkBallotExpired moves a ballot from active to expired

func (Keeper) MarkBallotFinalized

func (k Keeper) MarkBallotFinalized(ctx context.Context, id string, status types.BallotStatus) error

MarkBallotFinalized moves a ballot from active to finalized (PASSED or REJECTED)

func (Keeper) RemoveUniversalValidator

func (k Keeper) RemoveUniversalValidator(
	ctx context.Context,
	universalValidatorAddr string,
) error

RemoveUniversalValidator handles universal validator removal lifecycle:

  • ACTIVE -> PENDING_LEAVE
  • PENDING_JOIN ->
  • if in current TSS process (ongoing) → revert (keygen ongoing)
  • if not in current TSS process (ongoing) → INACTIVE

It ensures the validator exists before removal and triggers hooks on status change.

func (Keeper) RemoveUniversalValidatorFromSet

func (k Keeper) RemoveUniversalValidatorFromSet(ctx context.Context, addr sdk.ValAddress) error

func (Keeper) SchemaBuilder

func (k Keeper) SchemaBuilder() *collections.SchemaBuilder

func (Keeper) SetBallot

func (k Keeper) SetBallot(ctx context.Context, ballot types.Ballot) error

SetBallot updates an existing ballot

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(h types.UValidatorHooks) *Keeper

func (Keeper) UpdateParams

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

updateParams is for updating params collections of the module

func (Keeper) UpdateUniversalValidator

func (k Keeper) UpdateUniversalValidator(
	ctx context.Context,
	coreValidatorAddr string,
	networkInfo types.NetworkInfo,
) error

UpdateUniversalValidator updates the metadata of the registered universal validator

func (Keeper) UpdateUniversalValidatorStatus

func (k Keeper) UpdateUniversalValidatorStatus(
	ctx context.Context,
	coreValidatorAddr string,
	newStatus types.UVStatus,
) error

UpdateUniversalValidatorStatus updates the UV status from PENDING_LEAVE to ACTIVE any other case of status change must fail

func (Keeper) UpdateValidatorStatus

func (k Keeper) UpdateValidatorStatus(ctx context.Context, addr sdk.ValAddress, newStatus types.UVStatus) error

UpdateValidatorStatus updates the validator’s lifecycle status. It appends a LifecycleEvent, validates legal transitions, and saves the updated record.

func (Keeper) VoteOnBallot

func (k Keeper) VoteOnBallot(
	ctx context.Context,
	id string,
	ballotType types.BallotObservationType,
	voter string,
	voteResult types.VoteResult,
	voters []string,
	votesNeeded int64,
	expiryAfterBlocks int64,
) (
	ballot types.Ballot,
	isFinalized bool,
	isNew bool,
	err error)

type MultiUValidatorHooks

type MultiUValidatorHooks []types.UValidatorHooks

MultiUValidatorHooks allows multiple modules to listen to the same events.

func NewMultiUValidatorHooks

func NewMultiUValidatorHooks(hooks ...types.UValidatorHooks) MultiUValidatorHooks

NewMultiUValidatorHooks creates a new combined hook instance.

func (MultiUValidatorHooks) AfterValidatorAdded

func (mh MultiUValidatorHooks) AfterValidatorAdded(ctx sdk.Context, valAddr sdk.ValAddress)

AfterValidatorAdded calls every hook in the list.

func (MultiUValidatorHooks) AfterValidatorRemoved

func (mh MultiUValidatorHooks) AfterValidatorRemoved(ctx sdk.Context, valAddr sdk.ValAddress)

AfterValidatorRemoved calls every hook in the list.

func (MultiUValidatorHooks) AfterValidatorStatusChanged

func (mh MultiUValidatorHooks) AfterValidatorStatusChanged(ctx sdk.Context, valAddr sdk.ValAddress, oldStatus, newStatus types.UVStatus)

AfterValidatorStatusChanged calls every hook in the list.

type Querier

type Querier struct {
	Keeper
}

func NewQuerier

func NewQuerier(keeper Keeper) Querier

func (Querier) AllActiveBallots

ActiveBallots implements types.QueryServer.

func (Querier) AllBallots

AllBallots implements types.QueryServer.

func (Querier) AllExpiredBallotIDs

AllExpiredBallotIDs implements types.QueryServer.

func (Querier) AllExpiredBallots

AllExpiredBallots implements types.QueryServer.

func (Querier) AllFinalizedBallotIDs

FinalizedBallotIDs implements types.QueryServer.

func (Querier) AllFinalizedBallots

FinalizedBallots implements types.QueryServer.

func (Querier) Ballot

Ballot implements types.QueryServer.

func (Querier) Params

Jump to

Keyboard shortcuts

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