core

package
v0.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 50 Imported by: 33

Documentation

Index

Constants

View Source
const (
	// TODO make it to be configurable
	DefaultDelayPeriod uint64 = 0
)

Variables

This section is empty.

Functions

func CreateChannel

func CreateChannel(src, dst *ProvableChain, 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 CreateClients

func CreateClients(src, dst *ProvableChain) error

func CreateConnection

func CreateConnection(src, dst *ProvableChain, to time.Duration) error

func FindPacketAcknowledgementFromEventsBySequence

func FindPacketAcknowledgementFromEventsBySequence(events []abci.Event, seq uint64) (*packetAcknowledgement, error)

func FindPacketFromEventsBySequence

func FindPacketFromEventsBySequence(events []abci.Event, seq uint64) (*channeltypes.Packet, error)

func GetPacketAcknowledgementsFromEvents

func GetPacketAcknowledgementsFromEvents(events []abci.Event) ([]packetAcknowledgement, error)

func GetPacketsFromEvents

func GetPacketsFromEvents(events []abci.Event) ([]channeltypes.Packet, error)

func MakeCodec added in v0.1.1

func MakeCodec() codec.ProtoCodecMarshaler

func OrderFromString

func OrderFromString(order string) chantypes.Order

OrderFromString parses a string into a channel order byte

func QueryChannelPair

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

QueryChannelPair returns a pair of channel responses

func QueryClientConsensusStatePair

func QueryClientConsensusStatePair(
	src, dst IBCProvableQuerierI,
	srch, dsth int64, srcClientConsH,
	dstClientConsH ibcexported.Height) (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 IBCProvableQuerierI,
	srch, dsth int64) (srcCsRes, dstCsRes *clienttypes.QueryClientStateResponse, err error)

QueryClientStatePair returns a pair of connection responses

func QueryConnectionPair

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

QueryConnectionPair returns a pair of connection responses

func RandLowerCaseLetterString

func RandLowerCaseLetterString(length int) string

RandLowerCaseLetterString returns a lowercase letter string of given length

func SendTransferMsg

func SendTransferMsg(src, dst *ProvableChain, amount sdk.Coin, dstAddr fmt.Stringer, toHeightOffset uint64, toTimeOffset time.Duration) error

func StartService added in v0.1.1

func StartService(ctx context.Context, st StrategyI, src, dst *ProvableChain, relayInterval time.Duration) error

StartService starts a relay service

func UpdateClients added in v0.1.1

func UpdateClients(src, dst *ProvableChain) error

Types

type ChainConfigI

type ChainConfigI interface {
	proto.Message
	Build() (ChainI, error)
}

ChainConfigI defines a chain configuration and its builder

type ChainI

type ChainI interface {
	// ChainID returns ID of the chain
	ChainID() string

	// GetLatestHeight gets the chain for the latest height and returns it
	GetLatestHeight() (int64, error)

	// GetAddress returns the address of relayer
	GetAddress() (sdk.AccAddress, error)

	// Codec returns the codec
	Codec() codec.ProtoCodecMarshaler

	// SetRelayInfo sets source's path and counterparty's info to the chain
	SetRelayInfo(path *PathEnd, counterparty *ProvableChain, counterpartyPath *PathEnd) error

	// Path returns the path
	Path() *PathEnd

	// SendMsgs sends msgs to the chain
	SendMsgs(msgs []sdk.Msg) ([]byte, error)

	// Send sends msgs to the chain and logging a result of it
	// It returns a boolean value whether the result is success
	Send(msgs []sdk.Msg) bool

	// Init initializes the chain
	Init(homePath string, timeout time.Duration, codec codec.ProtoCodecMarshaler, debug bool) error

	// SetupForRelay performs chain-specific setup before starting the relay
	SetupForRelay(ctx context.Context) error

	// RegisterMsgEventListener registers a given EventListener to the chain
	RegisterMsgEventListener(MsgEventListener)

	IBCQuerierI
}

ChainI represents a chain that supports sending transactions and querying the state

type ChainProverConfig added in v0.1.1

type ChainProverConfig struct {
	Chain  json.RawMessage `json:"chain" yaml:"chain"` // NOTE: it's any type as json format
	Prover json.RawMessage `json:"prover" yaml:"prover"`
	// contains filtered or unexported fields
}

ChainProverConfig defines the top level configuration for a chain instance

func NewChainProverConfig added in v0.1.1

func NewChainProverConfig(m codec.JSONCodec, chain ChainConfigI, client ProverConfigI) (*ChainProverConfig, error)

NewChainProverConfig returns a new config instance

func (ChainProverConfig) Build added in v0.1.1

func (cc ChainProverConfig) Build() (*ProvableChain, error)

Build returns a new ProvableChain instance

func (ChainProverConfig) GetChainConfig added in v0.1.1

func (cc ChainProverConfig) GetChainConfig() (ChainConfigI, error)

GetChainConfig returns the cached ChainConfig instance

func (ChainProverConfig) GetProverConfig added in v0.1.1

func (cc ChainProverConfig) GetProverConfig() (ProverConfigI, error)

GetProverConfig returns the cached ChainProverConfig instance

func (*ChainProverConfig) Init added in v0.1.1

func (cc *ChainProverConfig) Init(m codec.Codec) error

Init initialises the configuration

type HeaderI

type HeaderI interface {
	exported.Header
}

func UpdatesWithHeaders

func UpdatesWithHeaders(src, dst LightClientI) (srch, dsth HeaderI, err error)

UpdatesWithHeaders calls UpdateLightWithHeader on the passed chains concurrently

type IBCProvableQuerierI added in v0.1.1

type IBCProvableQuerierI interface {
	// QueryClientConsensusState returns the ClientConsensusState and its proof
	QueryClientConsensusStateWithProof(height int64, dstClientConsHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)

	// QueryClientStateWithProof returns the ClientState and its proof
	QueryClientStateWithProof(height int64) (*clienttypes.QueryClientStateResponse, error)

	// QueryConnectionWithProof returns the Connection and its proof
	QueryConnectionWithProof(height int64) (*conntypes.QueryConnectionResponse, error)

	// QueryChannelWithProof returns the Channel and its proof
	QueryChannelWithProof(height int64) (chanRes *chantypes.QueryChannelResponse, err error)

	// QueryPacketCommitmentWithProof returns the packet commitment and its proof
	QueryPacketCommitmentWithProof(height int64, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error)

	// QueryPacketAcknowledgementCommitmentWithProof returns the packet acknowledgement commitment and its proof
	QueryPacketAcknowledgementCommitmentWithProof(height int64, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error)
}

IBCProvableQuerierI is an interface to the state of IBC and its proof.

type IBCQuerierI added in v0.1.1

type IBCQuerierI interface {
	// QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height
	QueryClientConsensusState(height int64, dstClientConsHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)

	// QueryClientState returns the client state of dst chain
	// height represents the height of dst chain
	QueryClientState(height int64) (*clienttypes.QueryClientStateResponse, error)

	// QueryConnection returns the remote end of a given connection
	QueryConnection(height int64) (*conntypes.QueryConnectionResponse, error)

	// QueryChannel returns the channel associated with a channelID
	QueryChannel(height int64) (chanRes *chantypes.QueryChannelResponse, err error)

	// QueryPacketCommitment returns the packet commitment corresponding to a given sequence
	QueryPacketCommitment(height int64, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error)

	// QueryPacketAcknowledgementCommitment returns the acknowledgement corresponding to a given sequence
	QueryPacketAcknowledgementCommitment(height int64, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error)

	// QueryPacketCommitments returns an array of packet commitments
	QueryPacketCommitments(offset, limit uint64, height int64) (comRes *chantypes.QueryPacketCommitmentsResponse, err error)

	// QueryUnrecievedPackets returns a list of unrelayed packet commitments
	QueryUnrecievedPackets(height int64, seqs []uint64) ([]uint64, error)

	// QueryPacketAcknowledgementCommitments returns an array of packet acks
	QueryPacketAcknowledgementCommitments(offset, limit uint64, height int64) (comRes *chantypes.QueryPacketAcknowledgementsResponse, err error)

	// QueryUnrecievedAcknowledgements returns a list of unrelayed packet acks
	QueryUnrecievedAcknowledgements(height int64, seqs []uint64) ([]uint64, error)

	// QueryPacket returns the packet corresponding to a sequence
	QueryPacket(height int64, sequence uint64) (*chantypes.Packet, error)

	// QueryPacketAcknowledgement returns the acknowledgement corresponding to a sequence
	QueryPacketAcknowledgement(height int64, sequence uint64) ([]byte, error)

	// QueryBalance returns the amount of coins in the relayer account
	QueryBalance(address sdk.AccAddress) (sdk.Coins, error)

	// QueryDenomTraces returns all the denom traces from a given chain
	QueryDenomTraces(offset, limit uint64, height int64) (*transfertypes.QueryDenomTracesResponse, error)
}

IBCQuerierI is an interface to the state of IBC

type LightClientI added in v0.1.1

type LightClientI interface {
	// GetChainID returns the chain ID
	GetChainID() string

	// QueryLatestHeader returns the latest header from the chain
	QueryLatestHeader() (out HeaderI, err error)

	// GetLatestLightHeight returns the latest height on the light client
	GetLatestLightHeight() (int64, error)

	// CreateMsgCreateClient creates a CreateClientMsg to this chain
	CreateMsgCreateClient(clientID string, dstHeader HeaderI, signer sdk.AccAddress) (*clienttypes.MsgCreateClient, error)

	// SetupHeader creates a new header based on a given header
	SetupHeader(dst LightClientIBCQueryierI, baseSrcHeader HeaderI) (HeaderI, error)

	// UpdateLightWithHeader updates a header on the light client and returns the header and height corresponding to the chain
	UpdateLightWithHeader() (header HeaderI, provableHeight int64, queryableHeight int64, err error)
}

LightClientI is an interface to the light client

type LightClientIBCQueryierI added in v0.1.1

type LightClientIBCQueryierI interface {
	LightClientI
	IBCQuerierI
}

LightClientIBCQueryierI is LightClientI + IBCQuerierI

type MsgEventListener added in v0.1.2

type MsgEventListener interface {
	// OnSentMsg is a callback functoin that is called when a msg send to the chain
	OnSentMsg(msgs []sdk.Msg) error
}

MsgEventListener is a listener that listens a msg send to the 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 NewNaiveStrategy

func NewNaiveStrategy() *NaiveStrategy

func (NaiveStrategy) GetType

func (st NaiveStrategy) GetType() string

GetType implements Strategy

func (NaiveStrategy) RelayAcknowledgements

func (st NaiveStrategy) RelayAcknowledgements(src, dst *ProvableChain, sp *RelaySequences, sh SyncHeadersI) error

func (NaiveStrategy) RelayPackets

func (st NaiveStrategy) RelayPackets(src, dst *ProvableChain, sp *RelaySequences, sh SyncHeadersI) error

func (NaiveStrategy) SetupRelay added in v0.1.2

func (st NaiveStrategy) SetupRelay(ctx context.Context, src, dst *ProvableChain) error

func (NaiveStrategy) UnrelayedAcknowledgements

func (st NaiveStrategy) UnrelayedAcknowledgements(src, dst *ProvableChain, sh SyncHeadersI) (*RelaySequences, error)

func (NaiveStrategy) UnrelayedSequences

func (st NaiveStrategy) UnrelayedSequences(src, dst *ProvableChain, sh SyncHeadersI) (*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 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) 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

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

GetStrategy the strategy defined in the relay messages

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

func (p *Path) QueryPathStatus(src, dst *ProvableChain) *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

func (*Path) Validate

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

Validate checks that a path is valid

type PathAction

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

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(dst *PathEnd, 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,
	consensusParams *abci.ConsensusParams,
	signer sdk.AccAddress) sdk.Msg

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

func (*PathEnd) GetOrder

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

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 ibcexported.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) Vversion

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

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 primatives in the path

type PathWithStatus

type PathWithStatus struct {
	Path   *Path      `yaml:"path" json:"chains"`
	Status PathStatus `yaml:"status" json:"status"`
}

PathWithStatus is used for showing the status of the path

func (*PathWithStatus) PrintString

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

PrintString prints a string representations of the path status

type Paths

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

type ProvableChain struct {
	ChainI
	ProverI
}

ProvableChain represents a chain that is supported by the relayer

func NewProvableChain added in v0.1.1

func NewProvableChain(chain ChainI, prover ProverI) *ProvableChain

NewProvableChain returns a new ProvableChain instance

func (*ProvableChain) Init added in v0.1.2

func (pc *ProvableChain) Init(homePath string, timeout time.Duration, codec codec.ProtoCodecMarshaler, debug bool) error

func (*ProvableChain) SetRelayInfo added in v0.1.2

func (pc *ProvableChain) SetRelayInfo(path *PathEnd, counterparty *ProvableChain, counterpartyPath *PathEnd) error

func (*ProvableChain) SetupForRelay added in v0.1.2

func (pc *ProvableChain) SetupForRelay(ctx context.Context) error

type ProverConfigI added in v0.1.1

type ProverConfigI interface {
	proto.Message
	Build(ChainI) (ProverI, error)
}

ProverConfigI defines a prover configuration and its builder

type ProverI added in v0.1.1

type ProverI interface {
	// Init initializes the chain
	Init(homePath string, timeout time.Duration, codec codec.ProtoCodecMarshaler, debug bool) error

	// SetRelayInfo sets source's path and counterparty's info to the chain
	SetRelayInfo(path *PathEnd, counterparty *ProvableChain, counterpartyPath *PathEnd) error

	// SetupForRelay performs chain-specific setup before starting the relay
	SetupForRelay(ctx context.Context) error

	LightClientI
	IBCProvableQuerierI
}

ProverI represents a prover that supports generating a commitment proof

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

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

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

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

func NewRelayService added in v0.1.1

func NewRelayService(st StrategyI, src, dst *ProvableChain, sh SyncHeadersI, interval time.Duration) *RelayService

NewRelayService returns a new service

func (*RelayService) Serve added in v0.1.1

func (srv *RelayService) Serve(ctx context.Context) error

Serve performs packet-relay

func (*RelayService) Start added in v0.1.1

func (srv *RelayService) Start(ctx context.Context) error

Start starts a relay service

type StrategyCfg

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

StrategyCfg defines which relaying strategy to take for a given path

type StrategyI

type StrategyI interface {
	GetType() string
	SetupRelay(ctx context.Context, src, dst *ProvableChain) error
	UnrelayedSequences(src, dst *ProvableChain, sh SyncHeadersI) (*RelaySequences, error)
	RelayPackets(src, dst *ProvableChain, sp *RelaySequences, sh SyncHeadersI) error
	UnrelayedAcknowledgements(src, dst *ProvableChain, sh SyncHeadersI) (*RelaySequences, error)
	RelayAcknowledgements(src, dst *ProvableChain, sp *RelaySequences, sh SyncHeadersI) error
}

StrategyI defines

func GetStrategy

func GetStrategy(cfg StrategyCfg) (StrategyI, error)

type SyncHeadersI

type SyncHeadersI interface {
	// GetProvableHeight returns the provable height of chain
	GetProvableHeight(chainID string) int64
	// GetQueryableHeight returns the queryable height of chain
	GetQueryableHeight(chainID string) int64
	// GetHeader returns the latest header of light client
	GetHeader(src, dst LightClientIBCQueryierI) (HeaderI, error)
	// GetHeaders returns the latest headers for both src and dst client.
	GetHeaders(src, dst LightClientIBCQueryierI) (srcHeader HeaderI, dstHeader HeaderI, err error)
	// Updates updates the header of light client
	Updates(src LightClientI, dst LightClientI) error
}

func NewSyncHeaders

func NewSyncHeaders(src, dst LightClientI) (SyncHeadersI, error)

NewSyncHeaders returns a new instance of SyncHeadersI that can be easily kept "reasonably up to date"

Jump to

Keyboard shortcuts

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