types

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 25 Imported by: 6

Documentation

Index

Constants

View Source
const (
	EventTypeTimeout      = "timeout"
	EventTypePacket       = "ccv_packet"
	EventTypeChannelClose = "channel_closed"

	AttributeKeyAckSuccess = "success"
	AttributeKeyAck        = "acknowledgement"
	AttributeKeyAckError   = "error"
)

CCV events

View Source
const (
	// ModuleName defines the CCV module name
	ModuleName = "CCV"

	// Version defines the current version the IBC CCV provider and consumer
	// module supports
	Version = "1"

	RouterKey = ModuleName
)
View Source
const TimeDelay = 4 * 7 * 24 * time.Hour

TimeDelay is 4 weeks to ensure channel doesn't close on timeout

Variables

View Source
var (
	ErrInvalidLengthCcv        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCcv          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupCcv = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (

	// ModuleCdc references the global x/ibc-transfer module codec. Note, the codec
	// should ONLY be used in certain instances of tests and for JSON encoding.
	//
	// The actual codec used for serialization should be provided to x/ibc transfer and
	// defined at the application level.
	ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())

	// AminoCdc is a amino codec created to support amino json compatible msgs.
	AminoCdc = codec.NewAminoCodec(amino)
)
View Source
var (
	ErrInvalidPacketData        = sdkerrors.Register(ModuleName, 2, "invalid CCV packet data")
	ErrInvalidPacketTimeout     = sdkerrors.Register(ModuleName, 3, "invalid packet timeout")
	ErrInvalidVersion           = sdkerrors.Register(ModuleName, 4, "invalid CCV version")
	ErrInvalidChannelFlow       = sdkerrors.Register(ModuleName, 5, "invalid message sent to channel end")
	ErrInvalidConsumerChain     = sdkerrors.Register(ModuleName, 6, "invalid consumer chain")
	ErrInvalidProviderChain     = sdkerrors.Register(ModuleName, 7, "invalid provider chain")
	ErrInvalidStatus            = sdkerrors.Register(ModuleName, 8, "invalid channel status")
	ErrInvalidGenesis           = sdkerrors.Register(ModuleName, 9, "invalid genesis state")
	ErrDuplicateChannel         = sdkerrors.Register(ModuleName, 10, "CCV channel already exists")
	ErrInvalidVSCMaturedId      = sdkerrors.Register(ModuleName, 11, "invalid vscId for VSC packet")
	ErrInvalidVSCMaturedTime    = sdkerrors.Register(ModuleName, 12, "invalid maturity time for VSC packet")
	ErrInvalidConsumerState     = sdkerrors.Register(ModuleName, 13, "provider chain has invalid state for consumer chain")
	ErrInvalidConsumerClient    = sdkerrors.Register(ModuleName, 14, "ccv channel is not built on correct client")
	ErrInvalidProposal          = sdkerrors.Register(ModuleName, 15, "invalid create consumer chain proposal")
	ErrInvalidHandshakeMetadata = sdkerrors.Register(ModuleName, 16, "invalid provider handshake metadata")
	ErrChannelNotFound          = sdkerrors.Register(ModuleName, 17, "channel not found")
	ErrClientNotFound           = sdkerrors.Register(ModuleName, 18, "client not found")
)

CCV sentinel errors

Functions

func GetTimeoutTimestamp

func GetTimeoutTimestamp(currentTime time.Time) time.Time

func RegisterInterfaces

func RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces register the ibc transfer module interfaces to protobuf Any.

func RegisterLegacyAminoCodec

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the necessary x/ibc transfer interfaces and concrete types on the provided LegacyAmino codec. These types are used for Amino JSON serialization.

func RegisterMsgServer

func RegisterMsgServer(s grpc1.Server, srv MsgServer)

func RegisterQueryServer

func RegisterQueryServer(s grpc1.Server, srv QueryServer)

Types

type AccountKeeper

type AccountKeeper interface {
	GetModuleAccount(ctx sdk.Context, name string) auth.ModuleAccountI
}

AccountKeeper defines the expected account keeper used for simulations

type BankKeeper

type BankKeeper interface {
	GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
	GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
}

BankKeeper defines the expected interface needed to retrieve account balances.

type ChannelKeeper

type ChannelKeeper interface {
	GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool)
	GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
	SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet ibcexported.PacketI) error
	WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
	ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error
}

ChannelKeeper defines the expected IBC channel keeper

type ClientKeeper

type ClientKeeper interface {
	CreateClient(ctx sdk.Context, clientState ibcexported.ClientState, consensusState ibcexported.ConsensusState) (string, error)
	GetClientState(ctx sdk.Context, clientID string) (ibcexported.ClientState, bool)
	GetLatestClientConsensusState(ctx sdk.Context, clientID string) (ibcexported.ConsensusState, bool)
	GetSelfConsensusState(ctx sdk.Context, height ibcexported.Height) (ibcexported.ConsensusState, error)
}

ClientKeeper defines the expected IBC client keeper

type ConnectionKeeper

type ConnectionKeeper interface {
	GetConnection(ctx sdk.Context, connectionID string) (conntypes.ConnectionEnd, bool)
}

ConnectionKeeper defines the expected IBC connection keeper

type ConsumerHooks

type ConsumerHooks interface {
	AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, _ sdk.ValAddress)
}

ConsumerHooks event hooks for newly bonded cross-chain validators

type IBCCoreKeeper

type IBCCoreKeeper interface {
	ChannelOpenInit(
		goCtx context.Context,
		msg *channeltypes.MsgChannelOpenInit,
	) (*channeltypes.MsgChannelOpenInitResponse, error)
}

IBCKeeper defines the expected interface needed for openning a channel

type IBCTransferKeeper

type IBCTransferKeeper interface {
	SendTransfer(
		ctx sdk.Context,
		sourcePort,
		sourceChannel string,
		token sdk.Coin,
		sender sdk.AccAddress,
		receiver string,
		timeoutHeight clienttypes.Height,
		timeoutTimestamp uint64,
	) error
}

IBCTransferKeeper defines the expected interface needed for distribution transfer of tokens from the consumer to the provider chain

type MsgClient

type MsgClient interface {
}

MsgClient is the client API for Msg service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewMsgClient

func NewMsgClient(cc grpc1.ClientConn) MsgClient

type MsgServer

type MsgServer interface {
}

MsgServer is the server API for Msg service.

type PortKeeper

type PortKeeper interface {
	BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability
}

PortKeeper defines the expected IBC port keeper

type QueryClient

type QueryClient interface {
}

QueryClient is the client API for Query service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewQueryClient

func NewQueryClient(cc grpc1.ClientConn) QueryClient

type QueryServer

type QueryServer interface {
}

QueryServer is the server API for Query service.

type SlashPacketData

type SlashPacketData struct {
	Validator types.Validator `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator" yaml:"validator"`
	// map to the infraction block height on the provider
	ValsetUpdateId uint64 `protobuf:"varint,2,opt,name=valset_update_id,json=valsetUpdateId,proto3" json:"valset_update_id,omitempty"`
	// tell if the slashing is for a downtime or a double-signing infraction
	Infraction types1.InfractionType `protobuf:"varint,3,opt,name=infraction,proto3,enum=cosmos.staking.v1beta1.InfractionType" json:"infraction,omitempty"`
}

This packet is sent from the consumer chain to the provider chain to request the slashing of a validator as a result of an infraction committed on the consumer chain.

func NewSlashPacketData

func NewSlashPacketData(validator abci.Validator, valUpdateId uint64, infractionType stakingtypes.InfractionType) SlashPacketData

func (*SlashPacketData) Descriptor

func (*SlashPacketData) Descriptor() ([]byte, []int)

func (SlashPacketData) GetBytes

func (vdt SlashPacketData) GetBytes() []byte

func (*SlashPacketData) GetInfraction

func (m *SlashPacketData) GetInfraction() types1.InfractionType

func (*SlashPacketData) GetValidator

func (m *SlashPacketData) GetValidator() types.Validator

func (*SlashPacketData) GetValsetUpdateId

func (m *SlashPacketData) GetValsetUpdateId() uint64

func (*SlashPacketData) Marshal

func (m *SlashPacketData) Marshal() (dAtA []byte, err error)

func (*SlashPacketData) MarshalTo

func (m *SlashPacketData) MarshalTo(dAtA []byte) (int, error)

func (*SlashPacketData) MarshalToSizedBuffer

func (m *SlashPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SlashPacketData) ProtoMessage

func (*SlashPacketData) ProtoMessage()

func (*SlashPacketData) Reset

func (m *SlashPacketData) Reset()

func (*SlashPacketData) Size

func (m *SlashPacketData) Size() (n int)

func (*SlashPacketData) String

func (m *SlashPacketData) String() string

func (*SlashPacketData) Unmarshal

func (m *SlashPacketData) Unmarshal(dAtA []byte) error

func (SlashPacketData) ValidateBasic

func (vdt SlashPacketData) ValidateBasic() error

func (*SlashPacketData) XXX_DiscardUnknown

func (m *SlashPacketData) XXX_DiscardUnknown()

func (*SlashPacketData) XXX_Marshal

func (m *SlashPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SlashPacketData) XXX_Merge

func (m *SlashPacketData) XXX_Merge(src proto.Message)

func (*SlashPacketData) XXX_Size

func (m *SlashPacketData) XXX_Size() int

func (*SlashPacketData) XXX_Unmarshal

func (m *SlashPacketData) XXX_Unmarshal(b []byte) error

type SlashingKeeper

type SlashingKeeper interface {
	JailUntil(sdk.Context, sdk.ConsAddress, time.Time) // called from provider keeper only
	GetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress) (info slashingtypes.ValidatorSigningInfo, found bool)
	DowntimeJailDuration(sdk.Context) time.Duration
	SlashFractionDowntime(sdk.Context) sdk.Dec
	SlashFractionDoubleSign(ctx sdk.Context) (res sdk.Dec)
	Tombstone(sdk.Context, sdk.ConsAddress)
	IsTombstoned(sdk.Context, sdk.ConsAddress) bool
}

SlashingKeeper defines the contract expected to perform ccv slashing

type StakingKeeper

type StakingKeeper interface {
	GetValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate
	UnbondingCanComplete(ctx sdk.Context, id uint64) error
	UnbondingTime(ctx sdk.Context) time.Duration
	GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool)
	// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
	Jail(sdk.Context, sdk.ConsAddress) // jail a validator
	Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, stakingtypes.InfractionType)
	GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool)
	IterateLastValidatorPowers(ctx sdk.Context, cb func(addr sdk.ValAddress, power int64) (stop bool))
	PowerReduction(ctx sdk.Context) sdk.Int
	PutUnbondingOnHold(ctx sdk.Context, id uint64) error
}

StakingKeeper defines the contract expected by provider-chain ccv module from a Staking Module that will keep track of the provider validator set. This version of the interchain-security protocol will mirror the provider chain's changes so we do not need a registry module between the staking module and CCV.

type UnbondingOp

type UnbondingOp struct {
	Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// consumer chains that are still unbonding
	UnbondingConsumerChains []string `` /* 132-byte string literal not displayed */
}

func (*UnbondingOp) Descriptor

func (*UnbondingOp) Descriptor() ([]byte, []int)

func (*UnbondingOp) GetId

func (m *UnbondingOp) GetId() uint64

func (*UnbondingOp) GetUnbondingConsumerChains

func (m *UnbondingOp) GetUnbondingConsumerChains() []string

func (*UnbondingOp) Marshal

func (m *UnbondingOp) Marshal() (dAtA []byte, err error)

func (*UnbondingOp) MarshalTo

func (m *UnbondingOp) MarshalTo(dAtA []byte) (int, error)

func (*UnbondingOp) MarshalToSizedBuffer

func (m *UnbondingOp) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UnbondingOp) ProtoMessage

func (*UnbondingOp) ProtoMessage()

func (*UnbondingOp) Reset

func (m *UnbondingOp) Reset()

func (*UnbondingOp) Size

func (m *UnbondingOp) Size() (n int)

func (*UnbondingOp) String

func (m *UnbondingOp) String() string

func (*UnbondingOp) Unmarshal

func (m *UnbondingOp) Unmarshal(dAtA []byte) error

func (*UnbondingOp) XXX_DiscardUnknown

func (m *UnbondingOp) XXX_DiscardUnknown()

func (*UnbondingOp) XXX_Marshal

func (m *UnbondingOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UnbondingOp) XXX_Merge

func (m *UnbondingOp) XXX_Merge(src proto.Message)

func (*UnbondingOp) XXX_Size

func (m *UnbondingOp) XXX_Size() int

func (*UnbondingOp) XXX_Unmarshal

func (m *UnbondingOp) XXX_Unmarshal(b []byte) error

type UnimplementedMsgServer

type UnimplementedMsgServer struct {
}

UnimplementedMsgServer can be embedded to have forward compatible implementations.

type UnimplementedQueryServer

type UnimplementedQueryServer struct {
}

UnimplementedQueryServer can be embedded to have forward compatible implementations.

type VSCMaturedPacketData

type VSCMaturedPacketData struct {
	// the id of the VSC packet that reached maturity
	ValsetUpdateId uint64 `protobuf:"varint,1,opt,name=valset_update_id,json=valsetUpdateId,proto3" json:"valset_update_id,omitempty"`
}

This packet is sent from the consumer chain to the provider chain to notify that a VSC packet reached maturity on the consumer chain.

func NewVSCMaturedPacketData

func NewVSCMaturedPacketData(valUpdateID uint64) VSCMaturedPacketData

func (*VSCMaturedPacketData) Descriptor

func (*VSCMaturedPacketData) Descriptor() ([]byte, []int)

func (VSCMaturedPacketData) GetBytes

func (mat VSCMaturedPacketData) GetBytes() []byte

func (*VSCMaturedPacketData) GetValsetUpdateId

func (m *VSCMaturedPacketData) GetValsetUpdateId() uint64

func (*VSCMaturedPacketData) Marshal

func (m *VSCMaturedPacketData) Marshal() (dAtA []byte, err error)

func (*VSCMaturedPacketData) MarshalTo

func (m *VSCMaturedPacketData) MarshalTo(dAtA []byte) (int, error)

func (*VSCMaturedPacketData) MarshalToSizedBuffer

func (m *VSCMaturedPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*VSCMaturedPacketData) ProtoMessage

func (*VSCMaturedPacketData) ProtoMessage()

func (*VSCMaturedPacketData) Reset

func (m *VSCMaturedPacketData) Reset()

func (*VSCMaturedPacketData) Size

func (m *VSCMaturedPacketData) Size() (n int)

func (*VSCMaturedPacketData) String

func (m *VSCMaturedPacketData) String() string

func (*VSCMaturedPacketData) Unmarshal

func (m *VSCMaturedPacketData) Unmarshal(dAtA []byte) error

func (VSCMaturedPacketData) ValidateBasic

func (mat VSCMaturedPacketData) ValidateBasic() error

ValidateBasic is used for validating the VSCMatured packet data.

func (*VSCMaturedPacketData) XXX_DiscardUnknown

func (m *VSCMaturedPacketData) XXX_DiscardUnknown()

func (*VSCMaturedPacketData) XXX_Marshal

func (m *VSCMaturedPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*VSCMaturedPacketData) XXX_Merge

func (m *VSCMaturedPacketData) XXX_Merge(src proto.Message)

func (*VSCMaturedPacketData) XXX_Size

func (m *VSCMaturedPacketData) XXX_Size() int

func (*VSCMaturedPacketData) XXX_Unmarshal

func (m *VSCMaturedPacketData) XXX_Unmarshal(b []byte) error

type ValidatorSetChangePacketData

type ValidatorSetChangePacketData struct {
	ValidatorUpdates []types.ValidatorUpdate `protobuf:"bytes,1,rep,name=validator_updates,json=validatorUpdates,proto3" json:"validator_updates" yaml:"validator_updates"`
	ValsetUpdateId   uint64                  `protobuf:"varint,2,opt,name=valset_update_id,json=valsetUpdateId,proto3" json:"valset_update_id,omitempty"`
	// consensus address of consumer chain validators
	// successfully slashed on the provider chain
	SlashAcks []string `protobuf:"bytes,3,rep,name=slash_acks,json=slashAcks,proto3" json:"slash_acks,omitempty"`
}

This packet is sent from provider chain to consumer chain if the validator set for consumer chain changes (due to new bonding/unbonding messages or slashing events) A VSCMatured packet from consumer chain will be sent asynchronously once unbonding period is over, and this will function as `UnbondingOver` message for this packet.

func NewValidatorSetChangePacketData

func NewValidatorSetChangePacketData(valUpdates []abci.ValidatorUpdate, valUpdateID uint64, SlashAcks []string) ValidatorSetChangePacketData

func (*ValidatorSetChangePacketData) Descriptor

func (*ValidatorSetChangePacketData) Descriptor() ([]byte, []int)

func (ValidatorSetChangePacketData) GetBytes

func (vsc ValidatorSetChangePacketData) GetBytes() []byte

func (*ValidatorSetChangePacketData) GetSlashAcks

func (m *ValidatorSetChangePacketData) GetSlashAcks() []string

func (*ValidatorSetChangePacketData) GetValidatorUpdates

func (m *ValidatorSetChangePacketData) GetValidatorUpdates() []types.ValidatorUpdate

func (*ValidatorSetChangePacketData) GetValsetUpdateId

func (m *ValidatorSetChangePacketData) GetValsetUpdateId() uint64

func (*ValidatorSetChangePacketData) Marshal

func (m *ValidatorSetChangePacketData) Marshal() (dAtA []byte, err error)

func (*ValidatorSetChangePacketData) MarshalTo

func (m *ValidatorSetChangePacketData) MarshalTo(dAtA []byte) (int, error)

func (*ValidatorSetChangePacketData) MarshalToSizedBuffer

func (m *ValidatorSetChangePacketData) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ValidatorSetChangePacketData) ProtoMessage

func (*ValidatorSetChangePacketData) ProtoMessage()

func (*ValidatorSetChangePacketData) Reset

func (m *ValidatorSetChangePacketData) Reset()

func (*ValidatorSetChangePacketData) Size

func (m *ValidatorSetChangePacketData) Size() (n int)

func (*ValidatorSetChangePacketData) String

func (*ValidatorSetChangePacketData) Unmarshal

func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error

func (ValidatorSetChangePacketData) ValidateBasic

func (vsc ValidatorSetChangePacketData) ValidateBasic() error

ValidateBasic is used for validating the CCV packet data.

func (*ValidatorSetChangePacketData) XXX_DiscardUnknown

func (m *ValidatorSetChangePacketData) XXX_DiscardUnknown()

func (*ValidatorSetChangePacketData) XXX_Marshal

func (m *ValidatorSetChangePacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ValidatorSetChangePacketData) XXX_Merge

func (m *ValidatorSetChangePacketData) XXX_Merge(src proto.Message)

func (*ValidatorSetChangePacketData) XXX_Size

func (m *ValidatorSetChangePacketData) XXX_Size() int

func (*ValidatorSetChangePacketData) XXX_Unmarshal

func (m *ValidatorSetChangePacketData) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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