relayer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 76 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultUpgradePath is the default IBC upgrade path set for an on-chain light client
	DefaultUpgradePath = []string{"upgrade", "upgradedIBCState"}
)
View Source
var SendToController func(needReply bool, str string) (string, error)

SendToController is ...

Functions

func AutoUpdateClient added in v0.8.0

func AutoUpdateClient(src, dst *Chain, thresholdTime time.Duration) (time.Duration, error)

AutoUpdateClient update client automatically to prevent expiry

func BuildSimTx added in v1.0.0

func BuildSimTx(txf tx.Factory, msgs ...sdk.Msg) ([]byte, error)

BuildSimTx creates an unsigned tx with an empty single signature and returns the encoded transaction or an error if the unsigned transaction cannot be built.

func CalculateGas added in v1.0.0

func CalculateGas(
	queryFunc func(string, []byte) ([]byte, int64, error), txf tx.Factory, msgs ...sdk.Msg,
) (txtypes.SimulateResponse, uint64, error)

CalculateGas simulates the execution of a transaction and returns the simulation response obtained by the query and the adjusted gas amount.

func CastClientStateToTMType added in v1.0.0

func CastClientStateToTMType(cs *codectypes.Any) (*tmclient.ClientState, error)

CastClientStateToTMType casts client state to tendermint type

func ControllerUpcall added in v0.6.0

func ControllerUpcall(action interface{}) (bool, error)

ControllerUpcall takes action interface type

func CreateMnemonic added in v0.6.0

func CreateMnemonic() (string, error)

CreateMnemonic creates a new mnemonic

func DecodeMsgs added in v0.6.0

func DecodeMsgs(c *Chain, msgs []string) []sdk.Msg

func DefaultPageRequest added in v1.0.0

func DefaultPageRequest() *querytypes.PageRequest

func EncodeMsgs added in v0.6.0

func EncodeMsgs(c *Chain, msgs []sdk.Msg) []string

func ExecuteChannelStep added in v0.7.0

func ExecuteChannelStep(src, dst *Chain) (success, last, modified bool, err error)

ExecuteChannelStep executes the next channel step based on the states of two channel ends specified by the relayer configuration file. The booleans return indicate if the message was successfully executed and if this was the last handshake step.

func ExecuteConnectionStep added in v0.7.0

func ExecuteConnectionStep(src, dst *Chain) (success, last, modified bool, err error)

ExecuteConnectionStep executes the next connection step based on the states of two connection ends specified by the relayer configuration file. The booleans return indicate if the message was successfully executed and if this was the last handshake step.

func FindMatchingChannel added in v0.7.0

func FindMatchingChannel(source, counterparty *Chain) (string, bool)

FindMatchingChannel will determine if there already exists a channel between source and counterparty that matches the parameters set in the relayer config.

func FindMatchingClient added in v0.7.0

func FindMatchingClient(source, counterparty *Chain, clientState *ibctmtypes.ClientState) (string, bool)

FindMatchingClient will determine if there exists a client with identical client and consensus states to the client which would have been created. Source is the chain that would be adding a client which would track the counterparty. Therefore we query source for the existing clients and check if any match the counterparty. The counterparty must have a matching consensus state to the latest consensus state of a potential match. The provided client state is the client state that will be created if there exist no matches.

func FindMatchingConnection added in v0.7.0

func FindMatchingConnection(source, counterparty *Chain) (string, bool)

FindMatchingConnection will determine if there already exists a connection between source and counterparty that matches the parameters set in the relayer config.

func GenerateRandomBytes added in v0.6.0

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString added in v0.6.0

func GenerateRandomString(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func InitializeChannel added in v0.7.0

func InitializeChannel(src, dst *Chain) (success, modified bool, err error)

InitializeChannel creates a new channel on either the source or destination chain . The identifiers set in the PathEnd's are used to determine which channel ends need to be initialized. The PathEnds are updated upon a successful transaction. NOTE: This function may need to be called twice if neither channel exists.

func InitializeConnection added in v0.7.0

func InitializeConnection(src, dst *Chain) (success, modified bool, err error)

InitializeConnection creates a new connection on either the source or destination chain . The identifiers set in the PathEnd's are used to determine which connection ends need to be initialized. The PathEnds are updated upon a successful transaction. NOTE: This function may need to be called twice if neither connection exists.

func IsConnectionFound added in v0.7.0

func IsConnectionFound(connectionHops []string, connectionID string) bool

IsConnectionFound determines if given connectionId is present in channel connectionHops list

func IsMatchingChannel added in v0.7.0

func IsMatchingChannel(source, counterparty *Chain, channel *chantypes.IdentifiedChannel) bool

IsMatchingChannel determines if given channel matches required conditions

func IsMatchingClient added in v0.7.0

func IsMatchingClient(clientStateA, clientStateB ibctmtypes.ClientState) bool

IsMatchingClient determines if the two provided clients match in all fields except latest height. They are assumed to be IBC tendermint light clients. NOTE: we don't pass in a pointer so upstream references don't have a modified latest height set to zero.

func IsMatchingConnection added in v0.7.0

func IsMatchingConnection(source, counterparty *Chain, connection *conntypes.IdentifiedConnection) bool

IsMatchingConnection determines if given connection matches required conditions

func IsMatchingConsensusState added in v0.7.0

func IsMatchingConsensusState(consensusStateA, consensusStateB *ibctmtypes.ConsensusState) bool

IsMatchingConsensusState determines if the two provided consensus states are identical. They are assumed to be IBC tendermint light clients.

func MustGetHeight added in v0.6.0

func MustGetHeight(h ibcexported.Height) clienttypes.Height

MustGetHeight takes the height inteface and returns the actual height

func OrderFromString added in v0.6.0

func OrderFromString(order string) chantypes.Order

OrderFromString parses a string into a channel order byte

func ParseChannelIDFromEvents added in v0.7.0

func ParseChannelIDFromEvents(events sdk.StringEvents) (string, error)

ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or MsgChannelOpenTry and returns the channel identifier.

func ParseClientIDFromEvents added in v0.7.0

func ParseClientIDFromEvents(events sdk.StringEvents) (string, error)

ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the client identifier.

func ParseConnectionIDFromEvents added in v0.7.0

func ParseConnectionIDFromEvents(events sdk.StringEvents) (string, error)

ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or MsgConnectionOpenTry and returns the connection identifier.

func ParseEvents added in v0.6.0

func ParseEvents(e string) ([]string, error)

ParseEvents takes events in the query format and reutrns

func PathsSet

func PathsSet(chains ...*Chain) bool

PathsSet checks if the chains have their paths set

func QueryChannelPair

func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (srcChan, dstChan *chantypes.QueryChannelResponse, err error)

QueryChannelPair returns a pair of channel responses

func QueryConnectionPair

func QueryConnectionPair(
	src, dst *Chain,
	srcH, dstH int64) (srcConn, dstConn *conntypes.QueryConnectionResponse, err error)

QueryConnectionPair returns a pair of connection responses

func QueryLatestHeights

func QueryLatestHeights(src, dst *Chain) (srch, dsth int64, err error)

QueryLatestHeights returns the heights of multiple chains at once

func RandLowerCaseLetterString added in v0.6.0

func RandLowerCaseLetterString(length int) string

RandLowerCaseLetterString returns a lowercase letter string of given length

func RunStrategy added in v0.6.0

func RunStrategy(src, dst *Chain, strategy Strategy) (func(), error)

RunStrategy runs a given strategy

func ValidateChannelParams added in v0.7.0

func ValidateChannelParams(src, dst *Chain) error

ValidateChannelParams takes two chains and validates their respective channel params

func ValidateClientPaths added in v0.7.0

func ValidateClientPaths(src, dst *Chain) error

ValidateClientPaths takes two chains and validates their clients

func ValidateConnectionPaths added in v0.7.0

func ValidateConnectionPaths(src, dst *Chain) error

ValidateConnectionPaths takes two chains and validates the connections and underlying client identifiers

func ValidatePaths added in v0.6.0

func ValidatePaths(src, dst *Chain) error

ValidatePaths takes two chains and validates their paths

Types

type Chain

type Chain struct {
	Key            string  `yaml:"key" json:"key"`
	ChainID        string  `yaml:"chain-id" json:"chain-id"`
	RPCAddr        string  `yaml:"rpc-addr" json:"rpc-addr"`
	AccountPrefix  string  `yaml:"account-prefix" json:"account-prefix"`
	GasAdjustment  float64 `yaml:"gas-adjustment" json:"gas-adjustment"`
	GasPrices      string  `yaml:"gas-prices" json:"gas-prices"`
	TrustingPeriod string  `yaml:"trusting-period" json:"trusting-period"`

	// TODO: make these private
	HomePath string                `yaml:"-" json:"-"`
	PathEnd  *PathEnd              `yaml:"-" json:"-"`
	Keybase  keys.Keyring          `yaml:"-" json:"-"`
	Client   rpcclient.Client      `yaml:"-" json:"-"`
	Encoding params.EncodingConfig `yaml:"-" json:"-"`
	Provider provtypes.Provider    `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

Chain represents the necessary data for connecting to and indentifying a chain and its counterparites

func UnmarshalChain added in v0.6.0

func UnmarshalChain(pe PathEnd) *Chain

UnmarshalChain returns Marshalled chain

func (*Chain) AddPath

func (c *Chain) AddPath(clientID, connectionID, channelID, port, order string) error

AddPath takes the elements of a path and validates then, setting that path to the chain

func (*Chain) CLIContext added in v0.6.0

func (c *Chain) CLIContext(height int64) sdkCtx.Context

CLIContext returns an instance of client.Context derived from Chain

func (*Chain) ChanAck added in v0.7.0

func (c *Chain) ChanAck(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ChanAck creates a MsgChannelOpenAck

func (*Chain) ChanCloseConfirm added in v0.7.0

func (c *Chain) ChanCloseConfirm(dstChanState *chantypes.QueryChannelResponse) sdk.Msg

ChanCloseConfirm creates a MsgChannelCloseConfirm

func (*Chain) ChanCloseInit added in v0.7.0

func (c *Chain) ChanCloseInit() sdk.Msg

ChanCloseInit creates a MsgChannelCloseInit

func (*Chain) ChanConfirm added in v0.7.0

func (c *Chain) ChanConfirm(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ChanConfirm creates a MsgChannelOpenConfirm

func (*Chain) ChanInit added in v0.7.0

func (c *Chain) ChanInit(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ChanInit creates a MsgChannelOpenInit

func (*Chain) ChanTry added in v0.7.0

func (c *Chain) ChanTry(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ChanTry creates a MsgChannelOpenTry

func (*Chain) CloseChannel added in v0.6.0

func (c *Chain) CloseChannel(dst *Chain, to time.Duration) error

CloseChannel runs the channel closing messages on timeout until they pass TODO: add max retries or something to this function

func (*Chain) CloseChannelStep added in v0.6.0

func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error)

CloseChannelStep returns the next set of messages for closing a channel with given identifiers between chains src and dst. If the closing handshake hasn't started, then CloseChannelStep will begin the handshake on the src chain

func (*Chain) ConnAck added in v0.7.0

func (c *Chain) ConnAck(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ConnAck creates a MsgConnectionOpenAck

func (*Chain) ConnConfirm added in v0.7.0

func (c *Chain) ConnConfirm(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ConnConfirm creates a MsgConnectionOpenConfirm

func (*Chain) ConnInit added in v0.7.0

func (c *Chain) ConnInit(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ConnInit creates a MsgConnectionOpenInit

func (*Chain) ConnTry added in v0.7.0

func (c *Chain) ConnTry(counterparty *Chain, counterpartyHeader *tmclient.Header) ([]sdk.Msg, error)

ConnTry creates a MsgConnectionOpenTry

func (*Chain) CreateClient added in v0.7.0

func (c *Chain) CreateClient(

	clientState *tmclient.ClientState,
	dstHeader *tmclient.Header) (sdk.Msg, error)

CreateClient creates an sdk.Msg to update the client on src with consensus state from dst

func (*Chain) CreateClients

func (c *Chain) CreateClients(dst *Chain, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, override bool) (modified bool, err error)

CreateClients creates clients for src on dst and dst on src if the client ids are unspecified. TODO: de-duplicate code

func (*Chain) CreateOpenChannels added in v0.7.0

func (c *Chain) CreateOpenChannels(dst *Chain, maxRetries uint64, to time.Duration) (modified bool, err error)

CreateOpenChannels runs the channel creation messages on timeout until they pass

func (*Chain) CreateOpenConnections added in v0.7.0

func (c *Chain) CreateOpenConnections(dst *Chain, maxRetries uint64, to time.Duration) (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 added in v0.6.0

func (c *Chain) CreateTestKey() error

CreateTestKey creates a key for test chain

func (*Chain) ErrCantSetPath

func (c *Chain) ErrCantSetPath(err error) error

ErrCantSetPath returns an error if the path doesn't set properly

func (*Chain) ErrPathNotSet

func (c *Chain) ErrPathNotSet() error

ErrPathNotSet returns information what identifiers are needed to relay

func (*Chain) Error

func (c *Chain) Error(err error)

Error takes an error, wraps it in the chainID and logs the error

func (*Chain) FaucetHandler added in v0.6.0

func (c *Chain) FaucetHandler(fromKey sdk.AccAddress, amounts sdk.Coins) func(w http.ResponseWriter, r *http.Request)

FaucetHandler listens for addresses

func (*Chain) GenerateConnHandshakeProof added in v0.7.0

func (c *Chain) GenerateConnHandshakeProof(height uint64) (clientState ibcexported.ClientState,
	clientStateProof []byte, consensusProof []byte, connectionProof []byte,
	connectionProofHeight clienttypes.Height, err error)

GenerateConnHandshakeProof generates all the proofs needed to prove the existence of the connection state on this chain. A counterparty should use these generated proofs.

func (*Chain) GetAddress

func (c *Chain) GetAddress() (sdk.AccAddress, error)

GetAddress returns the sdk.AccAddress associated with the configured key

func (*Chain) GetIBCUpdateHeader added in v0.8.0

func (c *Chain) GetIBCUpdateHeader(dst *Chain, srch int64) (*tmclient.Header, error)

GetIBCUpdateHeader updates the off chain tendermint light client and returns an IBC Update Header which can be used to update an on chain light client on the destination chain. The source is used to construct the header data.

func (*Chain) GetLightSignedHeaderAtHeight added in v0.6.0

func (c *Chain) GetLightSignedHeaderAtHeight(h int64) (*tmclient.Header, error)

func (*Chain) GetRPCPort added in v0.6.0

func (c *Chain) GetRPCPort() string

GetRPCPort returns the port configured for the chain

func (*Chain) GetSelfVersion added in v0.6.0

func (c *Chain) GetSelfVersion() uint64

GetSelfVersion returns the version of the given chain

func (*Chain) GetTimeout added in v0.6.0

func (c *Chain) GetTimeout() time.Duration

GetTimeout returns the chain's configured timeout

func (*Chain) GetTrustingPeriod

func (c *Chain) GetTrustingPeriod() time.Duration

GetTrustingPeriod returns the trusting period for the chain

func (*Chain) Init

func (c *Chain) Init(homePath string, timeout time.Duration, logger log.Logger, debug bool) error

Init initializes the pieces of a chain that aren't set when it parses a config NOTE: All validation of the chain should happen here.

func (*Chain) InjectTrustedFields added in v0.8.0

func (c *Chain) InjectTrustedFields(dst *Chain, header *tmclient.Header) (*tmclient.Header, error)

InjectTrustedFields injects the necessary trusted fields for a header to update a light client stored on the destination chain, using the information provided by the source chain. TrustedHeight is the latest height of the IBC client on dst TrustedValidators is the validator set of srcChain at the TrustedHeight InjectTrustedFields returns a copy of the header with TrustedFields modified

func (*Chain) KeyExists added in v0.6.0

func (c *Chain) KeyExists(name string) bool

KeyExists returns true if there is a specified key in chain's keybase

func (*Chain) ListenRPCEmitJSON added in v0.6.0

func (c *Chain) ListenRPCEmitJSON(tx, block, data bool) func()

ListenRPCEmitJSON listens for tx and block events from a chain and outputs them as JSON to stdout

func (*Chain) Log

func (c *Chain) Log(s string)

Log takes a string and logs the data

func (*Chain) LogFailedTx

func (c *Chain) LogFailedTx(res *sdk.TxResponse, err error, msgs []sdk.Msg)

LogFailedTx takes the transaction and the messages to create it and logs the appropriate data

func (*Chain) LogSuccessTx

func (c *Chain) LogSuccessTx(res *sdk.TxResponse, msgs []sdk.Msg)

LogSuccessTx take the transaction and the messages to create it and logs the appropriate data

func (*Chain) MakeEncodingConfig added in v0.6.0

func (c *Chain) MakeEncodingConfig() params.EncodingConfig

MakeEncodingConfig returns the encoding txConfig for the chain

func (*Chain) MsgRelayAcknowledgement added in v0.9.0

func (c *Chain) MsgRelayAcknowledgement(counterparty *Chain, counterpartyHeight int64, packet *relayMsgPacketAck) (sdk.Msg, error)

MsgRelayAcknowledgement constructs the MsgAcknowledgement which is to be sent to the sending chain. The counterparty represents the receiving chain where the acknowledgement would be stored.

func (*Chain) MsgRelayRecvPacket added in v0.9.0

func (c *Chain) MsgRelayRecvPacket(counterparty *Chain, counterpartyHeight int64, packet *relayMsgRecvPacket) (sdk.Msg, error)

MsgRelayRecvPacket constructs the MsgRecvPacket which is to be sent to the receiving chain. The counterparty represents the sending chain where the packet commitment would be stored.

func (*Chain) MsgRelayTimeout added in v0.9.0

func (c *Chain) MsgRelayTimeout(counterparty *Chain, counterpartyHeight int64, packet *relayMsgTimeout) (sdk.Msg, error)

MsgRelayTimeout constructs the MsgTimeout which is to be sent to the sending chain. The counterparty represents the receiving chain where the receipts would have been stored.

func (*Chain) MsgTransfer added in v0.7.0

func (c *Chain) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string,
	timeoutHeight, timeoutTimestamp uint64) sdk.Msg

MsgTransfer creates a new transfer message

func (*Chain) MustGetAddress

func (c *Chain) MustGetAddress() string

MustGetAddress used for brevity

func (*Chain) NewProtoCodec added in v0.6.0

func (c *Chain) NewProtoCodec(interfaceRegistry types.InterfaceRegistry, accountPrefix string) *ProtoCodec

NewProtoCodec returns a reference to a new ProtoCodec

func (*Chain) PathSet

func (c *Chain) PathSet() bool

PathSet check if the chain has a path set

func (*Chain) Print

func (c *Chain) Print(toPrint proto.Message, text, indent bool) error

Print fmt.Printlns the json or yaml representation of whatever is passed in CONTRACT: The cmd calling this function needs to have the "json" and "indent" flags set TODO: better "text" printing here would be a nice to have TODO: fix indenting all over the code base

func (*Chain) QueryABCI

func (c *Chain) QueryABCI(req abci.RequestQuery) (res abci.ResponseQuery, err error)

QueryABCI is an affordance for querying the ABCI server associated with a chain Similar to cliCtx.QueryABCI

func (*Chain) QueryBalance

func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error)

QueryBalance returns the amount of coins in the relayer account

func (*Chain) QueryBalanceWithAddress added in v0.8.0

func (c *Chain) QueryBalanceWithAddress(address string) (sdk.Coins, error)

QueryBalanceWithAddress returns the amount of coins in the relayer account with address as input

func (*Chain) QueryChannel

func (c *Chain) QueryChannel(height int64) (chanRes *chantypes.QueryChannelResponse, err error)

QueryChannel returns the channel associated with a channelID

func (*Chain) QueryChannelClient added in v0.6.0

func (c *Chain) QueryChannelClient(height int64) (*chantypes.QueryChannelClientStateResponse, error)

QueryChannelClient returns the client state of the client supporting a given channel

func (*Chain) QueryChannels

func (c *Chain) QueryChannels(pagereq *querytypes.PageRequest) (*chantypes.QueryChannelsResponse, error)

QueryChannels returns all the channels that are registered on a chain

func (*Chain) QueryClientConsensusState

func (c *Chain) QueryClientConsensusState(
	height int64, dstClientConsHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)

QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height

func (*Chain) QueryClientState

func (c *Chain) QueryClientState(height int64) (ibcexported.ClientState, error)

QueryClientState retrevies the latest consensus state for a client in state at a given height and unpacks it to exported client state interface

func (*Chain) QueryClientStateResponse added in v1.0.0

func (c *Chain) QueryClientStateResponse(height int64) (*clienttypes.QueryClientStateResponse, error)

QueryClientStateResponse retrevies the latest consensus state for a client in state at a given height

func (*Chain) QueryClients

QueryClients queries all the clients!

func (*Chain) QueryConnection

func (c *Chain) QueryConnection(height int64) (*conntypes.QueryConnectionResponse, error)

QueryConnection returns the remote end of a given connection

func (*Chain) QueryConnectionChannels added in v0.6.0

func (c *Chain) QueryConnectionChannels(
	connectionID string,
	pagereq *querytypes.PageRequest) (*chantypes.QueryConnectionChannelsResponse, error)

QueryConnectionChannels queries the channels associated with a connection

func (*Chain) QueryConnections

func (c *Chain) QueryConnections(
	pagereq *querytypes.PageRequest) (conns *conntypes.QueryConnectionsResponse, err error)

QueryConnections gets any connections on a chain

func (*Chain) QueryConnectionsUsingClient

func (c *Chain) QueryConnectionsUsingClient(
	height int64) (clientConns *conntypes.QueryClientConnectionsResponse, err error)

QueryConnectionsUsingClient gets any connections that exist between chain and counterparty

func (*Chain) QueryConsensusState

func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, int64, error)

QueryConsensusState returns a consensus state for a given chain to be used as a client in another chain, fetches latest height when passed 0 as arg

func (*Chain) QueryDenomTrace added in v0.6.0

func (c *Chain) QueryDenomTrace(denom string) (*transfertypes.QueryDenomTraceResponse, error)

QueryDenomTrace takes a denom from IBC and queries the information about it

func (*Chain) QueryDenomTraces added in v0.6.0

func (c *Chain) QueryDenomTraces(pagereq *querytypes.PageRequest,
	height int64) (*transfertypes.QueryDenomTracesResponse, error)

QueryDenomTraces returns all the denom traces from a given chain

func (*Chain) QueryHeaderAtHeight

func (c *Chain) QueryHeaderAtHeight(height int64) (*tmclient.Header, error)

QueryHeaderAtHeight returns the header at a given height

func (*Chain) QueryHistoricalInfo added in v0.6.0

func (c *Chain) QueryHistoricalInfo(height clienttypes.Height) (*stakingtypes.QueryHistoricalInfoResponse, error)

QueryHistoricalInfo returns historical header data

func (*Chain) QueryLatestHeight

func (c *Chain) QueryLatestHeight() (int64, error)

QueryLatestHeight queries the chain for the latest height and returns it

func (*Chain) QueryNextSeqRecv

func (c *Chain) QueryNextSeqRecv(height int64) (recvRes *chantypes.QueryNextSequenceReceiveResponse, err error)

QueryNextSeqRecv returns the next seqRecv for a configured channel

func (*Chain) QueryPacketAcknowledgement added in v0.6.0

func (c *Chain) QueryPacketAcknowledgement(height int64,
	seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error)

QueryPacketAcknowledgement returns the packet ack proof at a given height

func (*Chain) QueryPacketAcknowledgements added in v0.6.0

func (c *Chain) QueryPacketAcknowledgements(pagereq *querytypes.PageRequest,
	height uint64) (comRes *chantypes.QueryPacketAcknowledgementsResponse, err error)

QueryPacketAcknowledgements returns an array of packet acks

func (*Chain) QueryPacketCommitment

func (c *Chain) QueryPacketCommitment(
	height int64, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error)

QueryPacketCommitment returns the packet commitment proof at a given height

func (*Chain) QueryPacketCommitments added in v0.6.0

func (c *Chain) QueryPacketCommitments(pagereq *querytypes.PageRequest,
	height uint64) (comRes *chantypes.QueryPacketCommitmentsResponse, err error)

QueryPacketCommitments returns an array of packet commitments

func (*Chain) QueryPacketReceipt added in v0.8.0

func (c *Chain) QueryPacketReceipt(height int64, seq uint64) (recRes *chantypes.QueryPacketReceiptResponse, err error)

QueryPacketReceipt returns the packet receipt proof at a given height

func (*Chain) QueryTMClientState added in v1.0.0

func (c *Chain) QueryTMClientState(height int64) (*tmclient.ClientState, error)

QueryTMClientState retrevies the latest consensus state for a client in state at a given height and unpacks/cast it to tendermint clientstate

func (*Chain) QueryTx

func (c *Chain) QueryTx(hashHex string) (*ctypes.ResultTx, error)

QueryTx takes a transaction hash and returns the transaction

func (*Chain) QueryTxs

func (c *Chain) QueryTxs(height uint64, page, limit int, events []string) ([]*ctypes.ResultTx, error)

QueryTxs returns an array of transactions given a tag

func (*Chain) QueryUnbondingPeriod added in v0.6.0

func (c *Chain) QueryUnbondingPeriod() (time.Duration, error)

QueryUnbondingPeriod returns the unbonding period of the chain

func (*Chain) QueryUnreceivedAcknowledgements added in v0.8.0

func (c *Chain) QueryUnreceivedAcknowledgements(height uint64, seqs []uint64) ([]uint64, error)

QueryUnreceivedAcknowledgements returns a list of unrelayed packet acks

func (*Chain) QueryUnreceivedPackets added in v0.8.0

func (c *Chain) QueryUnreceivedPackets(height uint64, seqs []uint64) ([]uint64, error)

QueryUnreceivedPackets returns a list of unrelayed packet commitments

func (*Chain) QueryUpgradeProof added in v0.7.0

func (c *Chain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height, error)

QueryUpgradeProof performs an abci query with the given key and returns the proto encoded merkle proof for the query and the height at which the proof will succeed on a tendermint verifier.

func (*Chain) QueryUpgradedClient added in v0.7.0

func (c *Chain) QueryUpgradedClient(height int64) (*codectypes.Any, []byte, clienttypes.Height, error)

QueryUpgradedClient returns upgraded client info

func (*Chain) QueryUpgradedConsState added in v0.7.0

func (c *Chain) QueryUpgradedConsState(height int64) (*codectypes.Any, []byte, clienttypes.Height, error)

QueryUpgradedConsState returns upgraded consensus state and height of client

func (*Chain) QueryValsetAtHeight added in v0.6.0

func (c *Chain) QueryValsetAtHeight(height clienttypes.Height) (*tmproto.ValidatorSet, error)

QueryValsetAtHeight returns the validator set at a given height

func (*Chain) QueryWithData

func (c *Chain) QueryWithData(p string, d []byte) (byt []byte, i int64, err error)

QueryWithData satisfies auth.NodeQuerier interface and used for fetching account details

func (*Chain) SendAndPrint

func (c *Chain) SendAndPrint(txs []sdk.Msg, text, indent bool) (err error)

SendAndPrint sends a transaction and prints according to the passed args

func (*Chain) SendMsg

func (c *Chain) SendMsg(datagram sdk.Msg) (*sdk.TxResponse, bool, error)

SendMsg wraps the msg in a stdtx, signs and sends it

func (*Chain) SendMsgWithKey added in v0.6.0

func (c *Chain) SendMsgWithKey(msg sdk.Msg, keyName string) (res *sdk.TxResponse, err error)

SendMsgWithKey allows the user to specify which relayer key will sign the message

func (*Chain) SendMsgs

func (c *Chain) SendMsgs(msgs []sdk.Msg) (*sdk.TxResponse, bool, error)

SendMsgs wraps the msgs in a StdTx, signs and sends it. An error is returned if there was an issue sending the transaction. A successfully sent, but failed transaction will not return an error. If a transaction is successfully sent, the result of the execution of that transaction will be logged. A boolean indicating if a transaction was successfully sent and executed successfully is returned.

func (*Chain) SendTransferMsg added in v0.6.0

func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr string, toHeightOffset uint64, toTimeOffset time.Duration) error

SendTransferMsg initiates an ibs20 transfer from src to dst with the specified args

func (*Chain) SetPath

func (c *Chain) SetPath(p *PathEnd) error

SetPath sets the path and validates the identifiers

func (*Chain) Start added in v0.6.0

func (c *Chain) Start() error

Start the client service

func (*Chain) StatusErr added in v0.6.0

func (c *Chain) StatusErr() error

StatusErr returns err unless the chain is ready to go

func (*Chain) String

func (c *Chain) String() string

func (*Chain) Subscribe

func (c *Chain) Subscribe(query string) (<-chan ctypes.ResultEvent, context.CancelFunc, error)

Subscribe returns channel of events given a query

func (*Chain) TxFactory added in v0.6.0

func (c *Chain) TxFactory(height int64) tx.Factory

TxFactory returns an instance of tx.Factory derived from

func (*Chain) Update

func (c *Chain) Update(key, value string) (out *Chain, err error)

Update returns a new chain with updated values

func (*Chain) UpdateClient added in v0.7.0

func (c *Chain) UpdateClient(dst *Chain, dsth *tmclient.Header) (sdk.Msg, error)

UpdateClient creates an sdk.Msg to update the client on src with data pulled from dst at the request height..

func (*Chain) UpdateClients added in v0.6.0

func (c *Chain) UpdateClients(dst *Chain) (err error)

UpdateClients updates clients for src on dst and dst on src given the configured paths

func (*Chain) UpgradeChain added in v0.7.0

func (c *Chain) UpgradeChain(dst *Chain, plan *upgradetypes.Plan, deposit sdk.Coin,
	unbondingPeriod time.Duration) error

UpgradeChain submits and upgrade proposal using a zero'd out client state with an updated unbonding period.

func (*Chain) UpgradeClients added in v0.7.0

func (c *Chain) UpgradeClients(dst *Chain, height int64) error

UpgradeClients upgrades the client on src after dst chain has undergone an upgrade.

func (*Chain) UseSDKContext added in v0.6.0

func (c *Chain) UseSDKContext() func()

UseSDKContext uses a custom Bech32 account prefix and returns a restore func CONTRACT: When using this function, caller must ensure that lock contention doesn't cause program to hang. This function is only for use in codec calls

func (*Chain) WaitForNBlocks added in v0.6.0

func (c *Chain) WaitForNBlocks(n int64) error

WaitForNBlocks blocks until the next block on a given chain

type Chains

type Chains []*Chain

Chains is a collection of Chain

func (Chains) Get

func (c Chains) Get(chainID string) (*Chain, error)

Get returns the configuration for a given chain

func (Chains) Gets

func (c Chains) Gets(chainIDs ...string) (map[string]*Chain, error)

Gets returns a map chainIDs to their chains

func (Chains) MustGet added in v0.6.0

func (c Chains) MustGet(chainID string) *Chain

MustGet returns the chain and panics on any error

type DeliverMsgsAction added in v0.6.0

type DeliverMsgsAction struct {
	SrcMsgs   []string `json:"src_msgs"`
	Src       PathEnd  `json:"src"`
	DstMsgs   []string `json:"dst_msgs"`
	Dst       PathEnd  `json:"dst"`
	Last      bool     `json:"last"`
	Succeeded bool     `json:"succeeded"`
	Type      string   `json:"type"`
}

DeliverMsgsAction is struct

type FaucetRequest added in v0.6.0

type FaucetRequest struct {
	ChainID string `json:"chain-id"`
	Address string `json:"address"`
}

FaucetRequest represents a request to the facuet

type NaiveStrategy

type NaiveStrategy struct {
	Ordered      bool
	MaxTxSize    uint64 // maximum permitted size of the msgs in a bundled relay transaction
	MaxMsgLength uint64 // maximum amount of messages in a bundled relay transaction
}

NaiveStrategy is an implementation of Strategy.

func (*NaiveStrategy) GetType

func (nrs *NaiveStrategy) GetType() string

GetType implements Strategy

func (*NaiveStrategy) HandleEvents added in v0.6.0

func (nrs *NaiveStrategy) HandleEvents(src, dst *Chain, srch, dsth int64, events map[string][]string)

HandleEvents defines how the relayer will handle block and transaction events as they are emitted

func (*NaiveStrategy) RelayAcknowledgements added in v0.6.0

func (nrs *NaiveStrategy) RelayAcknowledgements(src, dst *Chain, sp *RelaySequences) error

RelayAcknowledgements creates transactions to relay acknowledgements from src to dst and from dst to src

func (*NaiveStrategy) RelayPackets added in v0.6.0

func (nrs *NaiveStrategy) RelayPackets(src, dst *Chain, sp *RelaySequences) error

RelayPackets creates transactions to relay packets from src to dst and from dst to src

func (*NaiveStrategy) UnrelayedAcknowledgements added in v0.6.0

func (nrs *NaiveStrategy) UnrelayedAcknowledgements(src, dst *Chain) (*RelaySequences, error)

UnrelayedAcknowledgements returns the unrelayed sequence numbers between two chains

func (*NaiveStrategy) UnrelayedSequences added in v0.6.0

func (nrs *NaiveStrategy) UnrelayedSequences(src, dst *Chain) (*RelaySequences, error)

UnrelayedSequences returns the unrelayed sequence numbers between two chains

type Path

type Path struct {
	Src      *PathEnd     `yaml:"src" json:"src"`
	Dst      *PathEnd     `yaml:"dst" json:"dst"`
	Strategy *StrategyCfg `yaml:"strategy" json:"strategy"`
}

Path represents a pair of chains and the identifiers needed to relay over them

func GenPath added in v0.6.0

func GenPath(srcChainID, dstChainID, srcPortID, dstPortID, order string, version string) *Path

GenPath generates a path with unspecified client, connection and channel identifiers given chainIDs and portIDs.

func (*Path) End

func (p *Path) End(chainID string) *PathEnd

End returns the proper end given a chainID

func (*Path) GetStrategy

func (p *Path) GetStrategy() (Strategy, error)

GetStrategy the strategy defined in the relay messages

func (*Path) MustGetStrategy added in v0.6.0

func (p *Path) MustGetStrategy() Strategy

MustGetStrategy returns the strategy and panics on error

func (*Path) MustYAML

func (p *Path) MustYAML() string

MustYAML returns the yaml string representation of the Path

func (*Path) Ordered added in v0.6.0

func (p *Path) Ordered() bool

Ordered returns true if the path is ordered and false if otherwise

func (*Path) QueryPathStatus added in v0.6.0

func (p *Path) QueryPathStatus(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) String

func (p *Path) String() string

type PathAction added in v0.6.0

type PathAction struct {
	*Path
	Type string `json:"type"`
}

PathAction is struct

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"`
	ChannelID    string `yaml:"channel-id,omitempty" json:"channel-id,omitempty"`
	PortID       string `yaml:"port-id,omitempty" json:"port-id,omitempty"`
	Order        string `yaml:"order,omitempty" json:"order,omitempty"`
	Version      string `yaml:"version,omitempty" json:"version,omitempty"`
}

PathEnd represents the local connection identifers for a relay path The path is set on the chain before performing operations

func MarshalChain added in v0.6.0

func MarshalChain(c *Chain) PathEnd

MarshalChain is PathEnd

func (*PathEnd) GetOrder added in v0.6.0

func (pe *PathEnd) GetOrder() chantypes.Order

GetOrder returns the channel order for the path end

func (*PathEnd) NewPacket

func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte,
	timeoutHeight clienttypes.Height, timeoutStamp uint64) chantypes.Packet

NewPacket returns a new packet from src to dist w

func (PathEnd) String

func (pe PathEnd) String() string

func (*PathEnd) ValidateBasic added in v0.7.0

func (pe *PathEnd) ValidateBasic() error

ValidateBasic validates fields that cannot be empty such as the port and channel order.

func (*PathEnd) ValidateFull added in v0.7.0

func (pe *PathEnd) ValidateFull() error

ValidateFull returns errors about invalid identifiers as well as unset path variables for the appropriate type

func (*PathEnd) Vchan

func (pe *PathEnd) Vchan() error

Vchan validates the channel identifier in the path

func (*PathEnd) Vclient

func (pe *PathEnd) Vclient() error

Vclient validates the client identifier in the path

func (*PathEnd) Vconn

func (pe *PathEnd) Vconn() error

Vconn validates the connection identifier in the path

func (*PathEnd) Vport

func (pe *PathEnd) Vport() error

Vport validates the port identifier in the path

func (*PathEnd) Vversion added in v0.6.0

func (pe *PathEnd) Vversion() error

Vversion validates the version identifier in the path

func (*PathEnd) XferPacket

func (pe *PathEnd) XferPacket(amount sdk.Coin, sender, receiver string) []byte

XferPacket creates a new transfer packet

type PathStatus added in v0.6.0

type PathStatus struct {
	Chains     bool `yaml:"chains" json:"chains"`
	Clients    bool `yaml:"clients" json:"clients"`
	Connection bool `yaml:"connection" json:"connection"`
	Channel    bool `yaml:"channel" json:"channel"`
}

PathStatus holds the status of the primitives in the path

type PathWithStatus added in v0.6.0

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 added in v0.6.0

func (ps *PathWithStatus) PrintString(name string) string

PrintString prints a string representations of the path status

type Paths

type Paths map[string]*Path

Paths represent connection paths between chains

func (Paths) Add

func (p Paths) Add(name string, path *Path) error

Add adds a path by its name

func (Paths) Get

func (p Paths) Get(name string) (path *Path, err error)

Get returns the configuration for a given path

func (Paths) MustGet added in v0.6.0

func (p Paths) MustGet(name string) *Path

MustGet panics if path is not found

func (Paths) MustYAML

func (p Paths) MustYAML() string

MustYAML returns the yaml string representation of the Paths

func (Paths) PathsFromChains

func (p Paths) PathsFromChains(src, dst string) (Paths, error)

PathsFromChains returns a path from the config between two chains

type ProtoCodec added in v0.6.0

type ProtoCodec struct {
	// contains filtered or unexported fields
}

ProtoCodec defines a codec that utilizes Protobuf for both binary and JSON encoding.

func (*ProtoCodec) InterfaceRegistry added in v0.6.0

func (pc *ProtoCodec) InterfaceRegistry() types.InterfaceRegistry

InterfaceRegistry returns the ProtoCodec interfaceRegistry

func (*ProtoCodec) Marshal added in v1.0.0

func (pc *ProtoCodec) Marshal(o codec.ProtoMarshaler) ([]byte, error)

Marshal implements BinaryCodec.Marshal method.

func (*ProtoCodec) MarshalInterface added in v0.7.0

func (pc *ProtoCodec) MarshalInterface(i proto.Message) ([]byte, error)

MarshalInterface is a convenience function for proto marshalling interfaces. It packs the provided value, which must be an interface, in an Any and then marshals it to bytes. NOTE: to marshal a concrete type, you should use Marshal instead

func (*ProtoCodec) MarshalInterfaceJSON added in v0.7.0

func (pc *ProtoCodec) MarshalInterfaceJSON(x proto.Message) ([]byte, error)

MarshalInterfaceJSON is a convenience function for proto marshalling interfaces. It packs the provided value in an Any and then marshals it to bytes. NOTE: to marshal a concrete type, you should use MarshalJSON instead

func (*ProtoCodec) MarshalJSON added in v0.6.0

func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error)

MarshalJSON implements JSONCodec.MarshalJSON method, it marshals to JSON using proto codec.

func (*ProtoCodec) MarshalLengthPrefixed added in v1.0.0

func (pc *ProtoCodec) MarshalLengthPrefixed(o codec.ProtoMarshaler) ([]byte, error)

MarshalLengthPrefixed implements BinaryCodec.MarshalLengthPrefixed method.

func (*ProtoCodec) MustMarshal added in v1.0.0

func (pc *ProtoCodec) MustMarshal(o codec.ProtoMarshaler) []byte

MustMarshal implements BinaryCodec.MustMarshal method.

func (*ProtoCodec) MustMarshalJSON added in v0.6.0

func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte

MustMarshalJSON implements JSONCodec.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure.

func (*ProtoCodec) MustMarshalLengthPrefixed added in v1.0.0

func (pc *ProtoCodec) MustMarshalLengthPrefixed(o codec.ProtoMarshaler) []byte

MustMarshalLengthPrefixed implements BinaryCodec.MustMarshalLengthPrefixed method.

func (*ProtoCodec) MustUnmarshal added in v1.0.0

func (pc *ProtoCodec) MustUnmarshal(bz []byte, ptr codec.ProtoMarshaler)

MustUnmarshal implements BinaryCodec.MustUnmarshal method.

func (*ProtoCodec) MustUnmarshalJSON added in v0.6.0

func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)

MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure.

func (*ProtoCodec) MustUnmarshalLengthPrefixed added in v1.0.0

func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler)

MustUnmarshalLengthPrefixed implements BinaryCodec.MustUnmarshalLengthPrefixed method.

func (*ProtoCodec) Unmarshal added in v1.0.0

func (pc *ProtoCodec) Unmarshal(bz []byte, ptr codec.ProtoMarshaler) error

Unmarshal implements BinaryMarshaler.Unmarshal method.

func (*ProtoCodec) UnmarshalInterface added in v0.7.0

func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error

UnmarshalInterface is a convenience function for proto unmarshaling interfaces. It unmarshals an Any from bz bytes and then unpacks it to the `ptr`, which must be a pointer to a non empty interface with registered implementations. NOTE: to unmarshal a concrete type, you should use Unmarshal instead

Example:

var x MyInterface
err := cdc.UnmarshalInterface(bz, &x)

func (*ProtoCodec) UnmarshalInterfaceJSON added in v0.7.0

func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error

UnmarshalInterfaceJSON is a convenience function for proto unmarshaling interfaces. It unmarshals an Any from bz bytes and then unpacks it to the `iface`, which must be a pointer to a non empty interface, implementing proto.Message with registered implementations. NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead

Example:

var x MyInterface  // must implement proto.Message
err := cdc.UnmarshalInterfaceJSON(&x, bz)

func (*ProtoCodec) UnmarshalJSON added in v0.6.0

func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error

UnmarshalJSON implements JSONCodec.UnmarshalJSON method, it unmarshals from JSON using proto codec.

func (*ProtoCodec) UnmarshalLengthPrefixed added in v1.0.0

func (pc *ProtoCodec) UnmarshalLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler) error

UnmarshalLengthPrefixed implements BinaryCodec.UnmarshalLengthPrefixed method.

func (*ProtoCodec) UnpackAny added in v0.6.0

func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error

UnpackAny implements AnyUnpacker.UnpackAny method, it unpacks the value in any to the interface pointer passed in as iface.

type RelayMsgs

type RelayMsgs struct {
	Src          []sdk.Msg `json:"src"`
	Dst          []sdk.Msg `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

	Last      bool `json:"last"`
	Succeeded bool `json:"success"`
}

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 NewRelayMsgs added in v0.6.0

func NewRelayMsgs() *RelayMsgs

NewRelayMsgs returns an initialized version of relay messages

func (*RelayMsgs) IsMaxTx added in v0.6.0

func (r *RelayMsgs) IsMaxTx(msgLen, txSize uint64) bool

func (*RelayMsgs) Ready

func (r *RelayMsgs) Ready() bool

Ready returns true if there are messages to relay

func (*RelayMsgs) Send

func (r *RelayMsgs) Send(src, dst *Chain)

Send sends the messages with appropriate output TODO: Parallelize? Maybe?

func (*RelayMsgs) SendWithController added in v0.6.0

func (r *RelayMsgs) SendWithController(src, dst *Chain, useController bool)

func (*RelayMsgs) Success

func (r *RelayMsgs) Success() bool

Success returns the success var

type RelaySequences added in v0.6.0

type RelaySequences struct {
	Src []uint64 `json:"src"`
	Dst []uint64 `json:"dst"`
}

RelaySequences represents unrelayed packets on src and dst

type Strategy

type Strategy interface {
	GetType() string
	HandleEvents(src, dst *Chain, srch, dsth int64, events map[string][]string)
	UnrelayedSequences(src, dst *Chain) (*RelaySequences, error)
	UnrelayedAcknowledgements(src, dst *Chain) (*RelaySequences, error)
	RelayPackets(src, dst *Chain, sp *RelaySequences) error
	RelayAcknowledgements(src, dst *Chain, sp *RelaySequences) error
}

Strategy defines

type StrategyCfg

type StrategyCfg struct {
	Type string `json:"type" yaml:"type"`
}

StrategyCfg defines which relaying strategy to take for a given path

func NewNaiveStrategy

func NewNaiveStrategy() *StrategyCfg

NewNaiveStrategy returns the proper config for the NaiveStrategy

Jump to

Keyboard shortcuts

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