keeper

package
v1.6.67 Latest Latest
Warning

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

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

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 IBC channel keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryMarshaler, key sdk.StoreKey,
	clientKeeper types.ClientKeeper, connectionKeeper types.ConnectionKeeper,
	portKeeper types.PortKeeper,
	scopedKeeper capabilitykeeper.ScopedKeeper,
) Keeper

NewKeeper creates a new IBC channel Keeper instance

func (Keeper) AcknowledgePacket

func (k Keeper) AcknowledgePacket(
	ctx sdk.Context,
	chanCap *capabilitytypes.Capability,
	packet exported.PacketI,
	acknowledgement []byte,
	proof []byte,
	proofHeight exported.Height,
) error

AcknowledgePacket is called by a module to process the acknowledgement of a packet previously sent by the calling module on a channel to a counterparty module on the counterparty chain. Its intended usage is within the ante handler. AcknowledgePacket will clean up the packet commitment, which is no longer necessary since the packet has been received and acted upon. It will also increment NextSequenceAck in case of ORDERED channels.

func (Keeper) ChanOpenAck

func (k Keeper) ChanOpenAck(
	ctx sdk.Context,
	portID,
	channelID string,
	chanCap *capabilitytypes.Capability,
	counterpartyVersion,
	counterpartyChannelID string,
	proofTry []byte,
	proofHeight exported.Height,
) error

ChanOpenAck is called by the handshake-originating module to acknowledge the acceptance of the initial request by the counterparty module on the other chain.

func (Keeper) ChanOpenConfirm

func (k Keeper) ChanOpenConfirm(
	ctx sdk.Context,
	portID,
	channelID string,
	chanCap *capabilitytypes.Capability,
	proofAck []byte,
	proofHeight exported.Height,
) error

ChanOpenConfirm is called by the counterparty module to close their end of the

channel, since the other end has been closed.

func (Keeper) ChanOpenInit

func (k Keeper) ChanOpenInit(
	ctx sdk.Context,
	order types.Order,
	connectionHops []string,
	portID string,
	portCap *capabilitytypes.Capability,
	counterparty types.Counterparty,
	version string,
) (string, *capabilitytypes.Capability, error)

ChanOpenInit is called by a module to initiate a channel opening handshake with a module on another chain. The counterparty channel identifier is validated to be empty in msg validation.

func (Keeper) ChanOpenTry

func (k Keeper) ChanOpenTry(
	ctx sdk.Context,
	order types.Order,
	connectionHops []string,
	portID,
	previousChannelID string,
	portCap *capabilitytypes.Capability,
	counterparty types.Counterparty,
	version,
	counterpartyVersion string,
	proofInit []byte,
	proofHeight exported.Height,
) (string, *capabilitytypes.Capability, error)

ChanOpenTry is called by a module to accept the first step of a channel opening handshake initiated by a module on another chain.

func (Keeper) Channel

Channel implements the Query/Channel gRPC method

func (Keeper) ChannelClientState

ChannelClientState implements the Query/ChannelClientState gRPC method

func (Keeper) ChannelConsensusState

ChannelConsensusState implements the Query/ChannelConsensusState gRPC method

func (Keeper) Channels

Channels implements the Query/Channels gRPC method

func (Keeper) ChannelsRest

func (q Keeper) ChannelsRest(ctx sdk.Context, r abci.RequestQuery) ([]byte, error)

func (Keeper) ConnectionChannels

ConnectionChannels implements the Query/ConnectionChannels gRPC method

func (Keeper) CounterpartyHops

func (k Keeper) CounterpartyHops(ctx sdk.Context, ch types.Channel) ([]string, bool)

CounterpartyHops returns the connection hops of the counterparty channel. The counterparty hops are stored in the inverse order as the channel's. NOTE: Since connectionHops only supports single connection channels for now, this function requires that connection hops only contain a single connection id

func (Keeper) GenerateChannelIdentifier

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

GenerateChannelIdentifier returns the next channel identifier.

func (Keeper) GetAllNextSequenceAck added in v1.5.25

func (k Keeper) GetAllNextSequenceAck(ctx sdk.Context, cb func(seq uint64, portID, channelID string) (stop bool))

func (Keeper) GetAllNextSequenceRecv added in v1.5.25

func (k Keeper) GetAllNextSequenceRecv(ctx sdk.Context, cb func(seq uint64, portID, channelID string) (stop bool))

func (Keeper) GetAllNextSequenceSend added in v1.5.25

func (k Keeper) GetAllNextSequenceSend(ctx sdk.Context, cb func(seq uint64, portID, channelID string) (stop bool))

func (Keeper) GetAllPacketAAcknowledgements added in v1.5.25

func (k Keeper) GetAllPacketAAcknowledgements(ctx sdk.Context, cb func(data []byte, portID, channelID string, Seq uint64) (stop bool))

func (Keeper) GetAllPacketCommitments added in v1.5.25

func (k Keeper) GetAllPacketCommitments(ctx sdk.Context, cb func(data []byte, portID, channelID string, Seq uint64) (stop bool))

func (Keeper) GetAllPacketReceipts added in v1.5.25

func (k Keeper) GetAllPacketReceipts(ctx sdk.Context, cb func(data []byte, portID, channelID string, Seq uint64) (stop bool))

func (Keeper) GetChannel

func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Channel, bool)

GetChannel returns a channel with a particular identifier binded to a specific port

func (Keeper) GetChannelClientState

func (k Keeper) GetChannelClientState(ctx sdk.Context, portID, channelID string) (string, exported.ClientState, error)

GetChannelClientState returns the associated client state with its ID, from a port and channel identifier.

func (Keeper) GetChannels added in v1.5.25

func (k Keeper) GetChannels(ctx sdk.Context, cb func(channel types.Channel, portID, channelID string) (stop bool))

func (Keeper) GetNextChannelSequence

func (k Keeper) GetNextChannelSequence(ctx sdk.Context) uint64

GetNextChannelSequence gets the next channel sequence from the store.

func (Keeper) GetNextSequenceAck

func (k Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (uint64, bool)

GetNextSequenceAck gets a channel's next ack sequence from the store

func (Keeper) GetNextSequenceRecv

func (k Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) (uint64, bool)

GetNextSequenceRecv gets a channel's next receive sequence from the store

func (Keeper) GetNextSequenceSend

func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)

GetNextSequenceSend gets a channel's next send sequence from the store

func (Keeper) GetPacketAcknowledgement

func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) ([]byte, bool)

GetPacketAcknowledgement gets the packet ack hash from the store

func (Keeper) GetPacketCommitment

func (k Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte

GetPacketCommitment gets the packet commitment hash from the store

func (Keeper) GetPacketReceipt

func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool)

GetPacketReceipt gets a packet receipt from the store

func (Keeper) HasPacketAcknowledgement

func (k Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) bool

HasPacketAcknowledgement check if the packet ack hash is already on the store

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) LookupModuleByChannel

func (k Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string) (string, *capabilitytypes.Capability, error)

LookupModuleByChannel will return the IBCModule along with the capability associated with a given channel defined by its portID and channelID

func (Keeper) NextSequenceReceive

NextSequenceReceive implements the Query/NextSequenceReceive gRPC method

func (Keeper) PacketAcknowledgement

PacketAcknowledgement implements the Query/PacketAcknowledgement gRPC method

func (Keeper) PacketAcknowledgements

PacketAcknowledgements implements the Query/PacketAcknowledgements gRPC method

func (Keeper) PacketCommitment

PacketCommitment implements the Query/PacketCommitment gRPC method

func (Keeper) PacketCommitmentRest

func (q Keeper) PacketCommitmentRest(ctx sdk.Context, req abci.RequestQuery) ([]byte, error)

PacketCommitment implements the Query/PacketCommitment gRPC method

func (Keeper) PacketCommitments

PacketCommitments implements the Query/PacketCommitments gRPC method

func (Keeper) PacketCommitmentsRest

func (q Keeper) PacketCommitmentsRest(ctx sdk.Context, requst abci.RequestQuery) ([]byte, error)

PacketCommitments implements the Query/PacketCommitments gRPC method

func (Keeper) PacketReceipt

PacketReceipt implements the Query/PacketReceipt gRPC method

func (Keeper) RecvPacket

func (k Keeper) RecvPacket(
	ctx sdk.Context,
	chanCap *capabilitytypes.Capability,
	packet exported.PacketI,
	proof []byte,
	proofHeight exported.Height,
) error

RecvPacket is called by a module in order to receive & process an IBC packet sent on the corresponding channel end on the counterparty chain.

func (Keeper) SendPacket

func (k Keeper) SendPacket(
	ctx sdk.Context,
	channelCap *capabilitytypes.Capability,
	packet exported.PacketI,
) error

SendPacket is called by a module in order to send an IBC packet on a channel end owned by the calling module to the corresponding module on the counterparty chain.

func (Keeper) SetChannel

func (k Keeper) SetChannel(ctx sdk.Context, portID, channelID string, channel types.Channel)

SetChannel sets a channel to the store

func (Keeper) SetNextChannelSequence

func (k Keeper) SetNextChannelSequence(ctx sdk.Context, sequence uint64)

SetNextChannelSequence sets the next channel sequence to the store.

func (Keeper) SetNextSequenceAck

func (k Keeper) SetNextSequenceAck(ctx sdk.Context, portID, channelID string, sequence uint64)

SetNextSequenceAck sets a channel's next ack sequence to the store

func (Keeper) SetNextSequenceRecv

func (k Keeper) SetNextSequenceRecv(ctx sdk.Context, portID, channelID string, sequence uint64)

SetNextSequenceRecv sets a channel's next receive sequence to the store

func (Keeper) SetNextSequenceSend

func (k Keeper) SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64)

SetNextSequenceSend sets a channel's next send sequence to the store

func (Keeper) SetPacketAcknowledgement

func (k Keeper) SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte)

SetPacketAcknowledgement sets the packet ack hash to the store

func (Keeper) SetPacketCommitment

func (k Keeper) SetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64, commitmentHash []byte)

SetPacketCommitment sets the packet commitment hash to the store

func (Keeper) SetPacketReceipt

func (k Keeper) SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64)

SetPacketReceipt sets an empty packet receipt to the store

func (Keeper) TimeoutExecuted

func (k Keeper) TimeoutExecuted(
	ctx sdk.Context,
	chanCap *capabilitytypes.Capability,
	packet exported.PacketI,
) error

TimeoutExecuted deletes the commitment send from this chain after it verifies timeout. If the timed-out packet came from an ORDERED channel then this channel will be closed.

CONTRACT: this function must be called in the IBC handler

func (Keeper) TimeoutPacket

func (k Keeper) TimeoutPacket(
	ctx sdk.Context,
	packet exported.PacketI,
	proof []byte,
	proofHeight exported.Height,
	nextSequenceRecv uint64,
) error

TimeoutPacket is called by a module which originally attempted to send a packet to a counterparty module, where the timeout height has passed on the counterparty chain without the packet being committed, to prove that the packet can no longer be executed and to allow the calling module to safely perform appropriate state transitions. Its intended usage is within the ante handler.

func (Keeper) UnreceivedAcks

UnreceivedAcks implements the Query/UnreceivedAcks gRPC method. Given a list of counterparty packet acknowledgements, the querier checks if the packet has already been received by checking if the packet commitment still exists on this chain (original sender) for the packet sequence. All acknowledgmeents that haven't been received yet are returned in the response. Usage: To use this method correctly, first query all packet acknowledgements on the original receiving chain (ie the chain that wrote the acks) using the Query/PacketAcknowledgements gRPC method. Then input the returned sequences into the QueryUnreceivedAcksRequest and send the request to this Query/UnreceivedAcks on the **original sending** chain. This gRPC method will then return the list of packet sequences whose acknowledgements are already written on the receiving chain but haven't yet been received back to the sending chain.

NOTE: The querier makes the assumption that the provided list of packet acknowledgements is correct and will not function properly if the list is not up to date. Ideally the query height should equal the latest height on the counterparty's client which represents this chain.

func (Keeper) UnreceivedPackets

UnreceivedPackets implements the Query/UnreceivedPackets gRPC method. Given a list of counterparty packet commitments, the querier checks if the packet has already been received by checking if a receipt exists on this chain for the packet sequence. All packets that haven't been received yet are returned in the response Usage: To use this method correctly, first query all packet commitments on the sending chain using the Query/PacketCommitments gRPC method. Then input the returned sequences into the QueryUnreceivedPacketsRequest and send the request to this Query/UnreceivedPackets on the **receiving** chain. This gRPC method will then return the list of packet sequences that are yet to be received on the receiving chain.

NOTE: The querier makes the assumption that the provided list of packet commitments is correct and will not function properly if the list is not up to date. Ideally the query height should equal the latest height on the counterparty's client which represents this chain.

func (Keeper) UnreceivedPacketsRest

func (q Keeper) UnreceivedPacketsRest(ctx sdk.Context, requst abci.RequestQuery) ([]byte, error)

UnreceivedPackets implements the Query/UnreceivedPackets gRPC method. Given a list of counterparty packet commitments, the querier checks if the packet has already been received by checking if a receipt exists on this chain for the packet sequence. All packets that haven't been received yet are returned in the response Usage: To use this method correctly, first query all packet commitments on the sending chain using the Query/PacketCommitments gRPC method. Then input the returned sequences into the QueryUnreceivedPacketsRequest and send the request to this Query/UnreceivedPackets on the **receiving** chain. This gRPC method will then return the list of packet sequences that are yet to be received on the receiving chain.

NOTE: The querier makes the assumption that the provided list of packet commitments is correct and will not function properly if the list is not up to date. Ideally the query height should equal the latest height on the counterparty's client which represents this chain.

func (Keeper) WriteAcknowledgement

func (k Keeper) WriteAcknowledgement(
	ctx sdk.Context,
	chanCap *capabilitytypes.Capability,
	packet exported.PacketI,
	acknowledgement []byte,
) error

WriteAcknowledgement writes the packet execution acknowledgement to the state, which will be verified by the counterparty chain using AcknowledgePacket.

CONTRACT:

1) For synchronous execution, this function is be called in the IBC handler . For async handling, it needs to be called directly by the module which originally processed the packet.

2) Assumes that packet receipt has been written (unordered), or nextSeqRecv was incremented (ordered) previously by RecvPacket.

Jump to

Keyboard shortcuts

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