processor

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainProcessor

type ChainProcessor interface {
	// Run starts the query loop for the chain which will gather applicable ibc messages and push events out to the relevant PathProcessors.
	// The initialBlockHistory parameter determines how many historical blocks should be fetched and processed before continuing with current blocks.
	// ChainProcessors should obey the context and return upon context cancellation.
	Run(ctx context.Context, initialBlockHistory uint64, stuckPacket *StuckPacket) error

	// Provider returns the ChainProvider, which provides the methods for querying, assembling IBC messages, and sending transactions.
	Provider() provider.ChainProvider
}

The ChainProcessor interface is responsible for polling blocks and emitting IBC message events to the PathProcessors. It is also responsible for tracking open channels and not sending messages to the PathProcessors for closed channels.

type ChainProcessorCacheData

type ChainProcessorCacheData struct {
	IBCMessagesCache     IBCMessagesCache
	InSync               bool
	ClientState          provider.ClientState
	ConnectionStateCache ConnectionStateCache
	ChannelStateCache    ChannelStateCache
	LatestBlock          provider.LatestBlock
	LatestHeader         provider.IBCHeader
	IBCHeaderCache       IBCHeaderCache
}

ChainProcessorCacheData is the data sent from the ChainProcessors to the PathProcessors to keep the PathProcessors up to date with the latest info from the chains.

type ChainProcessors

type ChainProcessors []ChainProcessor

ChainProcessors is a slice of ChainProcessor instances.

type ChannelCloseLifecycle

type ChannelCloseLifecycle struct {
	SrcChainID   string
	SrcChannelID string
	SrcPortID    string
	SrcConnID    string
	DstConnID    string
}

ChannelCloseLifecycle is used as a stop condition for the PathProcessor. It will attempt to finish closing the channel and terminate once the channel is closed.

type ChannelKey

type ChannelKey struct {
	ChannelID             string
	PortID                string
	CounterpartyChannelID string
	CounterpartyPortID    string
}

ChannelKey is the key used for identifying channels between ChainProcessor and PathProcessor.

func ChannelInfoChannelKey

func ChannelInfoChannelKey(info provider.ChannelInfo) ChannelKey

ChannelInfoChannelKey returns the applicable ChannelKey for ChannelInfo.

func PacketInfoChannelKey

func PacketInfoChannelKey(eventType string, info provider.PacketInfo) (ChannelKey, error)

PacketInfoChannelKey returns the applicable ChannelKey for the chain based on the eventType.

func (ChannelKey) Counterparty

func (k ChannelKey) Counterparty() ChannelKey

Counterparty flips a ChannelKey for the perspective of the counterparty chain

func (ChannelKey) MarshalLogObject

func (k ChannelKey) MarshalLogObject(enc zapcore.ObjectEncoder) error

func (ChannelKey) MsgInitKey

func (k ChannelKey) MsgInitKey() ChannelKey

MsgInitKey is used for comparing MsgChannelOpenInit keys with other connection handshake messages. MsgChannelOpenInit does not have CounterpartyChannelID.

func (ChannelKey) PreInitKey

func (k ChannelKey) PreInitKey() ChannelKey

PreInitKey is used for comparing pre-init keys with other connection handshake messages. Before the channel handshake, do not have ChannelID or CounterpartyChannelID.

type ChannelMessage

type ChannelMessage struct {
	ChainID   string
	EventType string
	Info      provider.ChannelInfo
}

type ChannelMessageCache

type ChannelMessageCache map[ChannelKey]provider.ChannelInfo

ChannelMessageCache is used for caching channel handshake IBC messages for a given IBC channel.

func (ChannelMessageCache) Merge

Merge merges another ChannelMessageCache into this one.

type ChannelMessageLifecycle

type ChannelMessageLifecycle struct {
	Initial     *ChannelMessage
	Termination *ChannelMessage
}

ChannelMessageLifecycle is used as a stop condition for the PathProcessor. It will send the Initial channel message (if non-nil), then stop once it observes the termination channel message (if non-nil).

type ChannelMessagesCache

type ChannelMessagesCache map[string]ChannelMessageCache

ChannelMessagesCache is used for caching a ChannelMessageCache for a given IBC message type.

func (ChannelMessagesCache) DeleteMessages

func (c ChannelMessagesCache) DeleteMessages(toDelete ...map[string][]ChannelKey)

func (ChannelMessagesCache) Merge

Merge merges another ChannelMessagesCache into this one.

func (ChannelMessagesCache) Retain

Retain assumes creates cache path if it doesn't exist, then caches message.

type ChannelPacketMessagesCache

type ChannelPacketMessagesCache map[ChannelKey]PacketMessagesCache

ChannelPacketMessagesCache is used for caching a PacketMessagesCache for a given IBC channel.

func (ChannelPacketMessagesCache) Cache

func (c ChannelPacketMessagesCache) Cache(
	eventType string,
	k ChannelKey,
	sequence uint64,
	packetInfo provider.PacketInfo,
)

Cache stores packet info safely, generating intermediate maps along the way if necessary.

func (ChannelPacketMessagesCache) IsCached

func (c ChannelPacketMessagesCache) IsCached(eventType string, k ChannelKey, sequence uint64) bool

IsCached returns true if a sequence for a channel key and event type is already cached.

func (ChannelPacketMessagesCache) Merge

Merge merges another ChannelPacketMessagesCache into this one.

func (ChannelPacketMessagesCache) Retain

Retain assumes the packet is applicable to the channels for a path processor that is subscribed to this chain processor. It creates cache path if it doesn't exist, then caches message.

type ChannelPacketStateCache

type ChannelPacketStateCache map[ChannelKey]PacketSequenceStateCache

ChannelPacketStateCache is used for caching a PacketSequenceStateCache for a given IBC channel.

func (ChannelPacketStateCache) Prune

func (c ChannelPacketStateCache) Prune(keep int)

Prune deletes all map entries except for the most recent (keep) for all channels.

func (ChannelPacketStateCache) State

func (c ChannelPacketStateCache) State(k ChannelKey, sequence uint64) (string, bool)

func (ChannelPacketStateCache) UpdateState

func (c ChannelPacketStateCache) UpdateState(k ChannelKey, sequence uint64, state string)

type ChannelState

type ChannelState struct {
	Order chantypes.Order
	Open  bool
}

ChannelState is used for caching channel open state and a lookup for the channel order.

type ChannelStateCache

type ChannelStateCache map[ChannelKey]ChannelState

ChannelStateCache maintains channel open state for multiple channels.

func (ChannelStateCache) FilterForClient

func (c ChannelStateCache) FilterForClient(clientID string, channelConnections map[string]string, connectionClients map[string]string) ChannelStateCache

FilterForClient returns a filtered copy of channels on top of an underlying clientID so it can be used by other goroutines.

func (ChannelStateCache) SetOpen

func (c ChannelStateCache) SetOpen(k ChannelKey, open bool, order chantypes.Order)

SetOpen sets the open state for a channel, and also the order if it is not NONE.

type ClientICQMessageCache

type ClientICQMessageCache map[provider.ClientICQQueryID]provider.ClientICQInfo

ClientICQMessageCache is used for caching a client ICQ message for a given query ID.

func (ClientICQMessageCache) Merge

Merge merges another ClientICQMessageCache into this one.

type ClientICQMessagesCache

type ClientICQMessagesCache map[ClientICQType]ClientICQMessageCache

ClientICQMessagesCache is used for caching a ClientICQMessageCache for a given type (query/response).

func (ClientICQMessagesCache) DeleteMessages

func (c ClientICQMessagesCache) DeleteMessages(queryID ...provider.ClientICQQueryID)

DeleteMessages deletes cached messages for the provided query ID.

func (ClientICQMessagesCache) Merge

Merge merges another ClientICQMessagesCache into this one.

func (ClientICQMessagesCache) Retain

Retain creates cache path if it doesn't exist, then caches message.

type ClientICQType

type ClientICQType string

ClientICQType string wrapper for query/response type.

const (
	ClientICQTypeRequest  ClientICQType = "query_request"
	ClientICQTypeResponse ClientICQType = "query_response"
)

type ConnectionKey

type ConnectionKey struct {
	ClientID             string
	ConnectionID         string
	CounterpartyClientID string
	CounterpartyConnID   string
}

ConnectionKey is the key used for identifying connections between ChainProcessor and PathProcessor.

func ConnectionInfoConnectionKey

func ConnectionInfoConnectionKey(info provider.ConnectionInfo) ConnectionKey

ConnectionInfoConnectionKey returns the applicable ConnectionKey for ConnectionInfo.

func (ConnectionKey) Counterparty

func (connectionKey ConnectionKey) Counterparty() ConnectionKey

Counterparty flips a ConnectionKey for the perspective of the counterparty chain

func (ConnectionKey) MarshalLogObject

func (k ConnectionKey) MarshalLogObject(enc zapcore.ObjectEncoder) error

func (ConnectionKey) MsgInitKey

func (connectionKey ConnectionKey) MsgInitKey() ConnectionKey

MsgInitKey is used for comparing MsgConnectionOpenInit keys with other connection handshake messages. MsgConnectionOpenInit does not have CounterpartyConnectionID.

func (ConnectionKey) PreInitKey

func (connectionKey ConnectionKey) PreInitKey() ConnectionKey

PreInitKey is used for comparing pre-init keys with other connection handshake messages. Before starting a connection handshake, do not have ConnectionID or CounterpartyConnectionID.

type ConnectionMessage

type ConnectionMessage struct {
	ChainID   string
	EventType string
	Info      provider.ConnectionInfo
}

type ConnectionMessageCache

type ConnectionMessageCache map[ConnectionKey]provider.ConnectionInfo

ConnectionMessageCache is used for caching connection handshake IBC messages for a given IBC connection.

func (ConnectionMessageCache) Merge

Merge merges another ConnectionMessageCache into this one.

type ConnectionMessageLifecycle

type ConnectionMessageLifecycle struct {
	Initial     *ConnectionMessage
	Termination *ConnectionMessage
}

ConnectionMessageLifecycle is used as a stop condition for the PathProcessor. It will send the Initial connection message (if non-nil), then stop once it observes the termination connection message (if non-nil).

type ConnectionMessagesCache

type ConnectionMessagesCache map[string]ConnectionMessageCache

ConnectionMessagesCache is used for caching a ConnectionMessageCache for a given IBC message type.

func (ConnectionMessagesCache) DeleteMessages

func (c ConnectionMessagesCache) DeleteMessages(toDelete ...map[string][]ConnectionKey)

func (ConnectionMessagesCache) Merge

Merge merges another ConnectionMessagesCache into this one.

func (ConnectionMessagesCache) Retain

Retain assumes creates cache path if it doesn't exist, then caches message.

type ConnectionStateCache

type ConnectionStateCache map[ConnectionKey]bool

ConnectionStateCache maintains connection open state for multiple connections.

func (ConnectionStateCache) FilterForClient

func (c ConnectionStateCache) FilterForClient(clientID string) ConnectionStateCache

FilterForClient makes a filtered copy of the ConnectionStateCache for a single client ID so it can be used by other goroutines.

type FlushLifecycle

type FlushLifecycle struct{}

Flush lifecycle informs the PathProcessor to terminate once all pending messages have been flushed.

type IBCHeaderCache

type IBCHeaderCache map[uint64]provider.IBCHeader

IBCHeaderCache holds a mapping of IBCHeaders for their block height.

func (IBCHeaderCache) Clone

func (c IBCHeaderCache) Clone() IBCHeaderCache

Clone makes a deep copy of an IBCHeaderCache.

func (IBCHeaderCache) Merge

func (c IBCHeaderCache) Merge(other IBCHeaderCache)

Merge merges another IBCHeaderCache into this one.

func (IBCHeaderCache) Prune

func (c IBCHeaderCache) Prune(keep int)

Prune deletes all map entries except for the most recent (keep).

type IBCMessagesCache

type IBCMessagesCache struct {
	PacketFlow          ChannelPacketMessagesCache
	PacketState         ChannelPacketStateCache
	ConnectionHandshake ConnectionMessagesCache
	ChannelHandshake    ChannelMessagesCache
	ClientICQ           ClientICQMessagesCache
}

IBCMessagesCache holds cached messages for packet flows, connection handshakes, and channel handshakes. The PathProcessors use this for message correlation to determine when messages should be sent and are pruned when flows/handshakes are complete. ChainProcessors construct this for new IBC messages and pass it to the PathProcessors which will retain relevant messages for each PathProcessor.

func NewIBCMessagesCache

func NewIBCMessagesCache() IBCMessagesCache

NewIBCMessagesCache returns an empty IBCMessagesCache.

func (IBCMessagesCache) Clone

Clone makes a deep copy of an IBCMessagesCache.

type MessageLifecycle

type MessageLifecycle interface {
	// contains filtered or unexported methods
}

MessageLifecycle is used to send an initial IBC message to a chain once the chains are in sync for the PathProcessor. It also allows setting a stop condition for the PathProcessor. PathProcessor will stop if it observes a message that matches the MessageLifecycle's Termination message.

type PacketMessage

type PacketMessage struct {
	ChainID   string
	EventType string
	Info      provider.PacketInfo
}

type PacketMessageLifecycle

type PacketMessageLifecycle struct {
	Initial     *PacketMessage
	Termination *PacketMessage
}

PacketMessageLifecycle is used as a stop condition for the PathProcessor. It will send the Initial packet message (if non-nil), then stop once it observes the Termination packet message (if non-nil).

type PacketMessagesCache

type PacketMessagesCache map[string]PacketSequenceCache

PacketMessagesCache is used for caching a PacketSequenceCache for a given IBC message type.

func (PacketMessagesCache) Clone

Clone creates a deep copy of a PacketMessagesCache.

func (PacketMessagesCache) DeleteMessages

func (c PacketMessagesCache) DeleteMessages(toDelete ...map[string][]uint64)

func (PacketMessagesCache) Merge

Merge merges another PacketMessagesCache into this one.

type PacketSequenceCache

type PacketSequenceCache map[uint64]provider.PacketInfo

PacketSequenceCache is used for caching an IBC message for a given packet sequence.

func (PacketSequenceCache) Merge

Merge merges another PacketSequenceCache into this one.

type PacketSequenceStateCache

type PacketSequenceStateCache map[uint64]string

PacketSequenceStateCache is used for caching the state of a packet sequence.

func (PacketSequenceStateCache) Prune

func (c PacketSequenceStateCache) Prune(keep int)

Prune deletes all map entries except for the most recent (keep).

type StuckPacket

type StuckPacket struct {
	ChainID     string
	StartHeight uint64
	EndHeight   uint64
}

StuckPacket is used for narrowing block queries on packets that are stuck on a channel for a specific chain.

Jump to

Keyboard shortcuts

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