keeper

package
v6.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 46 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffValidators

func DiffValidators(
	currentValidators []types.ConsensusValidator,
	nextValidators []types.ConsensusValidator,
) []abci.ValidatorUpdate

DiffValidators compares the current and the next epoch's consumer validators and returns the `ValidatorUpdate` diff needed by CometBFT to update the validator set on a chain.

func GetValidatorKey

func GetValidatorKey(prefix []byte, providerConsAddr types.ProviderConsAddress) []byte

GetValidatorKey constructs the key to access a given validator, stored under a given prefix. This method is public for testing.

func MaxProviderConsensusValidatorsInvariant

func MaxProviderConsensusValidatorsInvariant(k *Keeper) sdk.Invariant

MaxProviderConsensusValidatorsInvariant checks that the number of provider consensus validators is less than or equal to the maximum number of provider consensus validators

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

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

func NoMoreThanPercentOfTheSum

func NoMoreThanPercentOfTheSum(validators []types.ConsensusValidator, percent uint32) []types.ConsensusValidator

NoMoreThanPercentOfTheSum returns a set of validators with updated powers such that no validator has more than the provided `percent` of the sum of all validators' powers. Operates on a best-effort basis.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k *Keeper)

RegisterInvariants registers all staking invariants

func StakingKeeperEquivalenceInvariant

func StakingKeeperEquivalenceInvariant(k Keeper) sdk.Invariant

StakingKeeperEquivalenceInvariant checks that *if* MaxProviderConsensusValidators == MaxValidators, then the staking keeper and the provider keeper return the same values for their common interface, i.e. the functions from staking_keeper_interface.go

Types

type Hooks

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

Wrapper struct

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) AfterProposalDeposit

func (h Hooks) AfterProposalDeposit(ctx context.Context, proposalID uint64, depositorAddr sdk.AccAddress) error

func (Hooks) AfterProposalFailedMinDeposit

func (h Hooks) AfterProposalFailedMinDeposit(ctx context.Context, proposalID uint64) error

func (Hooks) AfterProposalSubmission

func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalId uint64) error

func (Hooks) AfterProposalVote

func (h Hooks) AfterProposalVote(ctx context.Context, proposalID uint64, voterAddr sdk.AccAddress) error

func (Hooks) AfterProposalVotingPeriodEnded

func (h Hooks) AfterProposalVotingPeriodEnded(goCtx context.Context, proposalId uint64) error

func (Hooks) AfterUnbondingInitiated

func (h Hooks) AfterUnbondingInitiated(goCtx context.Context, id uint64) error

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorCreated

func (h Hooks) AfterValidatorCreated(goCtx context.Context, valAddr sdk.ValAddress) error

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(goCtx context.Context, valConsAddr sdk.ConsAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeTokenizeShareRecordRemoved

func (h Hooks) BeforeTokenizeShareRecordRemoved(_ context.Context, _ uint64) error

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(_ context.Context, _ sdk.ValAddress) error

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(_ context.Context, _ sdk.ValAddress, _ math.LegacyDec) error

type Keeper

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

Keeper defines the Cross-Chain Validation Provider Keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, scopedKeeper ccv.ScopedKeeper,
	channelKeeper ccv.ChannelKeeper, portKeeper ccv.PortKeeper,
	connectionKeeper ccv.ConnectionKeeper, clientKeeper ccv.ClientKeeper,
	stakingKeeper ccv.StakingKeeper, slashingKeeper ccv.SlashingKeeper,
	accountKeeper ccv.AccountKeeper,
	distributionKeeper ccv.DistributionKeeper, bankKeeper ccv.BankKeeper,
	govKeeper govkeeper.Keeper,
	authority string,
	validatorAddressCodec, consensusAddressCodec addresscodec.Codec,
	feeCollectorName string,
) Keeper

NewKeeper creates a new provider Keeper instance

func (Keeper) AllocateTokens

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

AllocateTokens performs rewards distribution to the community pool and validators based on the Partial Set Security distribution specification.

func (Keeper) AllocateTokensToConsumerValidators

func (k Keeper) AllocateTokensToConsumerValidators(
	ctx sdk.Context,
	consumerId string,
	tokens sdk.DecCoins,
) (allocated sdk.DecCoins)

AllocateTokensToConsumerValidators allocates tokens to the given consumer chain's validator set

func (Keeper) AppendConsumerAddrsToPrune

func (k Keeper) AppendConsumerAddrsToPrune(
	ctx sdk.Context,
	consumerId string,
	pruneTs time.Time,
	consumerAddr types.ConsumerConsAddress,
)

AppendConsumerAddrsToPrune appends a consumer validator address to the list of consumer addresses that can be pruned once the block time is at least pruneTs.

The following invariant needs to hold: For each consumer address cAddr in ValidatorByConsumerAddr,

  • either there exists a provider address pAddr in ValidatorConsumerPubKey, s.t. hash(ValidatorConsumerPubKey(pAddr)) = cAddr
  • or there exists a timestamp in ConsumerAddrsToPrune s.t. cAddr in ConsumerAddrsToPrune(timestamp)

func (Keeper) AppendConsumerToBeLaunched

func (k Keeper) AppendConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error

AppendConsumerToBeLaunched appends the provider consumer id for the given spawn time

func (Keeper) AppendConsumerToBeRemoved

func (k Keeper) AppendConsumerToBeRemoved(ctx sdk.Context, consumerId string, removalTime time.Time) error

AppendConsumerToBeRemoved appends the provider consumer id for the given removal time

func (Keeper) AppendPendingVSCPackets

func (k Keeper) AppendPendingVSCPackets(ctx sdk.Context, consumerId string, newPackets ...ccv.ValidatorSetChangePacketData)

AppendPendingVSCPackets adds the given ValidatorSetChange packet to the list of pending ValidatorSetChange packets stored under consumer id

func (Keeper) AppendSlashAck

func (k Keeper) AppendSlashAck(ctx sdk.Context, consumerId,
	ack string,
)

AppendSlashAck appends the given slash ack to the given consumer id slash acks in store

func (Keeper) AssignConsumerKey

func (k Keeper) AssignConsumerKey(
	ctx sdk.Context,
	consumerId string,
	validator stakingtypes.Validator,
	consumerKey tmprotocrypto.PublicKey,
) error

AssignConsumerKey assigns the consumerKey to the validator with providerAddr on the consumer chain with the given `consumerId`, if it is either registered or currently voted on in a ConsumerAddition governance proposal

func (Keeper) AuthenticateCapability

func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool

AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function

func (Keeper) BeginBlockCIS

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

BeginBlockCIS contains the BeginBlock logic needed for the Consumer Initiated Slashing sub-protocol.

func (Keeper) BeginBlockLaunchConsumers

func (k Keeper) BeginBlockLaunchConsumers(ctx sdk.Context) error

BeginBlockLaunchConsumers launches initialized consumers chains for which the spawn time has passed

func (Keeper) BeginBlockRD

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

BeginBlockRD executes BeginBlock logic for the Reward Distribution sub-protocol.

func (Keeper) BeginBlockRemoveConsumers

func (k Keeper) BeginBlockRemoveConsumers(ctx sdk.Context) error

BeginBlockRemoveConsumers removes stopped consumer chain for which the removal time has passed

func (Keeper) BindPort

func (k Keeper) BindPort(ctx sdk.Context, portID string) error

BindPort defines a wrapper function for the port Keeper's function in order to expose it to module's InitGenesis function

func (Keeper) BlocksUntilNextEpoch

func (k Keeper) BlocksUntilNextEpoch(ctx sdk.Context) int64

BlocksUntilNextEpoch returns the number of blocks until the next epoch starts Returns 0 if VSCPackets are sent in the current block, which is done in the first block of each epoch.

func (Keeper) BondDenom

func (k Keeper) BondDenom(ctx sdk.Context) (string, error)

func (Keeper) BondedRatio

func (k Keeper) BondedRatio(ctx context.Context) (math.LegacyDec, error)

BondedRatio gets the ratio of tokens staked to validators active in the consensus to the total supply of tokens. Same as BondedRatio in the StakingKeeper, but only counts tokens of the first MaxProviderConsensusValidators bonded validators.

func (Keeper) CanValidateChain

func (k Keeper) CanValidateChain(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
	topN uint32,
	minPowerToOptIn int64,
) (bool, error)

CanValidateChain returns true if the validator `providerAddr` is opted-in to chain with `consumerId` and the allowlist and denylist do not prevent the validator from validating the chain.

func (Keeper) CapValidatorSet

func (k Keeper) CapValidatorSet(
	ctx sdk.Context,
	powerShapingParameters types.PowerShapingParameters,
	validators []types.ConsensusValidator,
) []types.ConsensusValidator

CapValidatorSet caps the provided `validators` if chain with `consumerId` is an Opt In chain with a validator-set cap. If cap is `k`, `CapValidatorSet` returns the first `k` validators from `validators` with the highest power.

func (Keeper) CapValidatorsPower

func (k Keeper) CapValidatorsPower(
	ctx sdk.Context,
	validatorsPowerCap uint32,
	validators []types.ConsensusValidator,
) []types.ConsensusValidator

CapValidatorsPower caps the power of the validators on chain with `consumerId` and returns an updated slice of validators with their new powers. Works on a best-basis effort because there are cases where we cannot guarantee that all validators on the consumer chain have less power than the set validators-power cap. For example, if we have 10 validators and the power cap is set to 5%, we need at least one validator to have more than 10% of the voting power on the consumer chain.

func (Keeper) ChangeRewardDenoms

func (k Keeper) ChangeRewardDenoms(ctx sdk.Context, denomsToAdd, denomsToRemove []string) []sdk.Attribute

TODO: this method needs to be tested

func (Keeper) CheckForSlashMeterReplenishment

func (k Keeper) CheckForSlashMeterReplenishment(ctx sdktypes.Context)

CheckForSlashMeterReplenishment checks if the slash meter should be replenished, and if so, replenishes it. Note: initial slash meter replenish time candidate is set in InitGenesis.

func (Keeper) CheckMisbehaviour

func (k Keeper) CheckMisbehaviour(ctx sdk.Context, consumerId string, misbehaviour ibctmtypes.Misbehaviour) error

CheckMisbehaviour checks that headers in the given misbehaviour forms a valid light client attack from an ICS consumer chain and that the light client isn't expired

func (Keeper) ClaimCapability

func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error

ClaimCapability allows the transfer module that can claim a capability that IBC module passes to it

func (Keeper) ComputeConsumerNextValSet

func (k Keeper) ComputeConsumerNextValSet(
	ctx sdk.Context,
	bondedValidators []stakingtypes.Validator,
	activeValidators []stakingtypes.Validator,
	consumerId string,
	currentConsumerValSet []types.ConsensusValidator,
) ([]abci.ValidatorUpdate, error)

ComputeConsumerNextValSet computes the consumer next validator set and returns the validator updates to be sent to the consumer chain. For TopN consumer chains, it automatically opts in all validators that belong to the top N of the active validators.

TODO add unit test for ComputeConsumerNextValSet

func (Keeper) ComputeConsumerTotalVotingPower

func (k Keeper) ComputeConsumerTotalVotingPower(ctx sdk.Context, consumerId string) (totalPower int64)

ComputeConsumerTotalVotingPower returns the validator set total voting power for the given consumer chain

func (Keeper) ComputeMinPowerInTopN

func (k Keeper) ComputeMinPowerInTopN(ctx sdk.Context, bondedValidators []stakingtypes.Validator, topN uint32) (int64, error)

ComputeMinPowerInTopN returns the minimum power needed for a validator (from the bonded validators) to belong to the `topN`% of validators for a Top N chain.

func (Keeper) ComputeNextValidators

func (k Keeper) ComputeNextValidators(
	ctx sdk.Context,
	consumerId string,
	bondedValidators []stakingtypes.Validator,
	powerShapingParameters types.PowerShapingParameters,
	minPowerToOptIn int64,
) ([]types.ConsensusValidator, error)

ComputeNextValidators computes the validators for the upcoming epoch based on the currently `bondedValidators`.

func (Keeper) ComputePowerToSlash

func (k Keeper) ComputePowerToSlash(ctx sdk.Context, validator stakingtypes.Validator, undelegations []stakingtypes.UnbondingDelegation,
	redelegations []stakingtypes.Redelegation, power int64, powerReduction math.Int,
) int64

ComputePowerToSlash computes the power to be slashed based on the tokens in non-matured `undelegations` and `redelegations`, as well as the current `power` of the validator. Note that this method does not perform any slashing.

func (Keeper) ConsensusAddressCodec

func (k Keeper) ConsensusAddressCodec() addresscodec.Codec

ConsensusAddressCodec returns the app consensus address codec.

func (Keeper) ConsumeConsumerAddrsToPrune

func (k Keeper) ConsumeConsumerAddrsToPrune(
	ctx sdk.Context,
	consumerId string,
	ts time.Time,
) (consumerAddrsToPrune types.AddressList)

ConsumeConsumerAddrsToPrune returns the list of consumer addresses that can be pruned at timestamp ts. The returned addresses are removed from the store.

Note that the list of all consumer addresses is stored under keys with the following format: ConsumerAddrsToPruneV2BytePrefix | len(consumerId) | consumerId | timestamp Thus, this method returns all the consumer addresses stored under keys in the following range: (ConsumerAddrsToPruneV2BytePrefix | len(consumerId) | consumerId | ts') where ts' <= ts

func (Keeper) ConsumeIdsFromTimeQueue

func (k Keeper) ConsumeIdsFromTimeQueue(
	ctx sdk.Context,
	timeQueueKeyPrefix byte,
	getIds func(sdk.Context, time.Time) (types.ConsumerIds, error),
	deleteAllIds func(sdk.Context, time.Time),
	appendId func(sdk.Context, string, time.Time) error,
	limit int,
) ([]string, error)

ConsumeIdsFromTimeQueue returns from a time queue the consumer ids for which the associated time passed. The number of ids return is limited to 'limit'. The ids returned are removed from the time queue.

func (Keeper) ConsumeSlashAcks

func (k Keeper) ConsumeSlashAcks(ctx sdk.Context, consumerId string) (acks []string)

ConsumeSlashAcks empties and returns the slash acks for a given consumer id

func (Keeper) ConsumerRewardDenomExists

func (k Keeper) ConsumerRewardDenomExists(
	ctx sdk.Context,
	denom string,
) bool

func (Keeper) CreateConsumerClient

func (k Keeper) CreateConsumerClient(
	ctx sdk.Context,
	consumerId string,
	valsetHash []byte,
) error

CreateConsumerClient will create the CCV client for the given consumer chain. The CCV channel must be built on top of the CCV client to ensure connection with the right consumer chain.

func (Keeper) CreateConsumerValidator

func (k Keeper) CreateConsumerValidator(ctx sdk.Context, consumerId string, validator stakingtypes.Validator) (types.ConsensusValidator, error)

CreateConsumerValidator creates a consumer validator for `consumerId` from the given staking `validator`

func (Keeper) CreateProviderConsensusValidator

func (k Keeper) CreateProviderConsensusValidator(ctx sdk.Context, val stakingtypes.Validator) (types.ConsensusValidator, error)

CreateProviderConsensusValidator creates a new ConsensusValidator from the given staking validator

func (Keeper) DeleteAllConsumersToBeLaunched

func (k Keeper) DeleteAllConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time)

DeleteAllConsumersToBeLaunched deletes all consumer to be launched at this specific spawn time

func (Keeper) DeleteAllConsumersToBeRemoved

func (k Keeper) DeleteAllConsumersToBeRemoved(ctx sdk.Context, removalTime time.Time)

DeleteAllConsumersToBeRemoved deletes all consumer to be removed at this specific removal time

func (Keeper) DeleteAllOptedIn

func (k Keeper) DeleteAllOptedIn(
	ctx sdk.Context,
	consumerId string,
)

DeleteAllOptedIn deletes all the opted-in validators for chain with `consumerId`

func (Keeper) DeleteAllowlist

func (k Keeper) DeleteAllowlist(ctx sdk.Context, consumerId string)

DeleteAllowlist deletes all allowlisted validators

func (Keeper) DeleteChannelIdToConsumerId

func (k Keeper) DeleteChannelIdToConsumerId(ctx sdk.Context, channelId string)

DeleteChannelIdToConsumerId deletes the consumer id for a given CCV channel id

func (Keeper) DeleteConsumerAddrsToPrune

func (k Keeper) DeleteConsumerAddrsToPrune(ctx sdk.Context, consumerId string, pruneTs time.Time)

DeleteConsumerAddrsToPruneV2 deletes the list of consumer addresses mapped to a timestamp

func (Keeper) DeleteConsumerChain

func (k Keeper) DeleteConsumerChain(ctx sdk.Context, consumerId string) (err error)

DeleteConsumerChain cleans up the state of the given consumer chain

func (Keeper) DeleteConsumerChainId

func (k Keeper) DeleteConsumerChainId(ctx sdk.Context, consumerId string)

DeleteConsumerChainId deletes the chain id associated with this consumer id

func (Keeper) DeleteConsumerClientId

func (k Keeper) DeleteConsumerClientId(ctx sdk.Context, consumerId string)

DeleteConsumerClientId removes from the store the client id for the given consumer id. Note that the method also removes the reverse index.

func (Keeper) DeleteConsumerCommissionRate

func (k Keeper) DeleteConsumerCommissionRate(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
)

DeleteConsumerCommissionRate the per-consumer chain commission rate associated to the given validator address

func (Keeper) DeleteConsumerGenesis

func (k Keeper) DeleteConsumerGenesis(ctx sdk.Context, consumerId string)

func (Keeper) DeleteConsumerIdToChannelId

func (k Keeper) DeleteConsumerIdToChannelId(ctx sdk.Context, consumerId string)

DeleteConsumerIdToChannelId deletes the CCV channel id for the given consumer id

func (Keeper) DeleteConsumerInitializationParameters

func (k Keeper) DeleteConsumerInitializationParameters(ctx sdk.Context, consumerId string)

DeleteConsumerInitializationParameters deletes the initialization parameters associated with this consumer id

func (Keeper) DeleteConsumerMetadata

func (k Keeper) DeleteConsumerMetadata(ctx sdk.Context, consumerId string)

DeleteConsumerMetadata deletes the metadata associated with this consumer id

func (Keeper) DeleteConsumerOwnerAddress

func (k Keeper) DeleteConsumerOwnerAddress(ctx sdk.Context, consumerId string)

DeleteConsumerOwnerAddress deletes the owner address associated with this consumer id

func (Keeper) DeleteConsumerPhase

func (k Keeper) DeleteConsumerPhase(ctx sdk.Context, consumerId string)

DeleteConsumerPhase deletes the phase associated with this consumer id

func (Keeper) DeleteConsumerRemovalTime

func (k Keeper) DeleteConsumerRemovalTime(ctx sdk.Context, consumerId string)

DeleteConsumerRemovalTime deletes the removal time associated with this consumer id

func (Keeper) DeleteConsumerRewardDenom

func (k Keeper) DeleteConsumerRewardDenom(
	ctx sdk.Context,
	denom string,
)

func (Keeper) DeleteConsumerRewardsAllocation

func (k Keeper) DeleteConsumerRewardsAllocation(ctx sdk.Context, consumerId string)

DeleteConsumerRewardsAllocation deletes the consumer rewards allocation for the given consumer id

func (Keeper) DeleteConsumerValSet

func (k Keeper) DeleteConsumerValSet(
	ctx sdk.Context,
	consumerId string,
)

DeleteConsumerValSet deletes all the stored consumer validators for chain with `consumerId`

func (Keeper) DeleteConsumerValidator

func (k Keeper) DeleteConsumerValidator(
	ctx sdk.Context,
	consumerId string,
	providerConsAddr types.ProviderConsAddress,
)

DeleteConsumerValidator removes consumer validator with `providerAddr` address

func (Keeper) DeleteDenylist

func (k Keeper) DeleteDenylist(ctx sdk.Context, consumerId string)

DeleteDenylist deletes all denylisted validators

func (Keeper) DeleteEquivocationEvidenceMinHeight

func (k Keeper) DeleteEquivocationEvidenceMinHeight(ctx sdk.Context, consumerId string)

DeleteEquivocationEvidenceMinHeight deletes the minimum height of a valid consumer equivocation evidence for a given consumer id

func (Keeper) DeleteInitChainHeight

func (k Keeper) DeleteInitChainHeight(ctx sdk.Context, consumerId string)

DeleteInitChainHeight deletes the block height value for which the given consumer chain's channel was established

func (Keeper) DeleteKeyAssignments

func (k Keeper) DeleteKeyAssignments(ctx sdk.Context, consumerId string)

DeleteKeyAssignments deletes all the state needed for key assignments on a consumer chain

func (Keeper) DeleteLastProviderConsensusValSet

func (k Keeper) DeleteLastProviderConsensusValSet(
	ctx sdk.Context,
)

DeleteLastProviderConsensusValSet deletes all the stored validators from the last provider consensus validator set

func (Keeper) DeleteLastProviderConsensusValidator

func (k Keeper) DeleteLastProviderConsensusValidator(
	ctx sdk.Context,
	providerConsAddr types.ProviderConsAddress,
)

DeleteLastProviderConsensusValidator removes the validator with `providerConsAddr` address from the stored last provider consensus validator set

func (Keeper) DeleteMinimumPowerInTopN

func (k Keeper) DeleteMinimumPowerInTopN(
	ctx sdk.Context,
	consumerId string,
)

DeleteMinimumPowerInTopN removes the minimum power required for a validator to be in the top N for a given consumer chain.

func (Keeper) DeleteOptedIn

func (k Keeper) DeleteOptedIn(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
)

func (Keeper) DeletePendingVSCPackets

func (k Keeper) DeletePendingVSCPackets(ctx sdk.Context, consumerId string)

DeletePendingVSCPackets deletes the list of pending ValidatorSetChange packets for chain ID

func (Keeper) DeleteSlashAcks

func (k Keeper) DeleteSlashAcks(ctx sdk.Context, consumerId string)

DeleteSlashAcks deletes the slash acks for a given consumer id

func (Keeper) DeleteValidatorByConsumerAddr

func (k Keeper) DeleteValidatorByConsumerAddr(ctx sdk.Context, consumerId string, consumerAddr types.ConsumerConsAddress)

DeleteValidatorByConsumerAddr deletes the mapping from a validator's consensus address on a consumer to the validator's consensus address on the provider

func (Keeper) DeleteValidatorConsumerPubKey

func (k Keeper) DeleteValidatorConsumerPubKey(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress)

DeleteValidatorConsumerPubKey deletes a validator's public key assigned for a consumer chain

func (Keeper) DeleteValsetUpdateBlockHeight

func (k Keeper) DeleteValsetUpdateBlockHeight(ctx sdk.Context, valsetUpdateId uint64)

DeleteValsetUpdateBlockHeight deletes the block height value for a given vaset update id

func (Keeper) EndBlockCIS

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

EndBlockCIS contains the EndBlock logic needed for the Consumer Initiated Slashing sub-protocol

func (Keeper) EndBlockVSU

func (k Keeper) EndBlockVSU(ctx sdk.Context) ([]abci.ValidatorUpdate, error)

EndBlockVSU contains the EndBlock logic needed for the Validator Set Update sub-protocol

func (Keeper) ExportGenesis

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

ExportGenesis returns the CCV provider module's exported genesis

func (Keeper) FetchAndIncrementConsumerId

func (k Keeper) FetchAndIncrementConsumerId(ctx sdk.Context) string

FetchAndIncrementConsumerId fetches the first consumer id that can be used and increments the underlying consumer id

func (Keeper) FilterValidators

func (k Keeper) FilterValidators(
	ctx sdk.Context,
	consumerId string,
	bondedValidators []stakingtypes.Validator,
	predicate func(providerAddr types.ProviderConsAddress) (bool, error),
) ([]types.ConsensusValidator, error)

FilterValidators filters the provided `bondedValidators` according to `predicate` and returns the filtered set.

func (Keeper) FulfillsMinStake

func (k Keeper) FulfillsMinStake(
	ctx sdk.Context,
	minStake uint64,
	providerAddr types.ProviderConsAddress,
) (bool, error)

FulfillsMinStake returns true if the validator `providerAddr` has enough stake to validate chain with `consumerId` by checking its staked tokens against the minimum stake required to validate the chain.

func (Keeper) GetAllActiveConsumerIds

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

GetAllActiveConsumerIds returns all the consumer ids of chains that are registered, initialized, or launched

func (Keeper) GetAllChannelToConsumers

func (k Keeper) GetAllChannelToConsumers(ctx sdk.Context) (channelsToConsumers []struct {
	ChannelId  string
	ConsumerId string
},
)

GetAllChannelToConsumers gets all channel to chain mappings. If a mapping exists, then the CCV channel to that consumer chain is established.

Note that mapping from CCV channel IDs to consumer IDs is stored under keys with the following format: ChannelIdToConsumerIdKeyPrefix | channelID Thus, the returned array is in ascending order of channelIDs.

func (Keeper) GetAllCommissionRateValidators

func (k Keeper) GetAllCommissionRateValidators(
	ctx sdk.Context,
	consumerId string,
) (addresses []types.ProviderConsAddress)

GetAllCommissionRateValidators returns all the validator address that set a commission rate for the given consumer id

func (Keeper) GetAllConsumerAddrsToPrune

func (k Keeper) GetAllConsumerAddrsToPrune(ctx sdk.Context, consumerId string) (consumerAddrsToPrune []types.ConsumerAddrsToPruneV2)

GetAllConsumerAddrsToPrune gets all consumer addresses that can be eventually pruned for a given consumerId.

Note that the list of all consumer addresses is stored under keys with the following format: ConsumerAddrsToPruneV2BytePrefix | len(consumerId) | consumerId | timestamp Thus, the returned array is in ascending order of timestamps.

func (Keeper) GetAllConsumerIds

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

GetAllConsumerIds returns all the existing consumer ids

func (Keeper) GetAllConsumerRewardDenoms

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

func (Keeper) GetAllConsumersWithIBCClients

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

GetAllConsumersWithIBCClients returns the ids of all consumer chains that with IBC clients created.

func (Keeper) GetAllOptedIn

func (k Keeper) GetAllOptedIn(
	ctx sdk.Context,
	consumerId string,
) (providerConsAddresses []types.ProviderConsAddress)

GetAllOptedIn returns all the opted-in validators on chain `consumerId`

func (Keeper) GetAllValidatorConsumerPubKeys

func (k Keeper) GetAllValidatorConsumerPubKeys(ctx sdk.Context, consumerId *string) (validatorConsumerPubKeys []types.ValidatorConsumerPubKey)

GetAllValidatorConsumerPubKeys gets all the validators public keys assigned for a consumer chain If consumerId is nil, it returns all the validators public keys assigned for all consumer chains

Note that the validators public keys assigned for a consumer chain are stored under keys with the following format: ConsumerValidatorsBytePrefix | len(consumerId) | consumerId | providerAddress Thus, the returned array is

  • in ascending order of providerAddresses, if consumerId is not nil;
  • in undetermined order, if consumerId is nil.

func (Keeper) GetAllValidatorsByConsumerAddr

func (k Keeper) GetAllValidatorsByConsumerAddr(ctx sdk.Context, consumerId *string) (validatorConsumerAddrs []types.ValidatorByConsumerAddr)

GetValidatorsByConsumerAddrs gets all the mappings from consensus addresses on a given consumer chain to consensus addresses on the provider chain. If consumerId is nil, it returns all the mappings from consensus addresses on all consumer chains.

Note that the mappings for a consumer chain are stored under keys with the following format: ValidatorsByConsumerAddrKeyPrefix | len(consumerId) | consumerId | consumerAddress Thus, the returned array is

  • in ascending order of consumerAddresses, if consumerId is not nil;
  • in undetermined order, if consumerId is nil.

func (Keeper) GetAllValsetUpdateBlockHeights

func (k Keeper) GetAllValsetUpdateBlockHeights(ctx sdk.Context) (valsetUpdateBlockHeights []types.ValsetUpdateIdToHeight)

GetAllValsetUpdateBlockHeights gets all the block heights for all valset updates

Note that the mapping from vscIDs to block heights is stored under keys with the following format: ValsetUpdateBlockHeightKeyPrefix | vscID Thus, the returned array is in ascending order of vscIDs.

func (Keeper) GetAllowList

func (k Keeper) GetAllowList(
	ctx sdk.Context,
	consumerId string,
) (providerConsAddresses []types.ProviderConsAddress)

GetAllowList returns all allowlisted validators

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the x/ccv/provider module's authority.

func (Keeper) GetBlocksPerEpoch

func (k Keeper) GetBlocksPerEpoch(ctx sdk.Context) int64

GetBlocksPerEpoch returns the number of blocks that constitute an epoch

func (Keeper) GetByzantineValidators

func (k Keeper) GetByzantineValidators(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour) (validators []*tmtypes.Validator, err error)

GetByzantineValidators returns the validators that signed both headers. If the misbehavior is an equivocation light client attack, then these validators are the Byzantine validators.

func (Keeper) GetCCVTimeoutPeriod

func (k Keeper) GetCCVTimeoutPeriod(ctx sdk.Context) time.Duration

GetCCVTimeoutPeriod returns the timeout period for sent ibc packets

func (Keeper) GetChannelIdToConsumerId

func (k Keeper) GetChannelIdToConsumerId(ctx sdk.Context, channelID string) (string, bool)

GetChannelIdToConsumerId gets the consumer id for a given CCV channel id

func (Keeper) GetClientIdToConsumerId

func (k Keeper) GetClientIdToConsumerId(ctx sdk.Context, clientId string) (string, bool)

GetClientIdToConsumerId returns the consumer id associated with this client id

func (Keeper) GetConsumerAddrsToPrune

func (k Keeper) GetConsumerAddrsToPrune(
	ctx sdk.Context,
	consumerId string,
	ts time.Time,
) (consumerAddrsToPrune types.AddressList)

GetConsumerAddrsToPrune returns the list of consumer addresses to prune stored under timestamp ts. Note that this method is only used in testing.

func (Keeper) GetConsumerChain

func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chain, error)

GetConsumerChain returns a Chain data structure with all the necessary fields

func (Keeper) GetConsumerChainConsensusValidatorsKey

func (k Keeper) GetConsumerChainConsensusValidatorsKey(ctx sdk.Context, consumerId string) []byte

GetConsumerChainConsensusValidatorsKey returns the store key for consumer validators of the consumer chain with `consumerId`

func (Keeper) GetConsumerChainId

func (k Keeper) GetConsumerChainId(ctx sdk.Context, consumerId string) (string, error)

GetConsumerChainId returns the chain id associated with this consumer id

func (Keeper) GetConsumerClientId

func (k Keeper) GetConsumerClientId(ctx sdk.Context, consumerId string) (string, bool)

GetConsumerClientId returns the client id for the given consumer id.

func (Keeper) GetConsumerCommissionRate

func (k Keeper) GetConsumerCommissionRate(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
) (math.LegacyDec, bool)

GetConsumerCommissionRate returns the per-consumer commission rate set for the given validator address

func (Keeper) GetConsumerGenesis

func (k Keeper) GetConsumerGenesis(ctx sdk.Context, consumerId string) (ccv.ConsumerGenesisState, bool)

func (Keeper) GetConsumerId

func (k Keeper) GetConsumerId(ctx sdk.Context) (uint64, bool)

GetConsumerId returns the next to-be-assigned consumer id

func (Keeper) GetConsumerIdToChannelId

func (k Keeper) GetConsumerIdToChannelId(ctx sdk.Context, consumerId string) (string, bool)

GetConsumerIdToChannelId gets the CCV channelId for the given consumer id

func (Keeper) GetConsumerInitializationParameters

func (k Keeper) GetConsumerInitializationParameters(ctx sdk.Context, consumerId string) (types.ConsumerInitializationParameters, error)

GetConsumerInitializationParameters returns the initialization parameters associated with this consumer id

func (Keeper) GetConsumerMetadata

func (k Keeper) GetConsumerMetadata(ctx sdk.Context, consumerId string) (types.ConsumerMetadata, error)

GetConsumerMetadata returns the registration record associated with this consumer id

func (Keeper) GetConsumerOwnerAddress

func (k Keeper) GetConsumerOwnerAddress(ctx sdk.Context, consumerId string) (string, error)

GetConsumerOwnerAddress returns the owner address associated with this consumer id

func (Keeper) GetConsumerPhase

func (k Keeper) GetConsumerPhase(ctx sdk.Context, consumerId string) types.ConsumerPhase

GetConsumerPhase returns the phase associated with this consumer id

func (Keeper) GetConsumerPowerShapingParameters

func (k Keeper) GetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string) (types.PowerShapingParameters, error)

GetConsumerPowerShapingParameters returns the power-shaping parameters associated with this consumer id

func (Keeper) GetConsumerRemovalTime

func (k Keeper) GetConsumerRemovalTime(ctx sdk.Context, consumerId string) (time.Time, error)

GetConsumerRemovalTime returns the removal time associated with the to-be-removed chain with consumer id

func (Keeper) GetConsumerRewardDenomRegistrationFee

func (k Keeper) GetConsumerRewardDenomRegistrationFee(ctx sdk.Context) sdk.Coin

func (Keeper) GetConsumerRewardsAllocation

func (k Keeper) GetConsumerRewardsAllocation(ctx sdk.Context, consumerId string) (pool types.ConsumerRewardsAllocation)

GetConsumerRewardsAllocation returns the consumer rewards allocation for the given consumer id

func (Keeper) GetConsumerRewardsPool

func (k Keeper) GetConsumerRewardsPool(ctx sdk.Context) sdk.Coins

GetConsumerRewardsPool returns the balance of the consumer rewards pool module account

func (Keeper) GetConsumerRewardsPoolAddressStr

func (k Keeper) GetConsumerRewardsPoolAddressStr(ctx sdk.Context) string

func (Keeper) GetConsumerValSet

func (k Keeper) GetConsumerValSet(
	ctx sdk.Context,
	consumerId string,
) ([]types.ConsensusValidator, error)

GetConsumerValSet returns all the consumer validators for chain with `consumerId`

func (Keeper) GetConsumerValidator

func (k Keeper) GetConsumerValidator(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) (types.ConsensusValidator, bool)

GetConsumerValidator returns the consumer validator with `providerAddr` if it exists for chain with `consumerId`

func (Keeper) GetConsumersToBeLaunched

func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) (types.ConsumerIds, error)

GetConsumersToBeLaunched returns all the consumer ids of chains stored under this spawn time

func (Keeper) GetConsumersToBeRemoved

func (k Keeper) GetConsumersToBeRemoved(ctx sdk.Context, removalTime time.Time) (types.ConsumerIds, error)

GetConsumersToBeRemoved returns all the consumer ids of chains stored under this removal time

func (Keeper) GetDenyList

func (k Keeper) GetDenyList(
	ctx sdk.Context,
	consumerId string,
) (providerConsAddresses []types.ProviderConsAddress)

GetDenyList returns all denylisted validators

func (Keeper) GetEffectiveValPower

func (k Keeper) GetEffectiveValPower(ctx sdktypes.Context,
	valConsAddr providertypes.ProviderConsAddress,
) math.Int

Obtains the effective validator power relevant to a validator consensus address.

func (Keeper) GetEquivocationEvidenceMinHeight

func (k Keeper) GetEquivocationEvidenceMinHeight(ctx sdk.Context, consumerId string) uint64

GetEquivocationEvidenceMinHeight returns the minimum height of a valid consumer equivocation evidence for a given consumer id

func (Keeper) GetInitChainHeight

func (k Keeper) GetInitChainHeight(ctx sdk.Context, consumerId string) (uint64, bool)

GetInitChainHeight returns the provider block height when the given consumer chain was initiated

func (Keeper) GetLastBondedValidators

func (k Keeper) GetLastBondedValidators(ctx sdk.Context) ([]stakingtypes.Validator, error)

GetLastBondedValidators iterates the last validator powers in the staking module and returns the first MaxValidators many validators with the largest powers.

func (Keeper) GetLastProviderConsensusActiveValidators

func (k Keeper) GetLastProviderConsensusActiveValidators(ctx sdk.Context) ([]stakingtypes.Validator, error)

GetLastProviderConsensusActiveValidators returns the `MaxProviderConsensusValidators` many validators with the largest powers from the last bonded validators in the staking module.

func (Keeper) GetLastProviderConsensusValSet

func (k Keeper) GetLastProviderConsensusValSet(
	ctx sdk.Context,
) ([]types.ConsensusValidator, error)

GetLastProviderConsensusValSet returns the last stored validator set sent to the consensus engine on the provider

func (Keeper) GetLastTotalProviderConsensusPower

func (k Keeper) GetLastTotalProviderConsensusPower(
	ctx sdk.Context,
) (math.Int, error)

GetLastTotalProviderConsensusPower returns the total power of the last stored validator set sent to the consensus engine on the provider

func (Keeper) GetMaxProviderConsensusValidators

func (k Keeper) GetMaxProviderConsensusValidators(ctx sdk.Context) int64

GetMaxProviderConsensusValidators returns the number of validators that will be passed on from the staking module to the consensus engine on the provider

func (Keeper) GetMinimumPowerInTopN

func (k Keeper) GetMinimumPowerInTopN(
	ctx sdk.Context,
	consumerId string,
) (int64, bool)

GetMinimumPowerInTopN returns the minimum power required for a validator to be in the top N for a given consumer chain.

func (Keeper) GetNumberOfEpochsToStartReceivingRewards

func (k Keeper) GetNumberOfEpochsToStartReceivingRewards(ctx sdk.Context) int64

GetNumberOfEpochsToStartReceivingRewards returns the number of epochs needed by a validator to continuously validate to start receiving rewards

func (Keeper) GetParams

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

GetParams returns the paramset for the provider module

func (Keeper) GetPendingVSCPackets

func (k Keeper) GetPendingVSCPackets(ctx sdk.Context, consumerId string) []ccv.ValidatorSetChangePacketData

GetPendingVSCPackets returns the list of pending ValidatorSetChange packets stored under consumer id

func (Keeper) GetPort

func (k Keeper) GetPort(ctx sdk.Context) string

GetPort returns the portID for the CCV module. Used in ExportGenesis

func (Keeper) GetProviderAddrFromConsumerAddr

func (k Keeper) GetProviderAddrFromConsumerAddr(
	ctx sdk.Context,
	consumerId string,
	consumerAddr types.ConsumerConsAddress,
) types.ProviderConsAddress

GetProviderAddrFromConsumerAddr returns the consensus address of a validator with consAddr set as the consensus address on a consumer chain

func (Keeper) GetSlashAcks

func (k Keeper) GetSlashAcks(ctx sdk.Context, consumerId string) []string

GetSlashAcks returns the slash acks stored under the given consumer id

TODO: SlashAcks should be persisted as a list of ConsumerConsAddr types, not strings. See https://github.com/cosmos/interchain-security/issues/728

func (Keeper) GetSlashLog

func (k Keeper) GetSlashLog(
	ctx sdk.Context,
	providerAddr types.ProviderConsAddress,
) (found bool)

GetSlashLog returns a validator's slash log status True will be returned if an entry exists for a given validator address

func (Keeper) GetSlashMeter

func (k Keeper) GetSlashMeter(ctx sdktypes.Context) math.Int

GetSlashMeter returns a meter (persisted as a signed int) which stores an amount of voting power, corresponding to an allowance of validators that can be jailed/tombstoned over time.

Note: the value of this int should always be in the range of tendermint's [-MaxVotingPower, MaxVotingPower]

func (Keeper) GetSlashMeterAllowance

func (k Keeper) GetSlashMeterAllowance(ctx sdktypes.Context) math.Int

GetSlashMeterAllowance returns the amount of voting power units (int) that would be added to the slash meter for a replenishment that would happen this block, this allowance value also serves as the max value for the meter for this block.

Note: allowance can change between blocks, since it is directly correlated to total voting power. The slash meter must be less than or equal to the allowance for this block, before any slash packet handling logic can be executed.

func (Keeper) GetSlashMeterReplenishFraction

func (k Keeper) GetSlashMeterReplenishFraction(ctx sdk.Context) string

GetSlashMeterReplenishFraction returns the string fraction of total voting power that is replenished to the slash meter every replenish period. This param also serves as a maximum fraction of total voting power that the slash meter can hold.

func (Keeper) GetSlashMeterReplenishPeriod

func (k Keeper) GetSlashMeterReplenishPeriod(ctx sdk.Context) time.Duration

GetSlashMeterReplenishPeriod returns the period in which: Once the slash meter becomes not-full, the slash meter is replenished after this period.

func (Keeper) GetSlashMeterReplenishTimeCandidate

func (k Keeper) GetSlashMeterReplenishTimeCandidate(ctx sdktypes.Context) time.Time

GetSlashMeterReplenishTimeCandidate returns the next UTC time the slash meter could potentially be replenished.

Note: this value is the next time the slash meter will be replenished IFF the slash meter is NOT full. Otherwise this value will be updated in every future block until the slash meter becomes NOT full.

func (Keeper) GetTemplateClient

func (k Keeper) GetTemplateClient(ctx sdk.Context) *ibctmtypes.ClientState

GetTemplateClient returns the template consumer client

func (Keeper) GetTrustingPeriodFraction

func (k Keeper) GetTrustingPeriodFraction(ctx sdk.Context) string

GetTrustingPeriodFraction returns a TrustingPeriodFraction used to compute the provider IBC client's TrustingPeriod as UnbondingPeriod / TrustingPeriodFraction

func (Keeper) GetValidatorByConsumerAddr

func (k Keeper) GetValidatorByConsumerAddr(
	ctx sdk.Context,
	consumerId string,
	consumerAddr types.ConsumerConsAddress,
) (providerAddr types.ProviderConsAddress, found bool)

GetValidatorByConsumerAddr returns a validator's consensus address on the provider given the validator's consensus address on a consumer

func (Keeper) GetValidatorConsumerPubKey

func (k Keeper) GetValidatorConsumerPubKey(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
) (consumerKey tmprotocrypto.PublicKey, found bool)

GetValidatorConsumerPubKey returns a validator's public key assigned for a consumer chain

func (Keeper) GetValidatorSetUpdateId

func (k Keeper) GetValidatorSetUpdateId(ctx sdk.Context) (validatorSetUpdateId uint64)

func (Keeper) GetValsetUpdateBlockHeight

func (k Keeper) GetValsetUpdateBlockHeight(ctx sdk.Context, valsetUpdateId uint64) (uint64, bool)

GetValsetUpdateBlockHeight gets the block height for a given valset update id

func (Keeper) HandleConsumerDoubleVoting

func (k Keeper) HandleConsumerDoubleVoting(
	ctx sdk.Context,
	consumerId string,
	evidence *tmtypes.DuplicateVoteEvidence,
	pubkey cryptotypes.PubKey,
) error

HandleConsumerDoubleVoting verifies a double voting evidence for a given a consumer id and a public key and, if successful, executes the slashing, jailing, and tombstoning of the malicious validator.

func (Keeper) HandleConsumerMisbehaviour

func (k Keeper) HandleConsumerMisbehaviour(ctx sdk.Context, consumerId string, misbehaviour ibctmtypes.Misbehaviour) error

HandleConsumerMisbehaviour checks if the given IBC misbehaviour corresponds to an equivocation light client attack, and in this case, slashes, jails, and tombstones

func (Keeper) HandleOptIn

func (k Keeper) HandleOptIn(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, consumerKey string) error

HandleOptIn prepares validator `providerAddr` to opt in to `consumerId` with an optional `consumerKey` consumer public key. Note that the validator only opts in at the end of an epoch.

func (Keeper) HandleOptOut

func (k Keeper) HandleOptOut(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) error

HandleOptOut prepares validator `providerAddr` to opt out from running `consumerId`. Note that the validator only opts out at the end of an epoch.

func (Keeper) HandleSetConsumerCommissionRate

func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, commissionRate math.LegacyDec) error

HandleSetConsumerCommissionRate sets a per-consumer chain commission rate for the given provider address on the condition that the given consumer chain exists.

func (Keeper) HandleSlashPacket

func (k Keeper) HandleSlashPacket(ctx sdk.Context, consumerId string, data ccv.SlashPacketData)

HandleSlashPacket potentially jails a misbehaving validator for a downtime infraction. This method should NEVER be called with a double-sign infraction.

func (Keeper) HasMinPower

func (k Keeper) HasMinPower(ctx sdk.Context, providerAddr types.ProviderConsAddress, minPower int64) (bool, error)

HasMinPower returns true if the `providerAddr` voting power is GTE than the given minimum power

func (*Keeper) Hooks

func (k *Keeper) Hooks() Hooks

Returns new provider hooks

func (Keeper) IdentifyConsumerIdFromIBCPacket

func (k Keeper) IdentifyConsumerIdFromIBCPacket(ctx sdk.Context, packet channeltypes.Packet) (string, error)

IdentifyConsumerIdFromIBCPacket checks if the packet destination matches a registered consumer chain. If so, it returns the consumer chain ID, otherwise an error.

func (Keeper) IncrementValidatorSetUpdateId

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

func (Keeper) InitGenesis

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

InitGenesis initializes the CCV provider state and binds to PortID.

func (Keeper) InitGenesisValUpdates

func (k Keeper) InitGenesisValUpdates(ctx sdk.Context) []abci.ValidatorUpdate

InitGenesisValUpdates returns the genesis validator set updates for the provider module by selecting the first MaxProviderConsensusValidators from the staking module's validator set.

func (Keeper) InitializeConsumer

func (k Keeper) InitializeConsumer(ctx sdk.Context, consumerId string) (time.Time, bool)

InitializeConsumer tries to move a consumer with `consumerId` to the initialized phase. If successful, it returns the spawn time and true.

func (Keeper) InitializeSlashMeter

func (k Keeper) InitializeSlashMeter(ctx sdktypes.Context)

InitializeSlashMeter initializes the slash meter to it's max value (also its allowance), and sets the replenish time candidate to one replenish period from current block time.

func (Keeper) IsAllowlistEmpty

func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, consumerId string) bool

IsAllowlistEmpty returns `true` if no validator is allowlisted on chain `consumerId`

func (Keeper) IsAllowlisted

func (k Keeper) IsAllowlisted(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
) bool

IsAllowlisted returns `true` if validator with `providerAddr` has been allowlisted on chain `consumerId`

func (Keeper) IsBound

func (k Keeper) IsBound(ctx sdk.Context, portID string) bool

IsBound checks if the CCV module is already bound to the desired port

func (Keeper) IsConsumerActive

func (k Keeper) IsConsumerActive(ctx sdk.Context, consumerId string) bool

IsConsumerActive checks if a consumer chain is either registered, initialized, or launched.

func (Keeper) IsConsumerValidator

func (k Keeper) IsConsumerValidator(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) bool

IsConsumerValidator returns `true` if the consumer validator with `providerAddr` exists for chain with `consumerId` and `false` otherwise

func (Keeper) IsDenylistEmpty

func (k Keeper) IsDenylistEmpty(ctx sdk.Context, consumerId string) bool

IsDenylistEmpty returns `true` if no validator is denylisted on chain `consumerId`

func (Keeper) IsDenylisted

func (k Keeper) IsDenylisted(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
) bool

IsDenylisted returns `true` if validator with `providerAddr` has been denylisted on chain `consumerId`

func (Keeper) IsEligibleForConsumerRewards

func (k Keeper) IsEligibleForConsumerRewards(ctx sdk.Context, consumerValidatorHeight int64) bool

IsEligibleForConsumerRewards returns `true` if the validator with `consumerValidatorHeight` has been a consumer validator for a long period of time and hence is eligible to receive rewards, and false otherwise

func (Keeper) IsOptedIn

func (k Keeper) IsOptedIn(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
) bool

func (Keeper) IterateBondedValidatorsByPower

func (k Keeper) IterateBondedValidatorsByPower(ctx context.Context, fn func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error

IterateBondedValidatorsByPower iterates over the consensus-active validators by power. The same as IterateBondedValidatorsByPower in the StakingKeeper, but only returns the first MaxProviderConsensusValidators validators. This is used to implement the interface of the staking keeper to interact with modules that need to reference the consensus-active validators.

func (Keeper) IterateDelegations

func (k Keeper) IterateDelegations(ctx context.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) error

IterateDelegations is the same as IterateDelegations in the StakingKeeper. Necessary to implement the interface of the staking keeper to interface with other modules.

func (Keeper) JailAndTombstoneValidator

func (k Keeper) JailAndTombstoneValidator(ctx sdk.Context, providerAddr types.ProviderConsAddress) error

JailAndTombstoneValidator jails and tombstones the validator with the given provider consensus address

func (Keeper) LaunchConsumer

func (k Keeper) LaunchConsumer(
	ctx sdk.Context,
	bondedValidators []stakingtypes.Validator,
	activeValidators []stakingtypes.Validator,
	consumerId string,
) error

LaunchConsumer launches the chain with the provided consumer id by creating the consumer client and the respective consumer genesis file

TODO add unit test for LaunchConsumer

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MakeConsumerGenesis

func (k Keeper) MakeConsumerGenesis(
	ctx sdk.Context,
	consumerId string,
	initialValidatorUpdates []abci.ValidatorUpdate,
) (gen ccv.ConsumerGenesisState, err error)

MakeConsumerGenesis returns the created consumer genesis state for consumer chain `consumerId`, as well as the validator hash of the initial validator set of the consumer chain

func (Keeper) OnAcknowledgementPacket

func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, ack channeltypes.Acknowledgement) error

OnAcknowledgementPacket handles acknowledgments for sent VSC packets

func (Keeper) OnRecvSlashPacket

func (k Keeper) OnRecvSlashPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	data ccv.SlashPacketData,
) (ccv.PacketAckResult, error)

OnRecvSlashPacket delivers a received slash packet, validates it and then queues the slash packet as pending if valid.

func (Keeper) OnTimeoutPacket

func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) error

OnTimeoutPacket aborts the transaction if no chain exists for the destination channel, otherwise it stops the chain

func (Keeper) OptInTopNValidators

func (k Keeper) OptInTopNValidators(
	ctx sdk.Context,
	consumerId string,
	bondedValidators []stakingtypes.Validator,
	minPowerToOptIn int64,
) error

OptInTopNValidators opts in to `consumerId` all the `bondedValidators` that have at least `minPowerToOptIn` power

func (Keeper) ParseConsumerKey

func (k Keeper) ParseConsumerKey(consumerKey string) (tmprotocrypto.PublicKey, error)

ParseConsumerKey parses the ED25519 PubKey`consumerKey` from a JSON string and constructs its corresponding `tmprotocrypto.PublicKey`

func (Keeper) PrepareConsumerForLaunch

func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime, spawnTime time.Time) error

PrepareConsumerForLaunch prepares to move the launch of a consumer chain from the previous spawn time to spawn time. Previous spawn time can correspond to its zero value if the validator was not previously set for launch.

func (Keeper) ProviderValidatorUpdates

func (k Keeper) ProviderValidatorUpdates(ctx sdk.Context) ([]abci.ValidatorUpdate, error)

ProviderValidatorUpdates returns changes in the provider consensus validator set from the last block to the current one. It retrieves the bonded validators from the staking module and creates a `ConsumerValidator` object for each validator. The maximum number of validators is determined by the `maxValidators` parameter. The function returns the difference between the current validator set and the next validator set as a list of `abci.ValidatorUpdate` objects.

func (Keeper) PruneKeyAssignments

func (k Keeper) PruneKeyAssignments(ctx sdk.Context, consumerId string)

PruneKeyAssignments prunes the consumer addresses no longer needed as they cannot be referenced in slash requests (by a correct consumer)

func (Keeper) QueryBlocksUntilNextEpoch

QueryBlocksUntilNextEpoch returns the number of blocks until the next epoch

func (Keeper) QueryConsumerChain

QueryConsumerChain returns the consumer chain associated with the consumer id

func (Keeper) QueryConsumerChainOptedInValidators

QueryConsumerChainOptedInValidators returns all validators that opted-in to a given consumer chain

func (Keeper) QueryConsumerChainsValidatorHasToValidate

QueryConsumerChainsValidatorHasToValidate returns all consumer chains that the given validator has to validate now or in the next epoch if nothing changes.

func (Keeper) QueryConsumerIdFromClientId

QueryConsumerIdFromClientId returns the consumer id of the chain associated with this client id

func (Keeper) QueryConsumerValidators

QueryConsumerValidators returns all validators that are consumer validators in a given consumer chain

func (Keeper) QueryParams

QueryParams returns all parameters and current values of provider

func (Keeper) QueryValidatorConsumerCommissionRate

QueryValidatorConsumerCommissionRate returns the commission rate a given validator charges on a given consumer chain

func (Keeper) QueueVSCPackets

func (k Keeper) QueueVSCPackets(ctx sdk.Context) error

QueueVSCPackets queues latest validator updates for every consumer chain with the IBC client created.

TODO (mpoke): iterate only over consumers with established channel -- GetAllChannelToConsumers

func (Keeper) RemoveConsumerToBeLaunched

func (k Keeper) RemoveConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error

RemoveConsumerToBeLaunched removes consumer id from if stored for this specific spawn time

func (Keeper) RemoveConsumerToBeRemoved

func (k Keeper) RemoveConsumerToBeRemoved(ctx sdk.Context, consumerId string, removalTime time.Time) error

RemoveConsumerToBeRemoved removes consumer id from the given removal time

func (Keeper) ReplenishSlashMeter

func (k Keeper) ReplenishSlashMeter(ctx sdktypes.Context)

func (Keeper) SendVSCPackets

func (k Keeper) SendVSCPackets(ctx sdk.Context) error

SendVSCPackets iterates over all consumers chains with created IBC clients and sends pending VSC packets to the chains with established CCV channels. If the CCV channel is not established for a consumer chain, the updates will remain queued until the channel is established

TODO (mpoke): iterate only over consumers with established channel -- GetAllChannelToConsumers

func (Keeper) SendVSCPacketsToChain

func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId, channelId string) error

SendVSCPacketsToChain sends all queued VSC packets to the specified chain

func (Keeper) SetAllowlist

func (k Keeper) SetAllowlist(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
)

SetAllowlist allowlists validator with `providerAddr` address on chain `consumerId`

func (Keeper) SetChannelToConsumerId

func (k Keeper) SetChannelToConsumerId(ctx sdk.Context, channelId, consumerId string)

SetChannelToConsumerId sets the mapping from the CCV channel id to the consumer id.

func (Keeper) SetConsumerChain

func (k Keeper) SetConsumerChain(ctx sdk.Context, channelID string) error

SetConsumerChain ensures that the consumer chain has not already been set by a different channel, and then sets the consumer chain mappings in keeper, and set the channel status to validating. If there is already a CCV channel between the provider and consumer chain then close the channel, so that another channel can be made.

SetConsumerChain is called by OnChanOpenConfirm.

func (Keeper) SetConsumerChainId

func (k Keeper) SetConsumerChainId(ctx sdk.Context, consumerId, chainId string)

SetConsumerChainId sets the chain id associated with this consumer id

func (Keeper) SetConsumerClientId

func (k Keeper) SetConsumerClientId(ctx sdk.Context, consumerId, clientId string)

SetConsumerClientId sets the client id for the given consumer id. Note that the method also stores a reverse index that can be accessed by calling GetClientIdToConsumerId.

func (Keeper) SetConsumerCommissionRate

func (k Keeper) SetConsumerCommissionRate(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
	commissionRate math.LegacyDec,
) error

SetConsumerCommissionRate sets a per-consumer chain commission rate for the given validator address

func (Keeper) SetConsumerGenesis

func (k Keeper) SetConsumerGenesis(ctx sdk.Context, consumerId string, gen ccv.ConsumerGenesisState) error

func (Keeper) SetConsumerIdToChannelId

func (k Keeper) SetConsumerIdToChannelId(ctx sdk.Context, consumerId, channelId string)

SetConsumerIdToChannelId sets the mapping from a consumer id to the CCV channel id for that consumer chain.

func (Keeper) SetConsumerInitializationParameters

func (k Keeper) SetConsumerInitializationParameters(ctx sdk.Context, consumerId string, parameters types.ConsumerInitializationParameters) error

SetConsumerInitializationParameters sets the initialization parameters associated with this consumer id

func (Keeper) SetConsumerMetadata

func (k Keeper) SetConsumerMetadata(ctx sdk.Context, consumerId string, metadata types.ConsumerMetadata) error

SetConsumerMetadata sets the registration record associated with this consumer id

func (Keeper) SetConsumerOwnerAddress

func (k Keeper) SetConsumerOwnerAddress(ctx sdk.Context, consumerId, chainId string)

SetConsumerOwnerAddress sets the chain id associated with this consumer id

func (Keeper) SetConsumerPhase

func (k Keeper) SetConsumerPhase(ctx sdk.Context, consumerId string, phase types.ConsumerPhase)

SetConsumerPhase sets the phase associated with this consumer id

func (Keeper) SetConsumerPowerShapingParameters

func (k Keeper) SetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string, parameters types.PowerShapingParameters) error

SetConsumerPowerShapingParameters sets the power-shaping parameters associated with this consumer id. Note that it also updates the allowlist and denylist indexes if they are different

func (Keeper) SetConsumerRemovalTime

func (k Keeper) SetConsumerRemovalTime(ctx sdk.Context, consumerId string, removalTime time.Time) error

SetConsumerRemovalTime sets the removal time associated with this consumer id

func (Keeper) SetConsumerRewardDenom

func (k Keeper) SetConsumerRewardDenom(
	ctx sdk.Context,
	denom string,
)

func (Keeper) SetConsumerRewardsAllocation

func (k Keeper) SetConsumerRewardsAllocation(ctx sdk.Context, consumerId string, pool types.ConsumerRewardsAllocation)

SetConsumerRewardsAllocation sets the consumer rewards allocation for the given consumer id

func (Keeper) SetConsumerValSet

func (k Keeper) SetConsumerValSet(ctx sdk.Context, consumerId string, nextValidators []types.ConsensusValidator) error

SetConsumerValSet resets the current consumer validators with the `nextValidators` computed by `FilterValidators` and hence this method should only be called after `FilterValidators` has completed.

func (Keeper) SetConsumerValidator

func (k Keeper) SetConsumerValidator(
	ctx sdk.Context,
	consumerId string,
	validator types.ConsensusValidator,
) error

SetConsumerValidator sets provided consumer `validator` on the consumer chain with `consumerId`

func (Keeper) SetDenylist

func (k Keeper) SetDenylist(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
)

SetDenylist denylists validator with `providerAddr` address on chain `consumerId`

func (Keeper) SetEquivocationEvidenceMinHeight

func (k Keeper) SetEquivocationEvidenceMinHeight(ctx sdk.Context, consumerId string, height uint64)

SetEquivocationEvidenceMinHeight sets the minimum height of a valid consumer equivocation evidence for a given consumer id

func (*Keeper) SetGovKeeper

func (k *Keeper) SetGovKeeper(govKeeper govkeeper.Keeper)

func (Keeper) SetInitChainHeight

func (k Keeper) SetInitChainHeight(ctx sdk.Context, consumerId string, height uint64)

SetInitChainHeight sets the provider block height when the given consumer chain was initiated

func (Keeper) SetLastProviderConsensusValSet

func (k Keeper) SetLastProviderConsensusValSet(ctx sdk.Context, nextValidators []types.ConsensusValidator) error

SetLastProviderConsensusValSet resets the stored last validator set sent to the consensus engine on the provider to the provided `nextValidators`.

func (Keeper) SetLastProviderConsensusValidator

func (k Keeper) SetLastProviderConsensusValidator(
	ctx sdk.Context,
	validator types.ConsensusValidator,
) error

SetLastProviderConsensusValidator sets the given validator to be stored as part of the last provider consensus validator set

func (Keeper) SetMinimumPowerInTopN

func (k Keeper) SetMinimumPowerInTopN(
	ctx sdk.Context,
	consumerId string,
	power int64,
)

SetMinimumPowerInTopN sets the minimum power required for a validator to be in the top N for a given consumer chain.

func (Keeper) SetOptedIn

func (k Keeper) SetOptedIn(
	ctx sdk.Context,
	consumerId string,
	providerConsAddress types.ProviderConsAddress,
)

func (Keeper) SetParams

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

SetParams sets the params for the provider module

func (Keeper) SetPort

func (k Keeper) SetPort(ctx sdk.Context, portID string)

SetPort sets the portID for the CCV module. Used in InitGenesis

func (Keeper) SetSlashAcks

func (k Keeper) SetSlashAcks(ctx sdk.Context, consumerId string, acks []string)

SetSlashAcks sets the slash acks under the given chain ID

TODO: SlashAcks should be persisted as a list of ConsumerConsAddr types, not strings. See https://github.com/cosmos/interchain-security/issues/728

func (Keeper) SetSlashLog

func (k Keeper) SetSlashLog(
	ctx sdk.Context,
	providerAddr types.ProviderConsAddress,
)

SetSlashLog updates validator's slash log for a consumer chain If an entry exists for a given validator address, at least one double signing slash packet was received by the provider from at least one consumer chain

func (Keeper) SetSlashMeter

func (k Keeper) SetSlashMeter(ctx sdktypes.Context, value math.Int)

SetSlashMeter sets the slash meter to the given signed int value

Note: the value of this int should always be in the range of tendermint's [-MaxTotalVotingPower, MaxTotalVotingPower]

func (Keeper) SetSlashMeterReplenishTimeCandidate

func (k Keeper) SetSlashMeterReplenishTimeCandidate(ctx sdktypes.Context)

SetSlashMeterReplenishTimeCandidate sets the next time the slash meter may be replenished to the current block time + the configured slash meter replenish period.

Note: this value is the next time the slash meter will be replenished IFF the slash meter is NOT full. Otherwise this value will be updated in every future block until the slash meter becomes NOT full.

func (Keeper) SetValidatorByConsumerAddr

func (k Keeper) SetValidatorByConsumerAddr(
	ctx sdk.Context,
	consumerId string,
	consumerAddr types.ConsumerConsAddress,
	providerAddr types.ProviderConsAddress,
)

SetValidatorByConsumerAddr sets the mapping from a validator's consensus address on a consumer to the validator's consensus address on the provider

func (Keeper) SetValidatorConsumerPubKey

func (k Keeper) SetValidatorConsumerPubKey(
	ctx sdk.Context,
	consumerId string,
	providerAddr types.ProviderConsAddress,
	consumerKey tmprotocrypto.PublicKey,
)

SetValidatorConsumerPubKey sets a validator's public key assigned for a consumer chain

func (Keeper) SetValidatorSetUpdateId

func (k Keeper) SetValidatorSetUpdateId(ctx sdk.Context, valUpdateID uint64)

func (Keeper) SetValsetUpdateBlockHeight

func (k Keeper) SetValsetUpdateBlockHeight(ctx sdk.Context, valsetUpdateId, blockHeight uint64)

SetValsetUpdateBlockHeight sets the block height for a given valset update id

func (Keeper) SlashValidator

func (k Keeper) SlashValidator(ctx sdk.Context, providerAddr types.ProviderConsAddress) error

SlashValidator slashes validator with given provider Address

func (Keeper) StakingTokenSupply

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

StakingTokenSupply is the same as StakingTotalSupply in the StakingKeeper. Necessary to implement the interface of the staking keeper to interface with other modules.

func (Keeper) StopAndPrepareForConsumerRemoval

func (k Keeper) StopAndPrepareForConsumerRemoval(ctx sdk.Context, consumerId string) error

StopAndPrepareForConsumerRemoval sets the phase of the chain to stopped and prepares to get the state of the chain removed after unbonding period elapses

func (Keeper) TotalBondedTokens

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

TotalBondedTokens gets the amount of tokens of the consensus-active validators. The same as TotalBondedTokens in the StakingKeeper, but only counts bonded tokens of the first MaxProviderConsensusValidators bonded validators. This is used to implement the interface of the staking keeper to interface with modules that need to reference the consensus-active validators.

func (Keeper) UnbondingCanComplete

func (k Keeper) UnbondingCanComplete(ctx sdk.Context, id uint64) error

func (Keeper) UnbondingTime

func (k Keeper) UnbondingTime(ctx sdk.Context) (time.Duration, error)

func (Keeper) UpdateAllowlist

func (k Keeper) UpdateAllowlist(ctx sdk.Context, consumerId string, allowlist []string)

UpdateAllowlist populates the allowlist store for the consumer chain with this consumer id

func (Keeper) UpdateDenylist

func (k Keeper) UpdateDenylist(ctx sdk.Context, consumerId string, denylist []string)

UpdateDenylist populates the denylist store for the consumer chain with this consumer id

func (Keeper) UpdateMinimumPowerInTopN

func (k Keeper) UpdateMinimumPowerInTopN(ctx sdk.Context, consumerId string, oldTopN, newTopN uint32) error

UpdateMinimumPowerInTopN populates the minimum power in Top N for the consumer chain with this consumer id

func (Keeper) ValidateSlashPacket

func (k Keeper) ValidateSlashPacket(ctx sdk.Context, consumerId string,
	packet channeltypes.Packet, data ccv.SlashPacketData,
) error

ValidateSlashPacket validates a recv slash packet before it is handled or persisted in store. An error is returned if the packet is invalid, and an error ack should be relayed to the sender.

func (Keeper) ValidatorAddressCodec

func (k Keeper) ValidatorAddressCodec() addresscodec.Codec

ValidatorAddressCodec returns the app validator address codec.

func (Keeper) ValidatorConsensusKeyInUse

func (k Keeper) ValidatorConsensusKeyInUse(ctx sdk.Context, valAddr sdk.ValAddress) bool

ValidatorConsensusKeyInUse checks if the given consensus key is already used by validator in a consumer chain. Note that this method is called when a new validator is created in the x/staking module of cosmos-sdk. In case it panics, the TX aborts and thus, the validator is not created. See AfterValidatorCreated hook.

func (Keeper) VerifyConsumerChain

func (k Keeper) VerifyConsumerChain(ctx sdk.Context, channelID string, connectionHops []string) error

VerifyConsumerChain verifies that the chain trying to connect on the channel handshake is the expected consumer chain.

func (Keeper) VerifyDoubleVotingEvidence

func (k Keeper) VerifyDoubleVotingEvidence(
	evidence tmtypes.DuplicateVoteEvidence,
	chainId string,
	pubkey cryptotypes.PubKey,
) error

VerifyDoubleVotingEvidence verifies a double voting evidence for a given chain id and a validator public key

Jump to

Keyboard shortcuts

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