relay

package
v0.0.0-...-d941823 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

relay package is a high level controller that implements whole mechanism of relaying a query

This high level logic is encapsulated in Relayer struct

Documentation

Index

Constants

View Source
const TxHeight = "tx.height"

TxHeight describes tendermint filter by tx.height that we use to get only actual txs

Variables

This section is empty.

Functions

func GetNeutronChain

func GetNeutronChain(logger *zap.Logger, cfg *config.NeutronChainConfig, chainID string) (*relayer.Chain, error)

func GetTargetChain

func GetTargetChain(logger *zap.Logger, cfg *config.TargetChainConfig, chainID string) (*relayer.Chain, error)

Types

type KVProcessor

type KVProcessor interface {
	// ProcessAndSubmit handles an incoming KV interchain query message. It checks whether it's time
	// to execute the query (based on the relayer's settings), queries values and proofs for the query
	// keys, and submits the result to the Neutron chain.
	ProcessAndSubmit(ctx context.Context, m *MessageKV) error
}

KVProcessor processes event query KV type. Obtains the proof for a query we need to process, and sends it to the neutron

type MessageKV

type MessageKV struct {
	// QueryId is the ID of the query.
	QueryId uint64
	// KVKeys is the query parameter that describes keys list to be retrieved.
	KVKeys types.KVKeys
}

MessageKV contains params of a KV interchain query.

type MessageTX

type MessageTX struct {
	// QueryId is the ID of the query.
	QueryId uint64
	// TransactionsFilter is the query parameter that describes conditions for transactions search.
	TransactionsFilter string
}

MessageTX contains params of a TX interchain query.

type Relayer

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

Relayer is controller for the whole app: 1. takes events from Neutron chain 2. dispatches each query by type to fetch proof for the right query 3. submits proof for a query back to the Neutron chain

func NewRelayer

func NewRelayer(
	cfg config.NeutronQueryRelayerConfig,
	store Storage,
	kvProcessor KVProcessor,
	targetChain *relayer.Chain,
	logger *zap.Logger,
) *Relayer

func (*Relayer) Run

func (r *Relayer) Run(
	ctx context.Context,
	queriesTasksQueue <-chan neutrontypes.RegisteredQuery,
) error

Run starts the relaying process: subscribes on the incoming interchain query messages from the Neutron and performs the queries by interacting with the target chain and submitting them to the Neutron chain.

type Storage

type Storage interface {
	GetLastQueryHeight(queryID uint64) (block uint64, found bool, err error)
	SetLastQueryHeight(queryID uint64, block uint64) error
	Close() error
}

Storage is local storage we use to store queries history: known queries, know transactions and its statuses

type Submitter

type Submitter interface {
	SubmitKVProof(ctx context.Context, height, revision, queryId uint64, proof []*neutrontypes.StorageValue, updateClientMsg sdk.Msg) error
}

Submitter knows how to submit proof to the chain

type Subscriber

type Subscriber interface {
	// returns the neutron registered query by its ID
	GetNeutronRegisteredQuery(ctx context.Context, queryId string) (*neutrontypes.RegisteredQuery, error)
}

Subscriber is an interface that subscribes to Neutron and provides chain data in real time.

type TrustedHeaderFetcher

type TrustedHeaderFetcher interface {
	// Fetch returns only one trusted Header for specified height
	Fetch(ctx context.Context, height uint64) (*tmclient.Header, error)
}

TrustedHeaderFetcher able to get trusted headers for a given height

Jump to

Keyboard shortcuts

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