keeper

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 29 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 sdk.StoreKey, paramSpace paramtypes.Subspace, scopedKeeper capabilitykeeper.ScopedKeeper,
	channelKeeper ccv.ChannelKeeper, portKeeper ccv.PortKeeper,
	connectionKeeper ccv.ConnectionKeeper, clientKeeper ccv.ClientKeeper,
	stakingKeeper ccv.StakingKeeper, slashingKeeper ccv.SlashingKeeper,
	accountKeeper ccv.AccountKeeper, feeCollectorName string,
) Keeper

NewKeeper creates a new provider Keeper instance

func (Keeper) AppendMaturedUnbondingOps

func (k Keeper) AppendMaturedUnbondingOps(ctx sdk.Context, ids []uint64) error

AppendMaturedUnbondingOps adds a list of ids to the list of matured unbonding operation ids

func (Keeper) AppendPendingVSC

func (k Keeper) AppendPendingVSC(ctx sdk.Context, chainID string, packet ccv.ValidatorSetChangePacketData)

AppendPendingVSC adds the given ValidatorSetChange packet to the list of pending ValidatorSetChange packets stored under chain ID

func (Keeper) AppendSlashAck

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

AppendSlashAck appends the given slash ack to the given chain ID slash acks in store

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) BindPort

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

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

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) CloseChannel

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

CloseChannel closes the channel for the given channel ID on the condition that the channel exists and isn't already in the CLOSED state

func (Keeper) CompleteMaturedUnbondingOps

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

CompleteMaturedUnbondingOps attempts to complete all matured unbonding operations

func (Keeper) CreateConsumerChainProposal

func (k Keeper) CreateConsumerChainProposal(ctx sdk.Context, p *types.CreateConsumerChainProposal) error

CreateConsumerChainProposal will receive the consumer chain's client state from the proposal. If the spawn time has already passed, then set the consumer chain. Otherwise store the client as a pending client, and set once spawn time has passed.

func (Keeper) CreateConsumerClient

func (k Keeper) CreateConsumerClient(ctx sdk.Context, chainID string, initialHeight clienttypes.Height, lockUbdOnTimeout bool) 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) DeleteChainToChannel

func (k Keeper) DeleteChainToChannel(ctx sdk.Context, chainID string)

DeleteChainToChannel deletes the CCV channel ID for the given consumer chain ID

func (Keeper) DeleteChannelToChain

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

DeleteChannelToChain deletes the consumer chain ID for a given CCV channe lID

func (Keeper) DeleteConsumerClientId

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

DeleteConsumerClientId removes from the store the clientID for the given chainID.

func (Keeper) DeleteInitChainHeight

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

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

func (Keeper) DeleteLockUnbondingOnTimeout

func (k Keeper) DeleteLockUnbondingOnTimeout(ctx sdk.Context, chainID string)

DeleteLockUnbondingOnTimeout deletes the unbonding operation lock in case of a CCV channel timeouts for the given consumer chain ID

func (Keeper) DeletePendingCreateProposal

func (k Keeper) DeletePendingCreateProposal(ctx sdk.Context, proposals ...types.CreateConsumerChainProposal)

DeletePendingCreateProposal deletes the given create consumer proposals

func (Keeper) DeletePendingStopProposals

func (k Keeper) DeletePendingStopProposals(ctx sdk.Context, proposals ...types.StopConsumerChainProposal)

DeletePendingStopProposals deletes the given stop proposals

func (Keeper) DeleteUnbondingOp

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

func (Keeper) DeleteUnbondingOpIndex

func (k Keeper) DeleteUnbondingOpIndex(ctx sdk.Context, chainID string, valsetUpdateID uint64)

This index allows retreiving UnbondingDelegationEntries by chainID and valsetUpdateID

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) EmptyMaturedUnbondingOps

func (k Keeper) EmptyMaturedUnbondingOps(ctx sdk.Context) ([]uint64, error)

EmptyMaturedUnbondingOps empties and returns list of matured unbonding operation ids (if it exists)

func (Keeper) EmptyPendingVSC

func (k Keeper) EmptyPendingVSC(ctx sdk.Context, chainID string) (packets []ccv.ValidatorSetChangePacketData)

EmptyPendingVSC empties and returns the list of pending ValidatorSetChange packets for chain ID (if it exists)

func (Keeper) EmptySlashAcks

func (k Keeper) EmptySlashAcks(ctx sdk.Context, chainID string) (acks []string)

EmptySlashAcks empties and returns the slash acks for a given chain ID

func (Keeper) ExportGenesis

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

func (Keeper) GetChainToChannel

func (k Keeper) GetChainToChannel(ctx sdk.Context, chainID string) (string, bool)

GetChainToChannel gets the CCV channelID for the given consumer chainID

func (Keeper) GetChannelToChain

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

GetChannelToChain gets the consumer chainID for a given CCV channelID

func (Keeper) GetConsumerClientId

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

GetConsumerClientId returns the client ID for the given chain ID.

func (Keeper) GetConsumerGenesis

func (k Keeper) GetConsumerGenesis(ctx sdk.Context, chainID string) (consumertypes.GenesisState, bool)

func (Keeper) GetFeeCollectorAddressStr

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

func (Keeper) GetInitChainHeight

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

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

func (Keeper) GetLockUnbondingOnTimeout

func (k Keeper) GetLockUnbondingOnTimeout(ctx sdk.Context, chainID string) bool

GetLockUnbondingOnTimeout returns the mapping from the given consumer chain ID to a boolean value indicating whether the unbonding operation funds should be locked on CCV channel timeout

func (Keeper) GetMaturedUnbondingOps

func (k Keeper) GetMaturedUnbondingOps(ctx sdk.Context) (ids []uint64, err error)

GetMaturedUnbondingOps returns the list of matured unbonding operation ids

func (Keeper) GetParams

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

GetParams returns the paramset for the provider module

func (Keeper) GetPendingCreateProposal

func (k Keeper) GetPendingCreateProposal(ctx sdk.Context, timestamp time.Time, chainID string) types.CreateConsumerChainProposal

GetPendingCreateProposal retrieves a pending proposal to create a consumer chain client (by spawn time and chain id)

func (Keeper) GetPendingStopProposal

func (k Keeper) GetPendingStopProposal(ctx sdk.Context, chainID string, timestamp time.Time) bool

GetPendingStopProposal returns a boolean if a pending stop proposal exists for the given consumer chain ID and the timestamp

func (Keeper) GetPendingVSCs

func (k Keeper) GetPendingVSCs(ctx sdk.Context, chainID string) (packets []ccv.ValidatorSetChangePacketData, found bool)

GetPendingVSCs returns the list of pending ValidatorSetChange packets stored under chain ID

func (Keeper) GetPort

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

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

func (Keeper) GetSlashAcks

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

GetSlashAcks returns the slash acks stored under the given chain ID

func (Keeper) GetTemplateClient

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

GetTemplateClient returns the template client for provider proposals

func (Keeper) GetUnbondingOp

func (k Keeper) GetUnbondingOp(ctx sdk.Context, id uint64) (ccv.UnbondingOp, bool)

Get UnbondingOp by unique ID

func (Keeper) GetUnbondingOpIndex

func (k Keeper) GetUnbondingOpIndex(ctx sdk.Context, chainID string, valsetUpdateID uint64) ([]uint64, bool)

This index allows retrieving UnbondingDelegationEntries by chainID and valsetUpdateID

func (Keeper) GetUnbondingOpsFromIndex

func (k Keeper) GetUnbondingOpsFromIndex(ctx sdk.Context, chainID string, valsetUpdateID uint64) (entries []ccv.UnbondingOp, found bool)

Retrieve UnbondingDelegationEntries by chainID and valsetUpdateID

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

GetValsetUpdateBlockHeight gets the block height for a given valset update id

func (Keeper) HandleSlashPacket

func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.SlashPacketData) (success bool, err error)

HandleSlashPacket slash and jail a misbehaving validator according the infraction type

func (*Keeper) Hooks

func (k *Keeper) Hooks() StakingHooks

Return the wrapper struct

func (Keeper) IncrementValidatorSetUpdateId

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

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState)

func (Keeper) IsBound

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

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

func (Keeper) IterateChannelToChain

func (k Keeper) IterateChannelToChain(ctx sdk.Context, cb func(ctx sdk.Context, channelID, chainID string) (stop bool))

IterateChannelToChain iterates over the channel to chain mappings and calls the provided callback until the iteration ends or the callback returns stop=true

func (Keeper) IterateConsumerChains

func (k Keeper) IterateConsumerChains(ctx sdk.Context, cb func(ctx sdk.Context, chainID string) (stop bool))

IterateConsumerChains iterates over all of the consumer chains that the provider module controls. It calls the provided callback function which takes in a chainID and returns a stop boolean which will stop the iteration.

func (Keeper) IterateOverUnbondingOpIndex

func (k Keeper) IterateOverUnbondingOpIndex(ctx sdk.Context, chainID string, cb func(vscID uint64, ubdIndex []uint64) bool)

IterateOverUnbondingOpIndex iterates over the unbonding indexes for a given chain id.

func (Keeper) IteratePendingCreateProposal

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

IteratePendingCreateProposal iterates over the pending proposals to create consumer chain clients in order and creates the consumer client if the spawn time has passed, otherwise it will break out of loop and return.

func (Keeper) IteratePendingStopProposal

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

IteratePendingStopProposal iterates over the pending stop proposals in order and stop the chain if the stop time has passed, otherwise it will break out of loop and return.

func (Keeper) IterateSlashAcks

func (k Keeper) IterateSlashAcks(ctx sdk.Context, cb func(chainID string, acks []string) bool)

IterateSlashAcks iterates through the slash acks set in the store

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MakeConsumerGenesis

func (k Keeper) MakeConsumerGenesis(ctx sdk.Context) (gen consumertypes.GenesisState, err error)

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) exported.Acknowledgement

OnRecvSlashPacket slashes and jails the given validator in the packet data

func (Keeper) OnRecvVSCMaturedPacket

func (k Keeper) OnRecvVSCMaturedPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	data ccv.VSCMaturedPacketData,
) exported.Acknowledgement

OnRecvVSCMaturedPacket handles a VSCMatured packet

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) PendingCreateProposalIterator

func (k Keeper) PendingCreateProposalIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) PendingStopProposalIterator

func (k Keeper) PendingStopProposalIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) SendPendingVSCPackets

func (k Keeper) SendPendingVSCPackets(ctx sdk.Context, chainID, channelID string)

Sends all pending ValidatorSetChangePackets to the specified chain

func (Keeper) SendValidatorUpdates

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

SendValidatorUpdates sends latest validator updates to every registered consumer chain

func (Keeper) SetChainToChannel

func (k Keeper) SetChainToChannel(ctx sdk.Context, chainID, channelID string)

SetChainToChannel sets the mapping from a consumer chainID to the CCV channel ID for that consumer chain.

func (Keeper) SetChannelToChain

func (k Keeper) SetChannelToChain(ctx sdk.Context, channelID, chainID string)

SetChannelToChain sets the mapping from the CCV channel ID to the consumer chainID.

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.

func (Keeper) SetConsumerClientId

func (k Keeper) SetConsumerClientId(ctx sdk.Context, chainID, clientID string)

SetConsumerClientId sets the client ID for the given chain ID

func (Keeper) SetConsumerGenesis

func (k Keeper) SetConsumerGenesis(ctx sdk.Context, chainID string, gen consumertypes.GenesisState) error

func (Keeper) SetInitChainHeight

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

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

func (Keeper) SetLockUnbondingOnTimeout

func (k Keeper) SetLockUnbondingOnTimeout(ctx sdk.Context, chainID string)

SetLockUnbondingOnTimeout locks the unbonding operation funds in case of a CCV channel timeouts for the given consumer chain ID

func (Keeper) SetParams

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

SetParams sets the paramset for the provider module

func (Keeper) SetPendingCreateProposal

func (k Keeper) SetPendingCreateProposal(ctx sdk.Context, clientInfo *types.CreateConsumerChainProposal) error

SetPendingCreateProposal stores a pending proposal to create a consumer chain client

func (Keeper) SetPendingStopProposal

func (k Keeper) SetPendingStopProposal(ctx sdk.Context, chainID string, timestamp time.Time)

SetPendingStopProposal sets the consumer chain ID for the given timestamp

func (Keeper) SetPort

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

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

func (Keeper) SetSlashAcks

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

SetSlashAcks sets the slash acks under the given chain ID

func (Keeper) SetUnbondingOp

func (k Keeper) SetUnbondingOp(ctx sdk.Context, unbondingOp ccv.UnbondingOp) error

Save UnbondingOp by unique ID

func (Keeper) SetUnbondingOpIndex

func (k Keeper) SetUnbondingOpIndex(ctx sdk.Context, chainID string, valsetUpdateID uint64, IDs []uint64)

This index allows retreiving UnbondingDelegationEntries by chainID and valsetUpdateID

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) StopConsumerChain

func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, lockUbd, closeChan bool) (err error)

StopConsumerChain cleans up the states for the given consumer chain ID and, if the given lockUbd is false, it completes the outstanding unbonding operations lock by the consumer chain.

func (Keeper) StopConsumerChainProposal

func (k Keeper) StopConsumerChainProposal(ctx sdk.Context, p *types.StopConsumerChainProposal) error

StopConsumerChainProposal stops a consumer chain and released the outstanding unbonding operations. If the stop time hasn't already passed, it stores the proposal as a pending proposal.

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.

type StakingHooks

type StakingHooks struct {
	stakingtypes.StakingHooksTemplate
	// contains filtered or unexported fields
}

func (StakingHooks) AfterUnbondingInitiated

func (h StakingHooks) AfterUnbondingInitiated(ctx sdk.Context, ID uint64)

This stores a record of each unbonding op from staking, allowing us to track which consumer chains have unbonded

Jump to

Keyboard shortcuts

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