relayer

package
v0.0.0-...-b432578 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLightNotInitialized = errors.New("light client is not initialized")

ErrLightNotInitialized returns the canonical error for a an uninitialized light client

Functions

func CreateMnemonic

func CreateMnemonic() (string, error)

CreateMnemonic creates a new mnemonic

func GenerateRandomBytes

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

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 InjectTrustedFields

func InjectTrustedFields(srcChain, dstChain *Chain, srcHeader *tmclient.Header) (*tmclient.Header, error)

InjectTrustedFields injects the necessary trusted fields for a srcHeader coming from a srcChain destined for an IBC client stored on the dstChain TrustedHeight is the latest height of the IBC client on dstChain TrustedValidators is the validator set of srcChain at the TrustedHeight InjectTrustedFields returns a copy of the header with TrustedFields modified

func InjectTrustedFieldsHeaders

func InjectTrustedFieldsHeaders(
	src, dst *Chain,
	srch, dsth *tmclient.Header) (srcho *tmclient.Header, dstho *tmclient.Header, err error)

InjectTrustedFieldsHeaders takes the headers and enriches them

func MustGetHeight

func MustGetHeight(h clientExported.Height) uint64

MustGetHeight takes the height inteface and returns the actual height

func OrderFromString

func OrderFromString(order string) chanTypes.Order

OrderFromString parses a string into a channel order byte

func ParseEvents

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 QueryClientConsensusStatePair

func QueryClientConsensusStatePair(
	src, dst *Chain,
	srch, dsth, srcClientConsH,
	dstClientConsH int64) (srcCsRes, dstCsRes *clientTypes.QueryConsensusStateResponse, err error)

QueryClientConsensusStatePair allows for the querying of multiple client states at the same time

func QueryClientStatePair

func QueryClientStatePair(
	src, dst *Chain,
	srch, dsth int64) (srcCsRes, dstCsRes *clientTypes.QueryClientStateResponse, err error)

QueryClientStatePair returns a pair of connection 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

func RandLowerCaseLetterString(length int) string

RandLowerCaseLetterString returns a lowercase letter string of given length

func RunStrategy

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

RunStrategy runs a given strategy

func UpdatesWithHeaders

func UpdatesWithHeaders(src, dst *Chain) (srch, dsth *tmclient.Header, err error)

UpdatesWithHeaders calls UpdateLightWithHeader on the passed chains concurrently

func ValidatePaths

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"`
	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:"-"`
	Cdc      codec.JSONMarshaler `yaml:"-" json:"-"`
	Amino    *codec.LegacyAmino  `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

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

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

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

CLIContext returns an instance of client.Context derived from Chain

func (*Chain) CloseChannel

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

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) CreateChannel

func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error

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

func (*Chain) CreateChannelStep

func (c *Chain) CreateChannelStep(dst *Chain, ordering chanTypes.Order) (*RelayMsgs, error)

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

func (*Chain) CreateClients

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

CreateClients creates clients for src on dst and dst on src given the configured paths

func (*Chain) CreateConnection

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

CreateConnection runs the connection creation messages on timeout until they pass TODO: add max retries or something to this function

func (*Chain) CreateConnectionStep

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

CreateConnectionStep returns the next set of messags for creating a channel with the given identifier between chains src and dst. If handshake hasn't started, CreateConnetionStep will start the handshake on src

func (*Chain) CreateTestKey

func (c *Chain) CreateTestKey() error

CreateTestKey creates a key for test chain

func (*Chain) DeleteLightDB

func (c *Chain) DeleteLightDB() error

DeleteLightDB removes the light client database on disk, forcing re-initialization

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

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

FaucetHandler listens for addresses

func (*Chain) ForceInitLight

func (c *Chain) ForceInitLight() error

ForceInitLight forces initialization of the light client from the configured node

func (*Chain) GetAddress

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

GetAddress returns the sdk.AccAddress associated with the configred key

func (*Chain) GetLatestLightHeader

func (c *Chain) GetLatestLightHeader() (*tmclient.Header, error)

GetLatestLightHeader returns the header to be used for client creation

func (*Chain) GetLatestLightHeight

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

GetLatestLightHeight uses the CLI utilities to pull the latest height from a given chain

func (*Chain) GetLightSignedHeaderAtHeight

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

GetLightSignedHeaderAtHeight returns a signed header at a particular height.

func (*Chain) GetRPCPort

func (c *Chain) GetRPCPort() string

GetRPCPort returns the port configured for the chain

func (*Chain) GetTimeout

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, 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) KeyExists

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

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

func (*Chain) LightClient

func (c *Chain) LightClient(db dbm.DB) (*light.Client, error)

LightClient initializes the light client for a given chain from the trusted store in the database this should be call for all other light client usage

func (*Chain) LightClientWithTrust

func (c *Chain) LightClientWithTrust(db dbm.DB, to light.TrustOptions) (*light.Client, error)

LightClientWithTrust takes a header from the chain and attempts to add that header to the light database.

func (*Chain) LightClientWithoutTrust

func (c *Chain) LightClientWithoutTrust(db dbm.DB) (*light.Client, error)

LightClientWithoutTrust querys the latest header from the chain and initializes a new light client database using that header. This should only be called when first initializing the light client

func (*Chain) LightHTTP

func (c *Chain) LightHTTP() lightp.Provider

LightHTTP returns the http client for light clients

func (*Chain) ListenRPCEmitJSON

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) MustGetAddress

func (c *Chain) MustGetAddress() sdk.AccAddress

MustGetAddress used for brevity

func (*Chain) NewLightDB

func (c *Chain) NewLightDB() (db *dbm.GoLevelDB, df func(), err error)

NewLightDB returns a new instance of the lightclient database connection CONTRACT: must close the database connection when done with it (defer df())

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 interface{}, 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

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) QueryChannel

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

QueryChannel returns the channel associated with a channelID

func (*Chain) QueryChannelClient

func (c *Chain) QueryChannelClient() (*chanTypes.QueryChannelClientStateResponse, error)

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

func (*Chain) QueryChannels

func (c *Chain) QueryChannels(offset, limit uint64) (*chanTypes.QueryChannelsResponse, error)

QueryChannels returns all the channels that are registered on a chain

func (*Chain) QueryClientConsensusState

func (c *Chain) QueryClientConsensusState(
	height, dstClientConsHeight int64) (*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) (*clientTypes.QueryClientStateResponse, error)

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

func (*Chain) QueryClients

func (c *Chain) QueryClients(offset, limit uint64) (*clientTypes.QueryClientStatesResponse, error)

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

func (c *Chain) QueryConnectionChannels(
	connectionID string,
	offset, limit uint64) (*chanTypes.QueryConnectionChannelsResponse, error)

QueryConnectionChannels queries the channels associated with a connection

func (*Chain) QueryConnections

func (c *Chain) QueryConnections(
	offset, limit uint64) (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

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

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

func (*Chain) QueryDenomTraces

func (c *Chain) QueryDenomTraces(offset, limit uint64) (*xferTypes.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

func (c *Chain) QueryHistoricalInfo(height clientTypes.Height) (*stakingTypes.QueryHistoricalInfoResponse, error)

QueryHistoricalInfo returns historical header data

func (*Chain) QueryLatestHeader

func (c *Chain) QueryLatestHeader() (out *tmclient.Header, err error)

QueryLatestHeader returns the latest header from the chain

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) 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

func (c *Chain) QueryPacketCommitments(
	offset, limit, height uint64) (comRes *chanTypes.QueryPacketCommitmentsResponse, err error)

QueryPacketCommitments returns an array of packet commitment proofs

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

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

QueryUnbondingPeriod returns the unbonding period of the chain

func (*Chain) QueryUnrecievedPackets

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

QueryUnrecievedPackets returns a list of unrelayed packet commitments

func (*Chain) QueryUnrelayedAcks

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

QueryUnrelayedAcks returns a list of unrelayed packet acks

func (*Chain) QueryValsetAtHeight

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, error)

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

func (*Chain) SendMsgWithKey

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) (res *sdk.TxResponse, err error)

SendMsgs wraps the msgs in a stdtx, signs and sends it

func (*Chain) SendTransferMsg

func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringer) 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

func (c *Chain) Start() error

Start the client service

func (*Chain) StatusErr

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) TrustOptions

func (c *Chain) TrustOptions(height int64, hash []byte) light.TrustOptions

TrustOptions returns light.TrustOptions given a height and hash

func (*Chain) TxFactory

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) UpdateClients

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) UpdateLightWithHeader

func (c *Chain) UpdateLightWithHeader() (*tmclient.Header, error)

UpdateLightWithHeader calls client.Update and then .

func (*Chain) UseSDKContext

func (c *Chain) UseSDKContext()

UseSDKContext uses a custom Bech32 account prefix and returns a restore func

func (*Chain) ValidateTxResult

func (c *Chain) ValidateTxResult(resTx *ctypes.ResultTx) (err error)

ValidateTxResult takes a transaction and validates the proof against a stored root of trust

func (*Chain) VerifyProof

func (c *Chain) VerifyProof(queryPath string, resp abci.ResponseQuery) error

VerifyProof performs response proof verification.

func (*Chain) WaitForNBlocks

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

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

MustGet returns the chain and panics on any error

type FaucetRequest

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

func (nrs *NaiveStrategy) HandleEvents(src, dst *Chain, sh *SyncHeaders, events map[string][]string)

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

func (*NaiveStrategy) RelayPacketsOrderedChan

func (nrs *NaiveStrategy) RelayPacketsOrderedChan(src, dst *Chain, sp *RelaySequences, sh *SyncHeaders) error

RelayPacketsOrderedChan creates transactions to clear both queues CONTRACT: the SyncHeaders passed in here must be up to date or being kept updated

func (*NaiveStrategy) RelayPacketsUnorderedChan

func (nrs *NaiveStrategy) RelayPacketsUnorderedChan(src, dst *Chain, sp *RelaySequences, sh *SyncHeaders) error

RelayPacketsUnorderedChan creates transactions to relay un-relayed messages

func (*NaiveStrategy) UnrelayedSequencesOrdered

func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error)

UnrelayedSequencesOrdered returns the unrelayed sequence numbers between two chains

func (*NaiveStrategy) UnrelayedSequencesUnordered

func (nrs *NaiveStrategy) UnrelayedSequencesUnordered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error)

UnrelayedSequencesUnordered 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

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

GenPath generates a path with random 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

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

func (p *Path) Ordered() bool

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

func (*Path) String

func (p *Path) String() string

func (*Path) Validate

func (p *Path) Validate() (err error)

Validate checks that a path is valid

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 (*PathEnd) ChanAck

func (pe *PathEnd) ChanAck(dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg

ChanAck creates a MsgChannelOpenAck

func (*PathEnd) ChanCloseConfirm

func (pe *PathEnd) ChanCloseConfirm(dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg

ChanCloseConfirm creates a MsgChannelCloseConfirm

func (*PathEnd) ChanCloseInit

func (pe *PathEnd) ChanCloseInit(signer sdk.AccAddress) sdk.Msg

ChanCloseInit creates a MsgChannelCloseInit

func (*PathEnd) ChanConfirm

func (pe *PathEnd) ChanConfirm(dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg

ChanConfirm creates a MsgChannelOpenConfirm

func (*PathEnd) ChanInit

func (pe *PathEnd) ChanInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg

ChanInit creates a MsgChannelOpenInit

func (*PathEnd) ChanTry

func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg

ChanTry creates a MsgChannelOpenTry

func (*PathEnd) ConnAck

func (pe *PathEnd) ConnAck(
	dst *PathEnd,
	dstClientState *clientTypes.QueryClientStateResponse,
	dstConnState *connTypes.QueryConnectionResponse,
	dstConsState *clientTypes.QueryConsensusStateResponse,
	signer sdk.AccAddress,
) sdk.Msg

ConnAck creates a MsgConnectionOpenAck NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE

func (*PathEnd) ConnConfirm

func (pe *PathEnd) ConnConfirm(dstConnState *connTypes.QueryConnectionResponse, signer sdk.AccAddress) sdk.Msg

ConnConfirm creates a MsgConnectionOpenAck NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE

func (*PathEnd) ConnInit

func (pe *PathEnd) ConnInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg

ConnInit creates a MsgConnectionOpenInit

func (*PathEnd) ConnTry

func (pe *PathEnd) ConnTry(
	dst *PathEnd,
	dstClientState *clientTypes.QueryClientStateResponse,
	dstConnState *connTypes.QueryConnectionResponse,
	dstConsState *clientTypes.QueryConsensusStateResponse,
	signer sdk.AccAddress,
) sdk.Msg

ConnTry creates a MsgConnectionOpenTry NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE

func (*PathEnd) CreateClient

func (pe *PathEnd) CreateClient(
	dstHeader *tmclient.Header,
	trustingPeriod, unbondingPeriod time.Duration,
	signer sdk.AccAddress) sdk.Msg

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

func (*PathEnd) MsgTransfer

func (pe *PathEnd) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string,
	signer sdk.AccAddress, timeoutHeight, timeoutTimestamp uint64) sdk.Msg

MsgTransfer creates a new transfer message

func (*PathEnd) NewPacket

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

NewPacket returns a new packet from src to dist w

func (PathEnd) String

func (pe PathEnd) String() string

func (*PathEnd) UpdateClient

func (pe *PathEnd) UpdateClient(dstHeader exported.Header, signer sdk.AccAddress) sdk.Msg

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

func (*PathEnd) Validate

func (pe *PathEnd) Validate() error

Validate 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) XferPacket

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

XferPacket creates a new transfer packet

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) AddForce

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

AddForce ignores existing paths and overwrites an existing path with that 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

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 RelayMsgs

type RelayMsgs struct {
	Src          []sdk.Msg
	Dst          []sdk.Msg
	MaxTxSize    uint64 // maximum permitted size of the msgs in a bundled relay transaction
	MaxMsgLength uint64 // maximum amount of messages in a bundled relay transaction
	// contains filtered or unexported fields
}

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

func NewRelayMsgs() *RelayMsgs

NewRelayMsgs returns an initialized version of relay messages

func (*RelayMsgs) IsMaxTx

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) Success

func (r *RelayMsgs) Success() bool

Success returns the success var

type RelaySequences

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, sh *SyncHeaders, events map[string][]string)
	UnrelayedSequencesUnordered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error)
	UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error)
	RelayPacketsOrderedChan(src, dst *Chain, sp *RelaySequences, sh *SyncHeaders) error
	RelayPacketsUnorderedChan(src, dst *Chain, sp *RelaySequences, sh *SyncHeaders) 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

type SyncHeaders

type SyncHeaders struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SyncHeaders is an instance of map[string]*tmclient.Header that can be kept "reasonably up to date" using it's Update method

func NewSyncHeaders

func NewSyncHeaders(src, dst *Chain) (*SyncHeaders, error)

NewSyncHeaders returns a new instance of map[string]*tmclient.Header that can be easily kept "reasonably up to date"

func (*SyncHeaders) GetHeader

func (uh *SyncHeaders) GetHeader(chainID string) *tmclient.Header

GetHeader returns the latest header for a given chainID

func (*SyncHeaders) GetHeight

func (uh *SyncHeaders) GetHeight(chainID string) uint64

GetHeight returns the latest height for a given chainID

func (*SyncHeaders) GetTrustedHeaders

func (uh *SyncHeaders) GetTrustedHeaders(src, dst *Chain) (srcTh, dstTh *tmclient.Header, err error)

GetTrustedHeaders returns the trusted headers for the current headers stored in SyncHeaders

func (*SyncHeaders) GetUpdateHeader

func (uh *SyncHeaders) GetUpdateHeader(srcChain, dstChain *Chain) (*tmclient.Header, error)

GetUpdateHeader returns a header to be used to UpdateClient of dstChain stored on srcChain

func (*SyncHeaders) Update

func (uh *SyncHeaders) Update(c *Chain) error

Update the header for a given chain

func (*SyncHeaders) UpdateWithTrustedHeaders

func (uh *SyncHeaders) UpdateWithTrustedHeaders(src, dst *Chain) (srcTh, dstTh *tmclient.Header, err error)

UpdateWithTrustedHeaders updates the latest headers in SyncHeaders

func (*SyncHeaders) Updates

func (uh *SyncHeaders) Updates(c ...*Chain) error

Updates updates the headers for a given set of chains

Jump to

Keyboard shortcuts

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