keeper

package
v0.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: LGPL-3.0, MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewQueryServer

func NewQueryServer(keeper Keeper) types.QueryServer

NewQueryServer returns an implementation of the QueryServer interface for the provided Keeper.

Types

type Keeper

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

Keeper of the poa store

func NewKeeper

func NewKeeper(
	storeKey storetypes.StoreKey,
	cdc codec.BinaryCodec,
) Keeper

NewKeeper creates a poa keeper

func (Keeper) AcceptOwnership

func (k Keeper) AcceptOwnership(
	ctx sdk.Context,
	sender sdk.AccAddress,
) error

AcceptOwnership finalizes the 2-step validator pool ownership transfer process. The candidate owner is promoted to the actual owner.

The function returns an error if the sender is not the current candidate owner or the ownership transfer process is not initialized. Returns nil if the ownership transfer is finalized successfully.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) AddPrivilege

func (k Keeper) AddPrivilege(
	ctx sdk.Context,
	sender sdk.AccAddress,
	operators []sdk.ValAddress,
	privilege string,
) error

AddPrivilege adds the privilege to a set of operators.

The function returns an error if any of the following occurs: - The sender is not the current owner. - No privilege is provided. - The operators list is empty. - The operators list contains an address that is not a validator. - The operators list contains an address that already has the privilege. - The operators list contains duplicate addresses.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) ApproveApplication

func (k Keeper) ApproveApplication(
	ctx sdk.Context,
	sender sdk.AccAddress,
	operator sdk.ValAddress,
) error

ApproveApplication approves an application submitted by a validator. The candidate validator will become an active validator at the end of the block.

The function returns an error if: - the sender is not the owner, - the max validators limit is reached, - the application does not exist. Returns nil if the application is successfully approved.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) BeginBlocker

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

BeginBlocker will persist the current header and validator set as a historical entry and prune the oldest entry based on the HistoricalEntries parameter.

func (Keeper) CheckOwner

func (k Keeper) CheckOwner(ctx sdk.Context, sender sdk.AccAddress) error

CheckOwner checks if the sender is the validator pool owner. Returns an error if the sender is not the owner or either of the compared addresses is empty. Returns nil otherwise.

func (Keeper) CleanupApplications

func (k Keeper) CleanupApplications(ctx sdk.Context, sender sdk.AccAddress) error

func (Keeper) DeleteHistoricalInfo

func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64)

DeleteHistoricalInfo deletes the historical info at a given height

func (Keeper) EndBlocker

func (k Keeper) EndBlocker(ctx context.Context) (
	updates []abci.ValidatorUpdate,
	err error,
)

EndBlocker called every block, update validator set.

func (Keeper) ExportGenesis

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

ExportGenesis writes the current store values to a genesis file, which can be imported again with InitGenesis

func (Keeper) ExportGenesisValidators

func (k Keeper) ExportGenesisValidators(
	ctx sdk.Context,
) ([]tmtypes.GenesisValidator, error)

ExportGenesisValidators exports the existing validators for genesis purposes.

func (Keeper) GetActiveValidators

func (k Keeper) GetActiveValidators(ctx sdk.Context) (validators []types.Validator)

GetActiveValidators gets the set of all active validators that are part of the Tendermint consensus set. The result contains only validators with the state types.ValidatorStateActive.

func (Keeper) GetAllApplications

func (k Keeper) GetAllApplications(ctx sdk.Context) (applications []types.Application)

GetAllApplications gets all applications.

func (Keeper) GetAllValidators

func (k Keeper) GetAllValidators(ctx sdk.Context) (validators []types.Validator)

GetAllValidators gets the set of all validators registered in the module store. The result contains validators of all states: - types.ValidatorStateJoining: not yet present in the Tendermint validator set - types.ValidatorStateActive: already present in the Tendermint validator set - types.ValidatorStateLeaving: will leave the Tendermint validator set at the end of the block

func (Keeper) GetApplication

func (k Keeper) GetApplication(
	ctx sdk.Context,
	operator sdk.ValAddress,
) (types.Application, bool)

GetApplication returns the application by the given candidate operator address.

func (Keeper) GetApplicationByConsAddr

func (k Keeper) GetApplicationByConsAddr(
	ctx sdk.Context,
	cons sdk.ConsAddress,
) (types.Application, bool)

GetApplicationByConsAddr gets an application by the given candidate consensus address.

func (Keeper) GetCandidateOwner

func (k Keeper) GetCandidateOwner(ctx sdk.Context) sdk.AccAddress

GetCandidateOwner returns the candidate validator pool owner address.

func (Keeper) GetHistoricalInfo

func (k Keeper) GetHistoricalInfo(
	ctx sdk.Context,
	height int64,
) (types.HistoricalInfo, bool)

GetHistoricalInfo gets the historical info at a given height

func (Keeper) GetOwner

func (k Keeper) GetOwner(ctx sdk.Context) sdk.AccAddress

GetOwner returns the validator pool owner address.

func (Keeper) GetParams

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

GetParams returns the total set of poa parameters.

func (Keeper) GetPubKeyByConsAddr

func (k Keeper) GetPubKeyByConsAddr(
	ctx context.Context,
	cons sdk.ConsAddress,
) (cmtprotocrypto.PublicKey, error)

GetPubKeyByConsAddr gets the public key of a validator by the consensus address. If the validator is no longer in the validator set, the function will search for the public key in the last 10 historical info entries. This function tries to maximize the chance of finding the public key as it is used within the function that validates the vote extensions. If vote extensions cannot be validated, due to missing public keys, the consensus will halt.

func (Keeper) GetValidator

func (k Keeper) GetValidator(
	ctx sdk.Context,
	operator sdk.ValAddress,
) (types.Validator, bool)

GetValidator gets a validator by the operator address.

func (Keeper) GetValidatorByConsAddr

func (k Keeper) GetValidatorByConsAddr(
	ctx sdk.Context,
	cons sdk.ConsAddress,
) (types.Validator, bool)

GetValidatorByConsAddr gets a validator by the consensus address.

func (Keeper) GetValidatorState

func (k Keeper) GetValidatorState(
	ctx sdk.Context,
	operator sdk.ValAddress,
) (types.ValidatorState, bool)

GetValidatorState gets the state of a validator.

func (Keeper) GetValidatorsConsAddrsByPrivilege

func (k Keeper) GetValidatorsConsAddrsByPrivilege(
	ctx sdk.Context,
	privilege string,
) []sdk.ConsAddress

GetValidatorsConsAddrsByPrivilege returns the consensus addresses of all validators that are currently present in the store and have the given privilege. There is no guarantee that the returned validators are currently part of the CometBFT validator set.

func (Keeper) GetValidatorsOperatorsByPrivilege

func (k Keeper) GetValidatorsOperatorsByPrivilege(
	ctx sdk.Context,
	privilege string,
) []sdk.ValAddress

GetValidatorsOperatorsByPrivilege returns the operator addresses of all validators that are currently present in the store and have the given privilege. There is no guarantee that the returned validators are currently part of the CometBFT validator set.

func (Keeper) HistoricalEntries

func (k Keeper) HistoricalEntries() uint32

HistoricalEntries returns the number of historical info entries to persist.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) (res []abci.ValidatorUpdate)

InitGenesis initialize default parameters and the keeper's address to pubkey map

func (Keeper) Kick

func (k Keeper) Kick(
	ctx sdk.Context,
	sender sdk.AccAddress,
	operator sdk.ValAddress,
) error

Kick forcibly removes a validator from the validator pool. The validator will be removed from active validators at the end of the block.

The function returns an error if: - the sender is not the owner, - the validator does not exist, - the validator is not an active validator. Returns nil if the validator is successfully kicked.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) Leave

func (k Keeper) Leave(ctx sdk.Context, sender sdk.AccAddress) error

Leave voluntarily removes a validator from the validator pool. The validator will be removed from active validators at the end of the block.

The function returns an error if: - there is only one validator, - the sender is not an existing validator, - the validator is not an active validator. Returns nil if the validator successfully leaves.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) RemovePrivilege

func (k Keeper) RemovePrivilege(
	ctx sdk.Context,
	sender sdk.AccAddress,
	operators []sdk.ValAddress,
	privilege string,
) error

RemovePrivilege removes the privilege from a set of operators.

The function returns an error if any of the following occurs: - The sender is not the current owner. - No privilege is provided. - The operators list is empty. - The operators list contains an address that is not a validator. - The operators list contains an address that doesn't have the privilege. - The operators list contains duplicate addresses.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) SetHistoricalInfo

func (k Keeper) SetHistoricalInfo(
	ctx sdk.Context,
	height int64,
	hi *types.HistoricalInfo,
)

SetHistoricalInfo sets the historical info at a given height

func (Keeper) SubmitApplication

func (k Keeper) SubmitApplication(
	ctx sdk.Context,
	sender sdk.AccAddress,
	validator types.Validator,
) error

SubmitApplication submits a new application to become a validator.

The function returns an error if: - the sender is not the operator of the candidate validator, - the max validators limit is reached, - the candidate is already a validator, - the candidate is already applying. Returns nil if the application is successfully submitted.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) TotalBondedTokens

func (k Keeper) TotalBondedTokens(ctx context.Context) (math.Int, error)

TotalBondedTokens is used by Connect to retrieve the total "stake" from which to calculate the stake-weighted median. Each active (including leaving) validator in the PoaKeeper will return 1 for its bonded tokens and is effectively/weighted equally.

func (Keeper) TrackHistoricalInfo

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

TrackHistoricalInfo saves the latest historical-info and deletes the oldest heights that are below pruning height

func (Keeper) TransferOwnership

func (k Keeper) TransferOwnership(
	ctx sdk.Context,
	sender sdk.AccAddress,
	newOwner sdk.AccAddress,
) error

TransferOwnership initializes the 2-step validator pool ownership transfer process. The new owner is set as a candidate owner and must accept the ownership to be promoted to the actual owner.

The function returns an error if the sender is not the current owner. Returns nil if the ownership transfer is initialized successfully.

Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation. If the sender address is empty, the function will return an error.

func (Keeper) UpdateParams

func (k Keeper) UpdateParams(
	ctx sdk.Context,
	sender sdk.AccAddress,
	params types.Params,
) error

UpdateParams updates the poa module's parameters. Upstream is responsible for setting the `sender` parameter to the actual actor performing the operation.

func (Keeper) ValidatorByConsAddr

func (k Keeper) ValidatorByConsAddr(ctx context.Context, addr sdk.ConsAddress) (stakingtypes.ValidatorI, error)

ValidatorByConsAddr is a compatibility method used by Connect. It wraps the PoaKeeper Validator type in a ValidatorCompat struct which provides compatibility with the x/staking methods that Connect expects.

Jump to

Keyboard shortcuts

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