keeper

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 27 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

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

Hooks wrapper struct for ConsumerKeeper

type Keeper

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

Keeper defines the Cross-Chain Validation Consumer Keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
	scopedKeeper ccv.ScopedKeeper,
	channelKeeper ccv.ChannelKeeper, portKeeper ccv.PortKeeper,
	connectionKeeper ccv.ConnectionKeeper, clientKeeper ccv.ClientKeeper,
	slashingKeeper ccv.SlashingKeeper, bankKeeper ccv.BankKeeper, accountKeeper ccv.AccountKeeper,
	ibcTransferKeeper ccv.IBCTransferKeeper, ibcCoreKeeper ccv.IBCCoreKeeper,
	feeCollectorName string,
) Keeper

NewKeeper creates a new Consumer Keeper instance NOTE: the feeCollectorName is in reference to the consumer-chain fee collector (and not the provider chain)

func (Keeper) AfterValidatorBonded

func (k Keeper) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, _ sdk.ValAddress)

func (Keeper) AppendPendingSlashRequests

func (k Keeper) AppendPendingSlashRequests(ctx sdk.Context, req types.SlashRequest)

AppendPendingSlashRequests appends the given slash request to the pending slash requests in store

func (Keeper) ApplyCCValidatorChanges

func (k Keeper) ApplyCCValidatorChanges(ctx sdk.Context, changes []abci.ValidatorUpdate) []abci.ValidatorUpdate

ApplyCCValidatorChanges applies the given changes to the cross-chain validators states and returns updates to forward to tendermint.

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

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

ChanCloseInit defines a wrapper function for the channel Keeper's function Following ICS 004: https://github.com/cosmos/ibc/tree/main/spec/core/ics-004-channel-and-packet-semantics#closing-handshake

func (Keeper) ClaimCapability

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

ClaimCapability claims a capability that the IBC module passes to it

func (Keeper) Delegation

Delegation - unimplemented on CCV keeper

func (Keeper) DeleteCCValidator

func (k Keeper) DeleteCCValidator(ctx sdk.Context, addr []byte)

DeleteCCValidator deletes a cross-chain validator for a given address

func (Keeper) DeleteHeightValsetUpdateID

func (k Keeper) DeleteHeightValsetUpdateID(ctx sdk.Context, height uint64)

DeleteHeightValsetUpdateID deletes the valset update id for a given block height

func (Keeper) DeleteHistoricalInfo

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

DeleteHistoricalInfo deletes the historical info at a given height

func (Keeper) DeleteOutstandingDowntime added in v0.2.0

func (k Keeper) DeleteOutstandingDowntime(ctx sdk.Context, consAddress string)

DeleteOutstandingDowntime deletes the outstanding downtime flag for the given validator consensus address

func (Keeper) DeletePacketMaturityTime

func (k Keeper) DeletePacketMaturityTime(ctx sdk.Context, vscId uint64)

DeletePacketMaturityTime deletes the packet maturity time for a given received VSC packet id

func (Keeper) DeletePendingChanges

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

DeletePendingChanges deletes the pending changes after they've been flushed to ABCI

func (Keeper) DeletePendingSlashRequests added in v0.2.0

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

ClearPendingSlashRequests clears the pending slash requests in store

func (Keeper) DeleteProviderChannel

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

DeleteProviderChannel deletes the channelID for the channel to the provider.

func (Keeper) DistributeToProviderValidatorSet

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

Simple model, send tokens to the fee pool of the provider validator set reference: cosmos/ibc-go/v3/modules/apps/transfer/keeper/msg_server.go

func (Keeper) ExportGenesis

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

ExportGenesis exports the CCV consumer state. If the channel has already been established, then we export provider chain. Otherwise, this is still considered a new chain and we export latest client state.

func (Keeper) GetAllCCValidator

func (k Keeper) GetAllCCValidator(ctx sdk.Context) (validators []types.CrossChainValidator)

GetAllCCValidator returns all cross-chain validators

func (Keeper) GetBlocksPerDistributionTransmission

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

func (Keeper) GetCCVTimeoutPeriod added in v0.2.0

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

GetCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets

func (Keeper) GetCCValidator

func (k Keeper) GetCCValidator(ctx sdk.Context, addr []byte) (validator types.CrossChainValidator, found bool)

GetCCValidator returns a cross-chain validator for a given address

func (Keeper) GetConnectionHops

func (k Keeper) GetConnectionHops(ctx sdk.Context, srcPort, srcChan string) ([]string, error)

func (Keeper) GetConsumerRedistributionFrac added in v0.2.0

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

GetConsumerRedistributionFrac returns the fraction of tokens allocated to the consumer redistribution address during distribution events. The fraction is a string representing a decimal number. For example "0.75" would represent 75%.

func (Keeper) GetDistributionTransmissionChannel

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

func (Keeper) GetEnabled

func (k Keeper) GetEnabled(ctx sdk.Context) bool

GetEnabled returns the enabled flag for the consumer module

func (Keeper) GetEstimatedNextFeeDistribution added in v0.2.0

func (k Keeper) GetEstimatedNextFeeDistribution(ctx sdk.Context) (types.NextFeeDistributionEstimate, error)

GetEstimatedNextFeeDistribution returns data about next fee distribution. Data represents an estimation of accumulated fees at the current block height.

func (Keeper) GetHeightValsetUpdateID

func (k Keeper) GetHeightValsetUpdateID(ctx sdk.Context, height uint64) uint64

GetHeightValsetUpdateID gets the valset update id recorded for a given block height

func (Keeper) GetHistoricalEntries added in v0.2.0

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

GetHistoricalEntries returns the number of historical info entries to persist in store

func (Keeper) GetHistoricalInfo

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

GetHistoricalInfo gets the historical info at a given height

func (Keeper) GetLastTransmissionBlockHeight

func (k Keeper) GetLastTransmissionBlockHeight(ctx sdk.Context) (
	*types.LastTransmissionBlockHeight, error)

func (Keeper) GetPacketMaturityTime

func (k Keeper) GetPacketMaturityTime(ctx sdk.Context, vscId uint64) uint64

GetPacketMaturityTime gets the maturity time for a given received VSC packet id

func (Keeper) GetParams

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

GetParams returns the params for the consumer ccv module

func (Keeper) GetPendingChanges

func (k Keeper) GetPendingChanges(ctx sdk.Context) (*ccv.ValidatorSetChangePacketData, bool)

GetPendingChanges gets the pending changes that haven't been flushed over ABCI

func (Keeper) GetPendingSlashRequests

func (k Keeper) GetPendingSlashRequests(ctx sdk.Context) types.SlashRequests

GetPendingSlashRequest returns the pending slash requests in store

func (Keeper) GetPort

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

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

func (Keeper) GetProviderChannel

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

GetProviderChannel gets the channelID for the channel to the provider.

func (Keeper) GetProviderClientID added in v0.1.4

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

GetProviderClientID gets the clientID for the client to the provider.

func (Keeper) GetProviderFeePoolAddrStr

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

func (Keeper) GetTransferTimeoutPeriod added in v0.2.0

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

GetTransferTimeoutPeriod returns the timeout period for sent transfer related ibc packets

func (Keeper) GetUnbondingPeriod added in v0.2.0

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

func (Keeper) GetValidatorUpdates added in v0.2.0

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

ValidatorUpdates gets all cross-chain validators converted to the ABCI validator update type

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Return the wrapper struct

func (Keeper) InitGenesis

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

InitGenesis initializes the CCV consumer state and binds to PortID.

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

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

IsChannelClosed returns a boolean whether a given channel is in the CLOSED state

func (Keeper) IsValidatorJailed

func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool

IsJailed returns the outstanding slashing flag for the given validator adddress

func (Keeper) IterateHeightToValsetUpdateID added in v0.2.0

func (k Keeper) IterateHeightToValsetUpdateID(ctx sdk.Context, cb func(height, vscID uint64) bool)

IterateHeightToValsetUpdateID iterates over the block height to valset update ID mapping in store

func (Keeper) IterateOutstandingDowntime added in v0.2.0

func (k Keeper) IterateOutstandingDowntime(ctx sdk.Context, cb func(address string) bool)

IterateOutstandingDowntime iterates over the validator addresses of outstanding downtime flags

func (Keeper) IteratePacketMaturityTime

func (k Keeper) IteratePacketMaturityTime(ctx sdk.Context, cb func(vscId, timeNs uint64) bool)

IteratePacketMaturityTime iterates through the VSC packet maturity times set in the store

func (Keeper) IterateValidators

func (k Keeper) IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))

IterateValidators - unimplemented on CCV keeper but perform a no-op in order to pass the slashing module InitGenesis. It is allowed since the condition verifying validator public keys in HandleValidatorSignature (x/slashing/keeper/infractions.go) is removed therefore it isn't required to store any validator public keys to the slashing states during genesis.

func (Keeper) Jail

func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress)

Jail - unimplemented on CCV keeper

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MaxValidators

func (k Keeper) MaxValidators(sdk.Context) uint32

MaxValidators - unimplemented on CCV keeper

func (Keeper) OnAcknowledgementPacket

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

OnAcknowledgementPacket executes application logic for acknowledgments of sent VSCMatured and Slash packets in conjunction with the ibc module's execution of "acknowledgePacket", according to https://github.com/cosmos/ibc/tree/main/spec/core/ics-004-channel-and-packet-semantics#processing-acknowledgements

func (Keeper) OnRecvVSCPacket

func (k Keeper) OnRecvVSCPacket(ctx sdk.Context, packet channeltypes.Packet, newChanges ccv.ValidatorSetChangePacketData) exported.Acknowledgement

OnRecvVSCPacket sets the pending validator set changes that will be flushed to ABCI on Endblock and set the maturity time for the packet. Once the maturity time elapses, a VSCMatured packet is sent back to the provider chain.

Note: CCV uses an ordered IBC channel, meaning VSC packet changes will be accumulated (and later processed by ApplyCCValidatorChanges) s.t. more recent val power changes overwrite older ones.

func (Keeper) OnTimeoutPacket

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

func (Keeper) OutstandingDowntime

func (k Keeper) OutstandingDowntime(ctx sdk.Context, address sdk.ConsAddress) bool

OutstandingDowntime returns the outstanding downtime flag for a given validator

func (Keeper) SendPendingSlashRequests

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

SendPendingSlashRequests iterates over the stored pending slash requests in reverse order and sends the embedded slash packets to the provider chain

func (Keeper) SendSlashPacket

func (k Keeper) SendSlashPacket(ctx sdk.Context, validator abci.Validator, valsetUpdateID uint64, infraction stakingtypes.InfractionType)

SendSlashPacket sends a slash packet containing the given validator data and slashing info

func (Keeper) SendVSCMaturedPackets added in v0.1.4

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

SendVSCMaturedPackets will iterate over the persisted maturity times of previously received VSC packets in order, and write acknowledgements for all matured VSC packets.

Note: Per spec, a VSC reaching maturity on a consumer chain means that all the unbonding operations that resulted in validator updates included in that VSC have matured on the consumer chain.

func (Keeper) SetBlocksPerDistributionTransmission

func (k Keeper) SetBlocksPerDistributionTransmission(ctx sdk.Context, bpdt int64)

func (Keeper) SetCCValidator

func (k Keeper) SetCCValidator(ctx sdk.Context, v types.CrossChainValidator)

SetCCValidator sets a cross-chain validator under its validator address

func (Keeper) SetDistributionTransmissionChannel

func (k Keeper) SetDistributionTransmissionChannel(ctx sdk.Context, channel string)

func (Keeper) SetHeightValsetUpdateID

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

SetHeightValsetUpdateID sets the valset update id for a given block height

func (Keeper) SetHistoricalInfo

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

SetHistoricalInfo sets the historical info at a given height

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(sh ccv.ConsumerHooks) *Keeper

func (Keeper) SetLastTransmissionBlockHeight

func (k Keeper) SetLastTransmissionBlockHeight(ctx sdk.Context,
	ltbh types.LastTransmissionBlockHeight) error

func (Keeper) SetOutstandingDowntime

func (k Keeper) SetOutstandingDowntime(ctx sdk.Context, address sdk.ConsAddress)

SetOutstandingDowntime sets the outstanding downtime flag for a given validator

func (Keeper) SetPacketMaturityTime

func (k Keeper) SetPacketMaturityTime(ctx sdk.Context, vscId, maturityTime uint64)

SetPacketMaturityTime sets the maturity time for a given received VSC packet id

func (Keeper) SetParams

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

SetParams sets the paramset for the consumer module

func (Keeper) SetPendingChanges

func (k Keeper) SetPendingChanges(ctx sdk.Context, updates ccv.ValidatorSetChangePacketData) error

SetPendingChanges sets the pending validator set change packet that haven't been flushed to ABCI

func (Keeper) SetPendingSlashRequests

func (k Keeper) SetPendingSlashRequests(ctx sdk.Context, requests types.SlashRequests)

SetPendingSlashRequests sets the pending slash requests in store

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

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

SetProviderChannel sets the channelID for the channel to the provider.

func (Keeper) SetProviderClientID added in v0.1.4

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

SetProviderClientID sets the clientID for the client to the provider. Set in InitGenesis

func (Keeper) SetProviderFeePoolAddrStr

func (k Keeper) SetProviderFeePoolAddrStr(ctx sdk.Context, addr string)

func (Keeper) SetUnbondingPeriod added in v0.2.0

func (k Keeper) SetUnbondingPeriod(ctx sdk.Context, period time.Duration)

Only used to set an unbonding period in diff tests

func (Keeper) Slash

func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, _ sdk.Dec, infraction stakingtypes.InfractionType)

Slash sends a slashing request to the provider chain

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

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

UnbondingTime returns consumer unbonding period, satisfying the staking keeper interface

func (Keeper) Unjail

func (k Keeper) Unjail(sdk.Context, sdk.ConsAddress)

Unjail - unimplemented on CCV keeper

func (Keeper) Validator

func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI

Validator - unimplemented on CCV keeper

func (Keeper) ValidatorByConsAddr

func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI

ValidatorByConsAddr returns an empty validator

func (Keeper) VerifyProviderChain

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

VerifyProviderChain verifies that the chain trying to connect on the channel handshake is the expected provider chain.

Jump to

Keyboard shortcuts

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