Documentation ¶
Index ¶
- Constants
- Variables
- func AutoUpdateClient(src, dst *Chain, thresholdTime time.Duration) (time.Duration, error)
- func CastClientStateToTMType(cs *codectypes.Any) (*ibctmtypes.ClientState, error)
- func DefaultChainLogger() log.Logger
- func ExecuteChannelStep(src, dst *Chain) (success, last, modified bool, err error)
- func ExecuteConnectionStep(src, dst *Chain) (success, last, modified bool, err error)
- func FindMatchingChannel(source, counterparty *Chain) (string, bool)
- func FindMatchingClient(source, counterparty *Chain, clientState *ibctmtypes.ClientState) (string, bool)
- func FindMatchingConnection(source, counterparty *Chain) (string, bool)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func GetIBCCreateClientHeaders(src, dst *Chain) (srcHeader, dstHeader *tmclient.Header, err error)
- func GetIBCUpdateHeaders(src, dst *Chain) (srcHeader, dstHeader *tmclient.Header, err error)
- func GetLatestLightHeights(src, dst *Chain) (srch int64, dsth int64, err error)
- func InitializeChannel(src, dst *Chain) (success, modified bool, err error)
- func InitializeConnection(src, dst *Chain) (success, modified bool, err error)
- func IsConnectionFound(connectionHops []string, connectionID string) bool
- func IsMatchingChannel(source, counterparty *Chain, channel *chantypes.IdentifiedChannel) bool
- func IsMatchingClient(clientStateA, clientStateB ibctmtypes.ClientState) bool
- func IsMatchingConnection(source, counterparty *Chain, connection *conntypes.IdentifiedConnection) bool
- func IsMatchingConsensusState(consensusStateA, consensusStateB *ibctmtypes.ConsensusState) bool
- func KeysDir(home, chainID string) string
- func Link(src, dst *Chain, retries uint64, to time.Duration) error
- func MustGetHeight(h ibcexported.Height) clienttypes.Height
- func OrderFromString(order string) chantypes.Order
- func ParseChannelIDFromEvents(events sdk.StringEvents) (string, error)
- func ParseClientIDFromEvents(events sdk.StringEvents) (string, error)
- func ParseConnectionIDFromEvents(events sdk.StringEvents) (string, error)
- func PathsSet(chains ...*Chain) bool
- func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (srcChan, dstChan *chantypes.QueryChannelResponse, err error)
- func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *conntypes.QueryConnectionResponse, err error)
- func RandLowerCaseLetterString(length int) string
- func RunStrategy(src, dst *Chain, strategy Strategy) (func(), error)
- func UpdateLightClients(src, dst *Chain) (srcLB, dstLB *tmtypes.LightBlock, err error)
- func ValidateChannelParams(src, dst *Chain) error
- func ValidateClientPaths(src, dst *Chain) error
- func ValidateConnectionPaths(src, dst *Chain) error
- type Chain
- func (c *Chain) AddPath(clientID, connectionID, channelID, port, order string) error
- func (c *Chain) CLIContext(height int64) sdkCtx.Context
- func (c *Chain) CLICosmosContext(height int64) cosmosSdkCtx.Context
- func (c *Chain) ChanAck(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) ChanConfirm(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) ChanInit(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) ChanTry(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) ConnAck(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) ConnConfirm(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) ConnInit(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) ConnTry(counterparty *Chain) ([]sdk.Msg, error)
- func (c *Chain) CreateClient(clientState *tmclient.ClientState, dstHeader *tmclient.Header) sdk.Msg
- func (c *Chain) CreateClients(dst *Chain) (modified bool, err error)
- func (c *Chain) CreateOpenChannels(dst *Chain, maxRetries uint64, to time.Duration) (modified bool, err error)
- func (c *Chain) CreateOpenConnections(dst *Chain, maxRetries uint64, to time.Duration) (modified bool, err error)
- func (c *Chain) DeleteLightDB() error
- func (c *Chain) ErrCantSetPath(err error) error
- func (c *Chain) ErrPathNotSet() error
- func (c *Chain) Error(err error)
- func (c *Chain) GenerateConnHandshakeProof(height uint64) (clientState ibcexported.ClientState, clientStateProof []byte, ...)
- func (c *Chain) GetAddress() (sdk.AccAddress, error)
- func (c *Chain) GetAddressString() (string, error)
- func (c *Chain) GetIBCCreateClientHeader() (*tmclient.Header, error)
- func (c *Chain) GetIBCUpdateHeader(dst *Chain) (*tmclient.Header, error)
- func (c *Chain) GetLatestLightHeader() (*tmclient.Header, error)
- func (c *Chain) GetLatestLightHeight() (int64, error)
- func (c *Chain) GetLightSignedHeaderAtHeight(height int64) (*tmclient.Header, error)
- func (c *Chain) GetTrustingPeriod() time.Duration
- func (c *Chain) HealthCheck() error
- func (c *Chain) ImportKey() error
- func (c *Chain) Init(homePath string, timeout time.Duration, logger log.Logger, debug bool) error
- func (c *Chain) InjectTrustedFields(dst *Chain, header *tmclient.Header) (*tmclient.Header, error)
- func (c *Chain) KeyExists(name string) bool
- func (c *Chain) LightClient(db dbm.DB) (*light.Client, error)
- func (c *Chain) LightClientWithoutTrust(db dbm.DB) (*light.Client, error)
- func (c *Chain) LightHTTP() lightp.Provider
- func (c *Chain) Log(s string)
- func (c *Chain) LogFailedTx(res *sdk.TxResponse, err error, msgs []sdk.Msg)
- func (c *Chain) LogSuccessTx(res *sdk.TxResponse, msgs []sdk.Msg)
- func (c *Chain) MakeCosmosEncodingConfig() params.EncodingConfig
- func (c *Chain) MakeEncodingConfig() types2.EncodingConfig
- func (c *Chain) MsgRelayRecvPacket(counterparty *Chain, packet *relayMsgRecvPacket) (msgs []sdk.Msg, err error)
- func (c *Chain) MsgRelayTimeout(counterparty *Chain, packet *relayMsgTimeout) (msgs []sdk.Msg, err error)
- func (c *Chain) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string, ...) sdk.Msg
- func (c *Chain) MustGetAddress() sdk.AccAddress
- func (c *Chain) MustGetAddressString() string
- func (c *Chain) MustGetLatestLightHeight() uint64
- func (c *Chain) NewLightDB() (db *dbm.GoLevelDB, df func(), err error)
- func (c *Chain) NewProtoCodec(interfaceRegistry types.InterfaceRegistry, accountPrefix string) *ProtoCodec
- func (c *Chain) PathSet() bool
- func (c *Chain) Print(toPrint interface{}, text, indent bool) error
- func (c *Chain) QueryBalanceWithAddress(address sdk.AccAddress) (sdk.Coins, error)
- func (c *Chain) QueryChannel(height int64) (chanRes *chantypes.QueryChannelResponse, err error)
- func (c *Chain) QueryChannels(offset, limit uint64) (*chantypes.QueryChannelsResponse, error)
- func (c *Chain) QueryClientConsensusState(height int64, dstClientConsHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)
- func (c *Chain) QueryClientState(height int64) (*clienttypes.QueryClientStateResponse, error)
- func (c *Chain) QueryClients(offset, limit uint64) (*clienttypes.QueryClientStatesResponse, error)
- func (c *Chain) QueryConnection(height int64) (*conntypes.QueryConnectionResponse, error)
- func (c *Chain) QueryConnections(offset, limit uint64) (*conntypes.QueryConnectionsResponse, error)
- func (c *Chain) QueryDenomTraces(offset, limit uint64, height int64) (*transfertypes.QueryDenomTracesResponse, error)
- func (c *Chain) QueryLatestHeight() (int64, error)
- func (c *Chain) QueryNonce() (uint64, error)
- func (c *Chain) QueryPacketAcknowledgement(height int64, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error)
- func (c *Chain) QueryPacketCommitment(height int64, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error)
- func (c *Chain) QueryPacketCommitments(offset, limit, height uint64) (comRes *chantypes.QueryPacketCommitmentsResponse, err error)
- func (c *Chain) QueryPacketReceipt(height int64, seq uint64) (recRes *chantypes.QueryPacketReceiptResponse, err error)
- func (c *Chain) QueryTxs(height uint64, page, limit int, events []string) ([]*ctypes.ResultTx, error)
- func (c *Chain) QueryUnbondingPeriod() (time.Duration, error)
- func (c *Chain) QueryUnreceivedPackets(height uint64, seqs []uint64) ([]uint64, error)
- func (c *Chain) SendMsg(datagram sdk.Msg) (*sdk.TxResponse, bool, error)
- func (c *Chain) SendMsgs(msgs []sdk.Msg) (*sdk.TxResponse, bool, error)
- func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr string, toHeightOffset uint64, ...) error
- func (c *Chain) SetPath(p *PathEnd) error
- func (c *Chain) Start() error
- func (c *Chain) Subscribe(query string) (<-chan ctypes.ResultEvent, context.CancelFunc, error)
- func (c *Chain) TxFactory(height int64) tx.Factory
- func (c *Chain) UnknownError(errorStr string)
- func (c *Chain) Update(key, value string) (out *Chain, err error)
- func (c *Chain) UpdateClient(dst *Chain) (sdk.Msg, error)
- func (c *Chain) UpdateClient2(dst *Chain) (sdk.Msg, int64, error)
- func (c *Chain) UpdateClients(dst *Chain) (err error)
- func (c *Chain) UpdateLightClient() (*tmtypes.LightBlock, error)
- func (c *Chain) UseSDKContext() func()
- func (c *Chain) ValidateLightInitialized() error
- type Chains
- type NaiveStrategy
- func (nrs *NaiveStrategy) GetType() string
- func (nrs *NaiveStrategy) HandleEvents(src, dst *Chain, events map[string][]string)
- func (nrs *NaiveStrategy) RelayAcknowledgements(src, dst *Chain, sp *RelaySequences) error
- func (nrs *NaiveStrategy) RelayPackets(src, dst *Chain, sp *RelaySequences) error
- func (nrs *NaiveStrategy) UnrelayedAcknowledgements(src, dst *Chain) (*RelaySequences, error)
- func (nrs *NaiveStrategy) UnrelayedSequences(src, dst *Chain) (*RelaySequences, error)
- type Path
- func (p *Path) End(chainID string) *PathEnd
- func (p *Path) GenDstChanID()
- func (p *Path) GenDstClientID()
- func (p *Path) GenDstConnID()
- func (p *Path) GenSrcChanID()
- func (p *Path) GenSrcClientID()
- func (p *Path) GenSrcConnID()
- func (p *Path) GetStrategy() (Strategy, error)
- func (p *Path) MustGetStrategy() Strategy
- func (p *Path) MustYAML() string
- func (p *Path) Ordered() bool
- func (p *Path) QueryPathStatus(src, dst *Chain) *PathWithStatus
- func (p *Path) String() string
- func (p *Path) Validate() (err error)
- type PathEnd
- func (pe *PathEnd) GetOrder() chantypes.Order
- func (pe PathEnd) String() string
- func (pe *PathEnd) ValidateBasic() error
- func (pe *PathEnd) ValidateFull() error
- func (pe *PathEnd) Vchan() error
- func (pe *PathEnd) Vclient() error
- func (pe *PathEnd) Vconn() error
- func (pe *PathEnd) Vport() error
- func (pe *PathEnd) Vversion() error
- type PathStatus
- type PathWithStatus
- type Paths
- type ProtoCodec
- func (pc *ProtoCodec) InterfaceRegistry() types.InterfaceRegistry
- func (pc *ProtoCodec) MarshalBinaryBare(o codec.ProtoMarshaler) ([]byte, error)
- func (pc *ProtoCodec) MarshalBinaryLengthPrefixed(o codec.ProtoMarshaler) ([]byte, error)
- func (pc *ProtoCodec) MarshalInterface(i proto.Message) ([]byte, error)
- func (pc *ProtoCodec) MarshalInterfaceJSON(x proto.Message) ([]byte, error)
- func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error)
- func (pc *ProtoCodec) MustMarshalBinaryBare(o codec.ProtoMarshaler) []byte
- func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o codec.ProtoMarshaler) []byte
- func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte
- func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr codec.ProtoMarshaler)
- func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler)
- func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
- func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr codec.ProtoMarshaler) error
- func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler) error
- func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error
- func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error
- func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
- func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error
- type RelayMsgs
- type RelaySequences
- type Strategy
- type StrategyCfg
Constants ¶
const ( ChainTypeWeelink = "weelink" ChainTypeCosmos = "cosmos" )
Variables ¶
var ( AllowUpdateAfterExpiry = true AllowUpdateAfterMisbehaviour = true )
var ( ErrDatabase = errors.New("database failure") // ErrLightNotInitialized returns the canonical error for a an uninitialized light client ErrLightNotInitialized = errors.New("light client is not initialized") )
var ( // DefaultUpgradePath is the default IBC upgrade path set for an on-chain light client DefaultUpgradePath = []string{"upgrade", "upgradedIBCState"} )
Functions ¶
func AutoUpdateClient ¶
AutoUpdateClient update client automatically to prevent expiry
func CastClientStateToTMType ¶
func CastClientStateToTMType(cs *codectypes.Any) (*ibctmtypes.ClientState, error)
CastClientStateToTMType casts client state to tendermint type
func DefaultChainLogger ¶
func ExecuteChannelStep ¶
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 ¶
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 ¶
FindMatchingChannel will determine if there already exists a channel between source and counterparty that matches the parameters set in the relayer configs.
func FindMatchingClient ¶
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 ¶
FindMatchingConnection will determine if there already exists a connection between source and counterparty that matches the parameters set in the relayer configs.
func GenerateRandomBytes ¶
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 ¶
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 GetIBCCreateClientHeaders ¶
GetIBCCreateClientHeaders returns the IBC TM header which will create an on-chain light client. The headers do not have trusted headers (ie trusted validators and trusted height)
func GetIBCUpdateHeaders ¶
GetIBCUpdateHeaders return the IBC TM Header which will update an on-chain light client. A header for the source and destination chain is returned.
func GetLatestLightHeights ¶
GetLatestLightHeights returns both the src and dst latest height in the local client
func InitializeChannel ¶
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 ¶
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 ¶
IsConnectionFound determines if given connectionId is present in channel connectionHops list
func IsMatchingChannel ¶
func IsMatchingChannel(source, counterparty *Chain, channel *chantypes.IdentifiedChannel) bool
IsMatchingChannel determines if given channel matches required conditions
func IsMatchingClient ¶
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 ¶
func IsMatchingConnection(source, counterparty *Chain, connection *conntypes.IdentifiedConnection) bool
IsMatchingConnection determines if given connection matches required conditions
func IsMatchingConsensusState ¶
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 ¶
func MustGetHeight(h ibcexported.Height) clienttypes.Height
MustGetHeight takes the height inteface and returns the actual height
func OrderFromString ¶
OrderFromString parses a string into a channel order byte
func ParseChannelIDFromEvents ¶
func ParseChannelIDFromEvents(events sdk.StringEvents) (string, error)
ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or MsgChannelOpenTry and returns the channel identifier.
func ParseClientIDFromEvents ¶
func ParseClientIDFromEvents(events sdk.StringEvents) (string, error)
ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the client identifier.
func ParseConnectionIDFromEvents ¶
func ParseConnectionIDFromEvents(events sdk.StringEvents) (string, error)
ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or MsgConnectionOpenTry and returns the connection identifier.
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 RandLowerCaseLetterString ¶
RandLowerCaseLetterString returns a lowercase letter string of given length
func RunStrategy ¶
RunStrategy runs a given strategy
func UpdateLightClients ¶
func UpdateLightClients(src, dst *Chain) (srcLB, dstLB *tmtypes.LightBlock, err error)
UpdateLightClients updates the off-chain tendermint light clients concurrently.
func ValidateChannelParams ¶
ValidateChannelParams takes two chains and validates their respective channel params
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 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"` RESTAddr string `yaml:"rest-addr" json:"rest-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"` PrivateKey string `yaml:"private-key" json:"-"` //json返回值除去private-key ChainType string `yaml:"chain-type" json:"chain-type"` // TODO: make these private HomePath string `yaml:"-" json:"-"` PathEnd *PathEnd `yaml:"-" json:"-"` Keybase keys.Keyring `yaml:"-" json:"-"` Client rpcclient.Client `yaml:"-" json:"-"` Encoding types2.EncodingConfig `yaml:"-" json:"-"` CosmosEncoding params.EncodingConfig `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 ¶
AddPath takes the elements of a path and validates then, setting that path to the chain
func (*Chain) CLIContext ¶
CLIContext returns an instance of client.Context derived from Chain
func (*Chain) CLICosmosContext ¶
func (c *Chain) CLICosmosContext(height int64) cosmosSdkCtx.Context
CLIContext returns an instance of client.Context derived from Chain
func (*Chain) ChanConfirm ¶
ChanConfirm creates a MsgChannelOpenConfirm
func (*Chain) ConnConfirm ¶
ConnConfirm creates a MsgConnectionOpenConfirm
func (*Chain) CreateClient ¶
func (c *Chain) CreateClient( clientState *tmclient.ClientState, dstHeader *tmclient.Header) sdk.Msg
CreateClient creates an sdk.Msg to update the client on src with consensus state from dst
func (*Chain) CreateClients ¶
CreateClients creates clients for src on dst and dst on src if the client ids are unspecified. TODO: de-duplicate code
func (*Chain) CreateOpenChannels ¶
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 ¶
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) DeleteLightDB ¶
DeleteLightDB removes the light client database on disk, forcing re-initialization
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) GenerateConnHandshakeProof ¶
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 configred key
func (*Chain) GetAddressString ¶
func (*Chain) GetIBCCreateClientHeader ¶
GetIBCCreateClientHeader updates the off chain tendermint light client on source and returns an IBC Update Header which can be used to create an on-chain light client on counterparty chain.
func (*Chain) GetIBCUpdateHeader ¶
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) GetLatestLightHeader ¶
GetLatestLightHeader returns the header to be used for client creation
func (*Chain) GetLatestLightHeight ¶
GetLatestLightHeight returns the latest height of the light client.
func (*Chain) GetLightSignedHeaderAtHeight ¶
GetLightSignedHeaderAtHeight returns a signed header at a particular height (0 - the latest).
func (*Chain) GetTrustingPeriod ¶
GetTrustingPeriod returns the trusting period for the chain
func (*Chain) HealthCheck ¶
func (*Chain) Init ¶
Init initializes the pieces of a chain that aren't set when it parses a configs NOTE: All validation of the chain should happen here.
func (*Chain) InjectTrustedFields ¶
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) LightClient ¶
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) LightClientWithoutTrust ¶
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) LogFailedTx ¶
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) MakeCosmosEncodingConfig ¶
func (c *Chain) MakeCosmosEncodingConfig() params.EncodingConfig
MakeEncodingConfig returns the encoding txConfig for the chain
func (*Chain) MakeEncodingConfig ¶
func (c *Chain) MakeEncodingConfig() types2.EncodingConfig
func (*Chain) MsgRelayRecvPacket ¶
func (c *Chain) MsgRelayRecvPacket(counterparty *Chain, packet *relayMsgRecvPacket) (msgs []sdk.Msg, err 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 ¶
func (c *Chain) MsgRelayTimeout(counterparty *Chain, packet *relayMsgTimeout) (msgs []sdk.Msg, err 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 ¶
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() sdk.AccAddress
MustGetAddress used for brevity
func (*Chain) MustGetAddressString ¶
func (*Chain) MustGetLatestLightHeight ¶
MustGetLatestLightHeight returns the latest height of the light client. If an error occurs due to a database failure, we keep trying with a delayed re-attempt. Otherwise, we panic.
func (*Chain) NewLightDB ¶
NewLightDB returns a new instance of the lightclient database connection CONTRACT: must close the database connection when done with it (defer df())
func (*Chain) NewProtoCodec ¶
func (c *Chain) NewProtoCodec(interfaceRegistry types.InterfaceRegistry, accountPrefix string) *ProtoCodec
NewProtoCodec returns a reference to a new ProtoCodec
func (*Chain) Print ¶
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) QueryBalanceWithAddress ¶
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) 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 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) (*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) QueryConnections ¶
func (c *Chain) QueryConnections( offset, limit uint64) (*conntypes.QueryConnectionsResponse, error)
QueryConnections gets any connections on a chain
func (*Chain) QueryDenomTraces ¶
func (c *Chain) QueryDenomTraces(offset, limit uint64, height int64) (*transfertypes.QueryDenomTracesResponse, error)
QueryDenomTraces returns all the denom traces from a given chain
func (*Chain) QueryLatestHeight ¶
QueryLatestHeight queries the chain for the latest height and returns it
func (*Chain) QueryNonce ¶
func (*Chain) QueryPacketAcknowledgement ¶
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) 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 commitments
func (*Chain) QueryPacketReceipt ¶
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) 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 ¶
QueryUnbondingPeriod returns the unbonding period of the chain
func (*Chain) QueryUnreceivedPackets ¶
QueryUnreceivedPackets returns a list of unrelayed packet commitments
func (*Chain) SendMsgs ¶
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 ¶
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) Subscribe ¶
func (c *Chain) Subscribe(query string) (<-chan ctypes.ResultEvent, context.CancelFunc, error)
Subscribe returns channel of events given a query
func (*Chain) UnknownError ¶
Error takes an error, wraps it in the chainID and logs the error
func (*Chain) UpdateClient ¶
UpdateClient creates an sdk.Msg to update the client on src with data pulled from dst at the request height..
func (*Chain) UpdateClients ¶
UpdateClients updates clients for src on dst and dst on src given the configured paths
func (*Chain) UpdateLightClient ¶
func (c *Chain) UpdateLightClient() (*tmtypes.LightBlock, error)
UpdateLightClient updates the tendermint light client by verifying the current header against a trusted header.
func (*Chain) UseSDKContext ¶
func (c *Chain) UseSDKContext() func()
func (*Chain) ValidateLightInitialized ¶
ValidateLightInitialized returns an error if the light client isn't initialized or there is a problem interacting with the light client.
type Chains ¶
type Chains []*Chain
Chains is a collection of Chain
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, events map[string][]string)
func (*NaiveStrategy) RelayAcknowledgements ¶
func (nrs *NaiveStrategy) RelayAcknowledgements(src, dst *Chain, sp *RelaySequences) error
func (*NaiveStrategy) RelayPackets ¶
func (nrs *NaiveStrategy) RelayPackets(src, dst *Chain, sp *RelaySequences) error
func (*NaiveStrategy) UnrelayedAcknowledgements ¶
func (nrs *NaiveStrategy) UnrelayedAcknowledgements(src, dst *Chain) (*RelaySequences, error)
func (*NaiveStrategy) UnrelayedSequences ¶
func (nrs *NaiveStrategy) UnrelayedSequences(src, dst *Chain) (*RelaySequences, error)
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 (*Path) GenDstChanID ¶
func (p *Path) GenDstChanID()
GenDstChanID generates the specififed identifier
func (*Path) GenDstClientID ¶
func (p *Path) GenDstClientID()
GenDstClientID generates the specififed identifier
func (*Path) GenDstConnID ¶
func (p *Path) GenDstConnID()
GenDstConnID generates the specififed identifier
func (*Path) GenSrcChanID ¶
func (p *Path) GenSrcChanID()
GenSrcChanID generates the specififed identifier
func (*Path) GenSrcClientID ¶
func (p *Path) GenSrcClientID()
GenSrcClientID generates the specififed identifier
func (*Path) GenSrcConnID ¶
func (p *Path) GenSrcConnID()
GenSrcConnID generates the specififed identifier
func (*Path) GetStrategy ¶
GetStrategy the strategy defined in the relay messages
func (*Path) MustGetStrategy ¶
MustGetStrategy returns the strategy and panics on error
func (*Path) QueryPathStatus ¶
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
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) ValidateBasic ¶
ValidateBasic validates fields that cannot be empty such as the port and channel order.
func (*PathEnd) ValidateFull ¶
ValidateFull returns errors about invalid identifiers as well as unset path variables for the appropriate type
type PathStatus ¶
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 ¶
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
type Paths ¶
Paths represent connection paths between chains
func (Paths) AddForce ¶
AddForce ignores existing paths and overwrites an existing path with that name
type ProtoCodec ¶
type ProtoCodec struct {
// contains filtered or unexported fields
}
ProtoCodec defines a codec that utilizes Protobuf for both binary and JSON encoding.
func (*ProtoCodec) InterfaceRegistry ¶
func (pc *ProtoCodec) InterfaceRegistry() types.InterfaceRegistry
InterfaceRegistry returns the ProtoCodec interfaceRegistry
func (*ProtoCodec) MarshalBinaryBare ¶
func (pc *ProtoCodec) MarshalBinaryBare(o codec.ProtoMarshaler) ([]byte, error)
MarshalBinaryBare implements BinaryMarshaler.MarshalBinaryBare method.
func (*ProtoCodec) MarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MarshalBinaryLengthPrefixed(o codec.ProtoMarshaler) ([]byte, error)
MarshalBinaryLengthPrefixed implements BinaryMarshaler.MarshalBinaryLengthPrefixed method.
func (*ProtoCodec) MarshalInterface ¶
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 MarshalBinaryBare instead
func (*ProtoCodec) MarshalInterfaceJSON ¶
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 ¶
func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error)
MarshalJSON implements JSONMarshaler.MarshalJSON method, it marshals to JSON using proto codec.
func (*ProtoCodec) MustMarshalBinaryBare ¶
func (pc *ProtoCodec) MustMarshalBinaryBare(o codec.ProtoMarshaler) []byte
MustMarshalBinaryBare implements BinaryMarshaler.MustMarshalBinaryBare method.
func (*ProtoCodec) MustMarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o codec.ProtoMarshaler) []byte
MustMarshalBinaryLengthPrefixed implements BinaryMarshaler.MustMarshalBinaryLengthPrefixed method.
func (*ProtoCodec) MustMarshalJSON ¶
func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte
MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure.
func (*ProtoCodec) MustUnmarshalBinaryBare ¶
func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr codec.ProtoMarshaler)
MustUnmarshalBinaryBare implements BinaryMarshaler.MustUnmarshalBinaryBare method.
func (*ProtoCodec) MustUnmarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler)
MustUnmarshalBinaryLengthPrefixed implements BinaryMarshaler.MustUnmarshalBinaryLengthPrefixed method.
func (*ProtoCodec) MustUnmarshalJSON ¶
func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
MustUnmarshalJSON implements JSONMarshaler.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure.
func (*ProtoCodec) UnmarshalBinaryBare ¶
func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr codec.ProtoMarshaler) error
UnmarshalBinaryBare implements BinaryMarshaler.UnmarshalBinaryBare method.
func (*ProtoCodec) UnmarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr codec.ProtoMarshaler) error
UnmarshalBinaryLengthPrefixed implements BinaryMarshaler.UnmarshalBinaryLengthPrefixed method.
func (*ProtoCodec) UnmarshalInterface ¶
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 UnmarshalBinaryBare instead
Example:
var x MyInterface err := cdc.UnmarshalInterface(bz, &x)
func (*ProtoCodec) UnmarshalInterfaceJSON ¶
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 ¶
func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
UnmarshalJSON implements JSONMarshaler.UnmarshalJSON method, it unmarshals from JSON using proto codec.
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 (*RelayMsgs) SendWithController ¶
type RelaySequences ¶
RelaySequences represents unrelayed packets on src and dst
type Strategy ¶
type Strategy interface { GetType() string HandleEvents(src, dst *Chain, 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 configs for the NaiveStrategy