Documentation ¶
Index ¶
- Constants
- Variables
- func AddMessagesForInterqueries(ctx context.Context, queries []interquerytypes.Interquery, src, dst *Chain, ...) error
- func AddMessagesForSequences(ctx context.Context, sequences []uint64, src, dst *Chain, srch, dsth int64, ...) error
- func CastClientStateToTMType(cs *codectypes.Any) (*tmclient.ClientState, error)
- func CreateClient(ctx context.Context, src, dst *Chain, ...) (bool, error)
- func GetIBCUpdateHeaders(ctx context.Context, srch, dsth int64, src, dst provider.ChainProvider, ...) (srcHeader, dstHeader ibcexported.Header, err error)
- func GetLightSignedHeadersAtHeights(ctx context.Context, src, dst *Chain, srch, dsth int64) (srcUpdateHeader, dstUpdateHeader ibcexported.Header, err error)
- func MustGetHeight(h ibcexported.Height) clienttypes.Height
- func OrderFromString(order string) chantypes.Order
- func ParseChannelIDFromEvents(events []provider.RelayerEvent) (string, error)
- func ParseClientIDFromEvents(events []provider.RelayerEvent) (string, error)
- func ParseConnectionIDFromEvents(events []provider.RelayerEvent) (string, error)
- func PathsSet(chains ...*Chain) bool
- func PrependUpdateClientMsg(ctx context.Context, msgs *[]provider.RelayerMessage, src, dst *Chain, ...) error
- func QueryChannel(ctx context.Context, src *Chain, channelID string) (*chantypes.IdentifiedChannel, error)
- func QueryChannelPair(ctx context.Context, src, dst *Chain, srcH, dstH int64, ...) (srcChan, dstChan *chantypes.QueryChannelResponse, err error)
- func QueryConnectionPair(ctx context.Context, src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *conntypes.QueryConnectionResponse, err error)
- func QueryLatestHeights(ctx context.Context, src, dst *Chain) (srch, dsth int64, err error)
- func QueryPortChannel(ctx context.Context, src *Chain, portID string) (*chantypes.IdentifiedChannel, error)
- func RelayAcknowledgements(ctx context.Context, log *zap.Logger, src, dst *Chain, sp RelaySequences, ...) error
- func RelayInterqueries(ctx context.Context, src, dst *Chain, iqs []interquerytypes.Interquery, ...) error
- func RelayPackets(ctx context.Context, log *zap.Logger, src, dst *Chain, sp RelaySequences, ...) error
- func StartRelayer(ctx context.Context, log *zap.Logger, src, dst *Chain, interquery bool, ...) chan error
- func StringFromOrder(order chantypes.Order) string
- func UnrelayedInterqueries(ctx context.Context, src, dst *Chain) ([]interquerytypes.Interquery, error)
- func ValidateChannelParams(srcPortID, dstPortID, order string) error
- func ValidateClientPaths(src, dst *Chain) error
- func ValidateConnectionPaths(src, dst *Chain) error
- func ValidatePaths(src, dst *Chain) error
- type ActiveChannel
- type Chain
- func (c *Chain) AddPath(clientID, connectionID string) error
- func (c *Chain) ChainID() string
- func (c *Chain) ClientID() string
- func (c *Chain) CloseChannel(ctx context.Context, dst *Chain, maxRetries uint64, timeout time.Duration, ...) error
- func (c *Chain) ConnectionID() string
- func (c *Chain) CreateClients(ctx context.Context, dst *Chain, ...) (bool, error)
- func (c *Chain) CreateOpenChannels(ctx context.Context, dst *Chain, maxRetries uint64, timeout time.Duration, ...) error
- func (c *Chain) CreateOpenConnections(ctx context.Context, dst *Chain, maxRetries uint64, timeout time.Duration, ...) (modified bool, err error)
- func (c *Chain) CreateTestKey() error
- func (c *Chain) ErrCantSetPath(err error) error
- func (c *Chain) ErrPathNotSet() error
- func (c *Chain) GetRPCPort() string
- func (c *Chain) GetSelfVersion() uint64
- func (c *Chain) GetTimeout() (time.Duration, error)
- func (c *Chain) GetTrustingPeriod(ctx context.Context) (time.Duration, error)
- func (c *Chain) LogFailedTx(res *provider.RelayerTxResponse, err error, msgs []provider.RelayerMessage)
- func (c *Chain) LogRetryGetIBCUpdateHeader(n uint, err error)
- func (c *Chain) PathSet() bool
- func (c *Chain) QueryTMClientState(ctx context.Context, height int64) (*tmclient.ClientState, error)
- func (c *Chain) SendTransferMsg(ctx context.Context, log *zap.Logger, dst *Chain, amount sdk.Coin, ...) error
- func (c *Chain) SetPath(p *PathEnd) error
- func (c *Chain) String() string
- func (c *Chain) UpdateClients(ctx context.Context, dst *Chain, memo string) (err error)
- func (c *Chain) UpgradeClients(ctx context.Context, dst *Chain, height int64, memo string) error
- type Chains
- type ChannelFilter
- type IBCdata
- type Interquery
- type Path
- type PathAction
- type PathEnd
- type PathStatus
- type PathWithStatus
- type Paths
- type RelayInterqueryMsgs
- type RelayMsgSender
- type RelayMsgs
- type RelaySequences
- type SendMsgsResult
Constants ¶
const ( ProcessorEvents string = "events" ProcessorLegacy string = "legacy" )
Variables ¶
var ( RtyAttNum = uint(5) RtyAtt = retry.Attempts(RtyAttNum) RtyDel = retry.Delay(time.Millisecond * 400) RtyErr = retry.LastErrorOnly(true) )
Functions ¶
func AddMessagesForInterqueries ¶
func AddMessagesForInterqueries(ctx context.Context, queries []interquerytypes.Interquery, src, dst *Chain, srch, dsth int64, msgs *[]provider.RelayerMessage) error
AddMessagesForInterqueries performs a query for each pending interquery from src on dst chain and then constructs an interquery submit message with the query results for the src chain.
func AddMessagesForSequences ¶
func AddMessagesForSequences( ctx context.Context, sequences []uint64, src, dst *Chain, srch, dsth int64, srcMsgs, dstMsgs *[]provider.RelayerMessage, srcChanID, srcPortID, dstChanID, dstPortID string, order chantypes.Order, ) error
AddMessagesForSequences constructs RecvMsgs and TimeoutMsgs from sequence numbers on a src chain and adds them to the appropriate queue of msgs for both src and dst
func CastClientStateToTMType ¶
func CastClientStateToTMType(cs *codectypes.Any) (*tmclient.ClientState, error)
CastClientStateToTMType casts client state to tendermint type
func CreateClient ¶
func GetIBCUpdateHeaders ¶
func GetIBCUpdateHeaders(ctx context.Context, srch, dsth int64, src, dst provider.ChainProvider, srcClientID, dstClientID string) (srcHeader, dstHeader ibcexported.Header, err error)
GetIBCUpdateHeaders returns a pair of IBC update headers which can be used to update an on chain light client
func MustGetHeight ¶
func MustGetHeight(h ibcexported.Height) clienttypes.Height
MustGetHeight takes the height inteface and returns the actual height
func OrderFromString ¶
OrderFromString parses a string into a channel order byte
func ParseChannelIDFromEvents ¶
func ParseChannelIDFromEvents(events []provider.RelayerEvent) (string, error)
ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or MsgChannelOpenTry and returns the channel identifier.
func ParseClientIDFromEvents ¶
func ParseClientIDFromEvents(events []provider.RelayerEvent) (string, error)
ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the client identifier.
func ParseConnectionIDFromEvents ¶
func ParseConnectionIDFromEvents(events []provider.RelayerEvent) (string, error)
ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or MsgConnectionOpenTry and returns the connection identifier.
func PrependUpdateClientMsg ¶
func PrependUpdateClientMsg(ctx context.Context, msgs *[]provider.RelayerMessage, src, dst *Chain, srch int64) error
PrependUpdateClientMsg adds an UpdateClient msg to the front of non-empty msg lists
func QueryChannel ¶
func QueryChannelPair ¶
func QueryChannelPair(ctx context.Context, src, dst *Chain, srcH, dstH int64, srcChanID, dstChanID, srcPortID, dstPortID string) (srcChan, dstChan *chantypes.QueryChannelResponse, err error)
QueryChannelPair returns a pair of channel responses
func QueryConnectionPair ¶
func QueryConnectionPair(ctx context.Context, src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *conntypes.QueryConnectionResponse, err error)
QueryConnectionPair returns a pair of connection responses
func QueryLatestHeights ¶
QueryLatestHeights returns the heights of multiple chains at once
func QueryPortChannel ¶
func RelayAcknowledgements ¶
func RelayAcknowledgements(ctx context.Context, log *zap.Logger, src, dst *Chain, sp RelaySequences, maxTxSize, maxMsgLength uint64, memo string, srcChannel *chantypes.IdentifiedChannel) error
RelayAcknowledgements creates transactions to relay acknowledgements from src to dst and from dst to src
func RelayInterqueries ¶
func RelayInterqueries(ctx context.Context, src, dst *Chain, iqs []interquerytypes.Interquery, maxTxSize, maxMsgLength uint64) error
RelayInterqueries creates transactions to relay packets from src to dst and from dst to src
func RelayPackets ¶
func RelayPackets(ctx context.Context, log *zap.Logger, src, dst *Chain, sp RelaySequences, maxTxSize, maxMsgLength uint64, memo string, srcChannel *chantypes.IdentifiedChannel) error
RelayPackets creates transactions to relay packets from src to dst and from dst to src
func StartRelayer ¶
func StartRelayer( ctx context.Context, log *zap.Logger, src, dst *Chain, interquery bool, filter ChannelFilter, maxTxSize, maxMsgLength uint64, memo string, processorType string, initialBlockHistory uint64, ) chan error
StartRelayer starts the main relaying loop and returns a channel that will contain any control-flow related errors.
func StringFromOrder ¶
StringFromOrder returns the string representation of a channel order.
func UnrelayedInterqueries ¶
func UnrelayedInterqueries(ctx context.Context, src, dst *Chain) ([]interquerytypes.Interquery, error)
UnrelayedInterqueries returns the unsubmitted/incomplete interqueries for the client-id specified in each interquery
func ValidateChannelParams ¶
ValidateChannelParams validates a set of port-ids as well as the order.
func ValidateClientPaths ¶
ValidateClientPaths takes two chains and validates their clients
func ValidateConnectionPaths ¶
ValidateConnectionPaths takes two chains and validates the connections and underlying client identifiers
func ValidatePaths ¶
ValidatePaths takes two chains and validates their paths
Types ¶
type ActiveChannel ¶
type ActiveChannel struct {
// contains filtered or unexported fields
}
ActiveChannel represents an IBC channel and whether there is an active goroutine relaying packets against it.
type Chain ¶
type Chain struct { ChainProvider provider.ChainProvider Chainid string `yaml:"chain-id" json:"chain-id"` RPCAddr string `yaml:"rpc-addr" json:"rpc-addr"` PathEnd *PathEnd `yaml:"-" json:"-"` // contains filtered or unexported fields }
Chain represents the necessary data for connecting to and identifying a chain and its counterparties TODO revise Chain struct
func UnmarshalChain ¶
UnmarshalChain returns Marshalled chain
func (*Chain) AddPath ¶
AddPath takes the client and connection identifiers for a Path, and if they are initialized, validates them before setting the PathEnd on the Chain. NOTE: if the Path is blank (i.e. the identifiers are not set) validation is skipped.
func (*Chain) CloseChannel ¶
func (c *Chain) CloseChannel( ctx context.Context, dst *Chain, maxRetries uint64, timeout time.Duration, srcChanID, srcPortID string, memo string, ) error
CloseChannel runs the channel closing messages on timeout until they pass.
func (*Chain) ConnectionID ¶
func (*Chain) CreateClients ¶
func (c *Chain) CreateClients(ctx context.Context, dst *Chain, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, override bool, memo string) (bool, error)
CreateClients creates clients for src on dst and dst on src if the client ids are unspecified.
func (*Chain) CreateOpenChannels ¶
func (c *Chain) CreateOpenChannels( ctx context.Context, dst *Chain, maxRetries uint64, timeout time.Duration, srcPortID, dstPortID, order, version string, override bool, memo string, ) error
CreateOpenChannels runs the channel creation messages on timeout until they pass.
func (*Chain) CreateOpenConnections ¶
func (c *Chain) CreateOpenConnections( ctx context.Context, dst *Chain, maxRetries uint64, timeout time.Duration, memo string, ) (modified bool, err error)
CreateOpenConnections runs the connection creation messages on timeout until they pass. The returned boolean indicates that the path end has been modified.
func (*Chain) CreateTestKey ¶
CreateTestKey creates a key for test chain
func (*Chain) ErrCantSetPath ¶
ErrCantSetPath returns an error if the path doesn't set properly
func (*Chain) ErrPathNotSet ¶
ErrPathNotSet returns information what identifiers are needed to relay
func (*Chain) GetRPCPort ¶
GetRPCPort returns the port configured for the chain
func (*Chain) GetSelfVersion ¶
GetSelfVersion returns the version of the given chain
func (*Chain) GetTimeout ¶
GetTimeout returns the chain's configured timeout
func (*Chain) GetTrustingPeriod ¶
GetTrustingPeriod returns the trusting period for the chain
func (*Chain) LogFailedTx ¶
func (c *Chain) LogFailedTx(res *provider.RelayerTxResponse, err error, msgs []provider.RelayerMessage)
LogFailedTx takes the transaction and the messages to create it and logs the appropriate data
func (*Chain) LogRetryGetIBCUpdateHeader ¶
func (*Chain) QueryTMClientState ¶
func (c *Chain) QueryTMClientState(ctx context.Context, height int64) (*tmclient.ClientState, error)
QueryTMClientState retrieves the latest consensus state for a client in state at a given height and unpacks/cast it to tendermint clientstate
func (*Chain) SendTransferMsg ¶
func (c *Chain) SendTransferMsg(ctx context.Context, log *zap.Logger, dst *Chain, amount sdk.Coin, dstAddr string, toHeightOffset uint64, toTimeOffset time.Duration, srcChannel *chantypes.IdentifiedChannel) error
SendTransferMsg initiates an ics20 transfer from src to dst with the specified args
func (*Chain) SetPath ¶
SetPath sets the path and validates the identifiers if they are initialized.
func (*Chain) UpdateClients ¶
UpdateClients updates clients for src on dst and dst on src given the configured paths
type Chains ¶
Chains is a collection of Chain (mapped by chain_name)
type ChannelFilter ¶
type ChannelFilter struct { Rule string `yaml:"rule" json:"rule"` ChannelList []string `yaml:"channel-list" json:"channel-list"` }
ChannelFilter provides the means for either creating an allowlist or a denylist of channels on the src chain which will be used to narrow down the list of channels a user wants to relay on.
func (*ChannelFilter) InChannelList ¶
func (cf *ChannelFilter) InChannelList(channelID string) bool
InChannelList returns true if the channelID argument is in the ChannelFilter's ChannelList or false otherwise.
type IBCdata ¶
type IBCdata struct { Schema string `json:"$schema"` Chain1 struct { ChainName string `json:"chain-name"` ClientID string `json:"client-id"` ConnectionID string `json:"connection-id"` } `json:"chain-1"` Chain2 struct { ChainName string `json:"chain-name"` ClientID string `json:"client-id"` ConnectionID string `json:"connection-id"` } `json:"chain-2"` Channels []struct { Chain1 struct { ChannelID string `json:"channel-id"` PortID string `json:"port-id"` } `json:"chain-1"` Chain2 struct { ChannelID string `json:"channel-id"` PortID string `json:"port-id"` } `json:"chain-2"` Ordering string `json:"ordering"` Version string `json:"version"` Tags struct { Status string `json:"status"` Preferred bool `json:"preferred"` Dex string `json:"dex"` Properties string `json:"properties"` } `json:"tags,omitempty"` } `json:"channels"` }
type Interquery ¶
type Interquery struct {
Query bool `yaml:"query" json:"query"`
}
type Path ¶
type Path struct { Src *PathEnd `yaml:"src" json:"src"` Dst *PathEnd `yaml:"dst" json:"dst"` Filter ChannelFilter `yaml:"src-channel-filter" json:"src-channel-filter"` Interquery Interquery `yaml:"interquery" json:"interquery"` }
Path represents a pair of chains and the identifiers needed to relay over them along with a channel filter list. A Memo can optionally be provided for identification in relayed messages.
func GenPath ¶
GenPath generates a path with unspecified client, connection and channel identifiers given chainIDs and portIDs.
func (*Path) QueryPathStatus ¶
func (p *Path) QueryPathStatus(ctx context.Context, src, dst *Chain) *PathWithStatus
QueryPathStatus returns an instance of the path struct with some attached data about the current status of the path
func (*Path) ValidateChannelFilterRule ¶
ValidateChannelFilterRule verifies that the configured ChannelFilter rule is set to an appropriate value.
type PathEnd ¶
type PathEnd struct { ChainID string `yaml:"chain-id,omitempty" json:"chain-id,omitempty"` ClientID string `yaml:"client-id,omitempty" json:"client-id,omitempty"` ConnectionID string `yaml:"connection-id,omitempty" json:"connection-id,omitempty"` }
PathEnd represents the local connection identifiers for a relay path The path is set on the chain before performing operations
func (*PathEnd) ValidateFull ¶
ValidateFull returns errors about invalid client and connection identifiers.
type PathStatus ¶
type PathStatus struct { Chains bool `yaml:"chains" json:"chains"` Clients bool `yaml:"clients" json:"clients"` Connection bool `yaml:"connection" json:"connection"` }
PathStatus holds the status of the primitives in the path
type PathWithStatus ¶
type PathWithStatus struct { Path *Path `yaml:"path" json:"chains"` Status PathStatus `yaml:"status" json:"status"` }
PathWithStatus is used for showing the status of the path
func (*PathWithStatus) PrintString ¶
func (ps *PathWithStatus) PrintString(name string) string
PrintString prints a string representations of the path status
type Paths ¶
Paths represent connection paths between chains
type RelayInterqueryMsgs ¶
type RelayInterqueryMsgs struct { Msgs []provider.RelayerMessage `json:"msgs"` MaxTxSize uint64 `json:"max_tx_size"` // maximum permitted size of the msgs in a bundled relay transaction MaxMsgLength uint64 `json:"max_msg_length"` // maximum amount of messages in a bundled relay transaction Last bool `json:"last"` Succeeded bool `json:"success"` }
RelayInterqueryMsgs contains the msgs that need to be sent to src chain with query results from the dst chain
func (*RelayInterqueryMsgs) IsMaxTx ¶
func (r *RelayInterqueryMsgs) IsMaxTx(msgLen, txSize uint64) bool
func (*RelayInterqueryMsgs) Ready ¶
func (r *RelayInterqueryMsgs) Ready() bool
Ready returns true if there are messages to relay
func (*RelayInterqueryMsgs) Send ¶
func (r *RelayInterqueryMsgs) Send(ctx context.Context, src, dst *Chain)
func (*RelayInterqueryMsgs) Success ¶
func (r *RelayInterqueryMsgs) Success() bool
Success returns the success var
type RelayMsgSender ¶
type RelayMsgSender struct { ChainID string // SendMessages is a function matching the signature of the same method // on the ChainProvider interface. // // Accepting this narrow subset of the interface greatly simplifies testing. SendMessages func(context.Context, []provider.RelayerMessage, string) (*provider.RelayerTxResponse, bool, error) }
RelayMsgSender is a narrow subset of a Chain, to simplify testing methods on RelayMsgs.
func AsRelayMsgSender ¶
func AsRelayMsgSender(c *Chain) RelayMsgSender
AsRelayMsgSender converts c to a RelayMsgSender.
type RelayMsgs ¶
type RelayMsgs struct { Src []provider.RelayerMessage `json:"src"` Dst []provider.RelayerMessage `json:"dst"` MaxTxSize uint64 `json:"max_tx_size"` // maximum permitted size of the msgs in a bundled relay transaction MaxMsgLength uint64 `json:"max_msg_length"` // maximum amount of messages in a bundled relay transaction }
RelayMsgs contains the msgs that need to be sent to both a src and dst chain after a given relay round. MaxTxSize and MaxMsgLength are ignored if they are set to zero.
func (*RelayMsgs) Send ¶
func (r *RelayMsgs) Send(ctx context.Context, log *zap.Logger, src, dst RelayMsgSender, memo string) SendMsgsResult
Send concurrently sends out r's messages to the corresponding RelayMsgSenders.
type RelaySequences ¶
RelaySequences represents unrelayed packets on src and dst
func UnrelayedAcknowledgements ¶
func UnrelayedAcknowledgements(ctx context.Context, src, dst *Chain, srcChannel *chantypes.IdentifiedChannel) RelaySequences
UnrelayedAcknowledgements returns the unrelayed sequence numbers between two chains
func UnrelayedSequences ¶
func UnrelayedSequences(ctx context.Context, src, dst *Chain, srcChannel *chantypes.IdentifiedChannel) RelaySequences
UnrelayedSequences returns the unrelayed sequence numbers between two chains
func (*RelaySequences) Empty ¶
func (rs *RelaySequences) Empty() bool
type SendMsgsResult ¶
type SendMsgsResult struct {
// Count of successfully sent batches,
// where "successful" means there was no error in sending the batch across the network,
// and the remote end sent a response indicating success.
SuccessfulSrcBatches, SuccessfulDstBatches int
// Accumulation of errors encountered when sending to source or destination.
// If multiple errors occurred, these will be multierr errors
// which are displayed nicely through zap logging.
SrcSendError, DstSendError error
}
SendMsgsResult is returned by (*RelayMsgs).Send. It contains details about the distinct results of sending messages to the corresponding chains.
func (SendMsgsResult) Error ¶
func (r SendMsgsResult) Error() error
Error returns any accumulated erors that occurred while sending messages.
func (SendMsgsResult) MarshalLogObject ¶
func (r SendMsgsResult) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject satisfies the zapcore.ObjectMarshaler interface so that you can use zap.Object("send_result", r) when logging. This is typically useful when logging details about a partially sent result.
func (SendMsgsResult) PartiallySent ¶
func (r SendMsgsResult) PartiallySent() bool
PartiallySent reports the presence of both some successfully sent batches and some errors.