Documentation ¶
Index ¶
- Constants
- Variables
- 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, ...) (string, error)
- func MsgUpdateClient(ctx context.Context, src, dst *Chain, srch, dsth int64) (provider.RelayerMessage, error)
- func MustGetHeight(h ibcexported.Height) clienttypes.Height
- func OrderFromString(order string) chantypes.Order
- func QueryBalance(ctx context.Context, chain *Chain, address string, showDenoms bool) (sdk.Coins, error)
- func QueryChannel(ctx context.Context, src *Chain, channelID string) (*chantypes.IdentifiedChannel, error)
- func QueryClientStates(ctx context.Context, srch, dsth int64, src, dst *Chain) (ibcexported.ClientState, ibcexported.ClientState, error)
- func QueryIBCHeaders(ctx context.Context, src, dst *Chain, srch, dsth int64) (srcUpdateHeader, dstUpdateHeader provider.IBCHeader, err error)
- func QueryIBCUpdateHeaders(ctx context.Context, srcClientID, dstClientID string, ...) (srcHeader, dstHeader, srcTrustedHeader, dstTrustedHeader provider.IBCHeader, ...)
- 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 RelayPackets(ctx context.Context, log *zap.Logger, src, dst *Chain, sp RelaySequences, ...) error
- func StartRelayer(ctx context.Context, log *zap.Logger, chains map[string]*Chain, ...) chan error
- func StringFromOrder(order chantypes.Order) string
- func UpdateClients(ctx context.Context, src, dst *Chain, memo string) error
- func UpgradeClient(ctx context.Context, src, dst *Chain, height int64, memo string) error
- func ValidateChannelParams(srcPortID, dstPortID, order string) error
- func ValidateClientPaths(src, dst *Chain) error
- func ValidateConnectionPaths(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, ...) (string, string, 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, ...) (string, string, 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
- type Chains
- type ChannelFilter
- type IBCdata
- type NamedPath
- type Path
- type PathAction
- type PathEnd
- type PathStatus
- type PathWithStatus
- type Paths
- type RelayMsgSender
- type RelayMsgs
- func (r *RelayMsgs) IsMaxTx(msgLen, txSize uint64) bool
- func (r *RelayMsgs) PrependMsgUpdateClient(ctx context.Context, src, dst *Chain, srch, dsth int64) error
- func (r *RelayMsgs) Ready() bool
- func (r *RelayMsgs) Send(ctx context.Context, log *zap.Logger, src, dst RelayMsgSender, memo string) SendMsgsResult
- type RelaySequences
- type SendMsgsResult
Constants ¶
const ( ProcessorEvents string = "events" ProcessorLegacy = "legacy" )
Variables ¶
var ( RtyAttNum = uint(5) RtyAtt = retry.Attempts(RtyAttNum) RtyDel = retry.Delay(time.Millisecond * 400) RtyErr = retry.LastErrorOnly(true) )
Functions ¶
func AddMessagesForSequences ¶ added in v2.1.0
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 ¶ added in v2.1.0
func CreateClient( ctx context.Context, src, dst *Chain, srcUpdateHeader, dstUpdateHeader provider.IBCHeader, allowUpdateAfterExpiry bool, allowUpdateAfterMisbehaviour bool, override bool, customClientTrustingPeriod time.Duration, memo string) (string, error)
CreateClient creates client tracking dst on src.
func MsgUpdateClient ¶ added in v2.1.0
func MsgUpdateClient( ctx context.Context, src, dst *Chain, srch, dsth int64, ) (provider.RelayerMessage, error)
MsgUpdateClient queries for the current client state on dst, then queries for the latest and trusted headers on src in order to build a MsgUpdateClient message for dst.
func MustGetHeight ¶ added in v2.1.0
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 QueryBalance ¶ added in v2.1.0
func QueryBalance(ctx context.Context, chain *Chain, address string, showDenoms bool) (sdk.Coins, error)
QueryBalance is a helper function for query balance
func QueryChannel ¶ added in v2.1.0
func QueryClientStates ¶ added in v2.1.0
func QueryClientStates(ctx context.Context, srch, dsth int64, src, dst *Chain, ) (ibcexported.ClientState, ibcexported.ClientState, error)
QueryClientStates queries the client state of multiple chains at once
func QueryIBCHeaders ¶ added in v2.1.0
func QueryIBCUpdateHeaders ¶ added in v2.1.0
func QueryIBCUpdateHeaders( ctx context.Context, srcClientID, dstClientID string, src, dst provider.ChainProvider, srch, dsth int64, srcTrustedH, dstTrustedH int64, ) (srcHeader, dstHeader, srcTrustedHeader, dstTrustedHeader provider.IBCHeader, err error)
QueryIBCUpdateHeaders returns a pair of IBC update headers which can be used to update an on chain light client
func QueryLatestHeights ¶
QueryLatestHeights queries the heights of multiple chains at once
func QueryPortChannel ¶ added in v2.1.0
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 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, chains map[string]*Chain, paths []NamedPath, maxTxSize, maxMsgLength uint64, memo string, processorType string, initialBlockHistory uint64, metrics *processor.PrometheusMetrics, ) chan error
StartRelayer starts the main relaying loop and returns a channel that will contain any control-flow related errors.
func StringFromOrder ¶ added in v2.1.0
StringFromOrder returns the string representation of a channel order.
func UpdateClients ¶ added in v2.1.0
UpdateClients updates clients for src on dst and dst on src given the configured paths.
func UpgradeClient ¶ added in v2.1.0
UpgradeClient upgrades the client on dst after src chain has undergone an upgrade. If height is zero, will use the latest height of the source chain. If height is non-zero, it will be used for queries on the source chain.
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
Types ¶
type ActiveChannel ¶ added in v2.1.0
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 (*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, pathName 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, customClientTrustingPeriod time.Duration, memo string) (string, string, 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, pathName 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, initialBlockHistory uint64, pathName string, ) (string, string, 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 ¶ added in v2.1.0
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
type Chains ¶
Chains is a collection of Chain (mapped by chain_name)
type ChannelFilter ¶ added in v2.1.0
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 ¶ added in v2.1.0
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 ¶ added in v2.1.0
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 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"` }
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 ¶ added in v2.1.0
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 RelayMsgSender ¶ added in v2.1.0
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 ¶ added in v2.1.0
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) PrependMsgUpdateClient ¶ added in v2.1.0
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 ¶ added in v2.1.0
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 ¶ added in v2.1.0
func (r SendMsgsResult) Error() error
Error returns any accumulated erors that occurred while sending messages.
func (SendMsgsResult) MarshalLogObject ¶ added in v2.1.0
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 ¶ added in v2.1.0
func (r SendMsgsResult) PartiallySent() bool
PartiallySent reports the presence of both some successfully sent batches and some errors.