Categorygithub.com/hadronlabs-org/neutron-query-relayer
module
0.0.0-20240730121546-131ca43f4a47
Repository: https://github.com/hadronlabs-org/neutron-query-relayer.git
Documentation: pkg.go.dev

# README

Interchain query relayer implementation for Neutron.

More on relayer in neutron-docs

Running in development

Natively

  • export environment you need (e.g. export $(grep -v '^#' .env.example | xargs) note: change rpc addresses to actual)
  • make dev

For more configuration parameters see Environment section.

In Docker

  1. Build docker image make build-docker
  2. Run docker run --env-file .env.example -v $PWD/../neutron/data:/data -p 9999:9999 hadronlabs-org/neutron-query-relayer-cli
    • note: this command uses relative path to mount keys, run this from root path of neutron-query-relayer
    • note: with local chains use host.docker.internal in RELAYER_NEUTRON_CHAIN_RPC_ADDR and RELAYER_TARGET_CHAIN_RPC_ADDR instead of localhost/127.0.0.1
    • note: on Linux machines it is necessary to pass --add-host=host.docker.internal:host-gateway to Docker in order to make container able to access host network

Testing

Run unit tests

$ make test

Testing with 2 neutron-chains (easier for development) via cli

prerequisites

Clone the following repositories to the same folder where the neutron-query-relayer folder is located:

  1. git clone [email protected]:neutron-org/neutron.git
  2. git clone [email protected]:neutron-org/neutron-dev-contracts.git
  3. git clone [email protected]:neutron-org/neutron-integration-tests.git for testing using docker

terminal 1

  1. cd neutron
  2. make build && make init && make start-rly

terminal 2

  1. cd neutron-dev-contracts
  2. run test_*.sh files from the root of the neutron-dev-contracts project (e.g. ./test_tx_query_result.sh).

terminal 3

  1. cp .env.example.dev .env, edit .env if desired
  2. export $(grep -v '^#' .env | xargs) && make dev QUERY_ID=<query id to relay>

Testing via docker

  1. cd neutron-integration-tests
  2. read and run preparation steps described in the README.md file
  3. run tests as described in the README.md file

In case of unexpected behaviour (e.g. tests failure) you can inspect neutron and relayer logs by doing the following:

Neutron:

  1. docker ps
  2. find the neutron container id
  3. docker exec -it neutron_id bash
  4. cd /opt/neutron/data
  5. observe neutron logs in file test-1.log

Relayer:

  1. docker ps
  2. find the relayer container id
  3. docker logs -f relayer_id

Configuration

Environment

Keytypedescriptionoptional
MANUAL_MODEboolif true, will not run coordinator. Used to manually run query relayer from testsrequired
RELAYER_NEUTRON_CHAIN_RPC_ADDRstringrpc address of neutron chainrequired
RELAYER_NEUTRON_CHAIN_REST_ADDRstringrest address of neutron chainrequired
RELAYER_NEUTRON_CHAIN_HOME_DIR stringpath to keys directoryrequired
RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAMEstringkey namerequired
RELAYER_NEUTRON_CHAIN_TIMEOUT timetimeout of neutron chain provideroptional
RELAYER_NEUTRON_CHAIN_GAS_PRICESstringspecifies how much the user is willing to pay per unit of gas, which can be one or multiple denominations of tokenrequired
RELAYER_NEUTRON_CHAIN_GAS_LIMITstringthe maximum price a relayer user is willing to pay for relayer's paid blockchain actionsrequired
RELAYER_NEUTRON_CHAIN_GAS_ADJUSTMENTfloatused to scale gas up in order to avoid underestimating. For example, users can specify their gas adjustment as 1.5 to use 1.5 times the estimated gasrequired
RELAYER_NEUTRON_CHAIN_CONNECTION_IDstringneutron chain connection IDrequired
RELAYER_NEUTRON_CHAIN_DEBUG boolflag to run neutron chain provider in debug modeoptional
RELAYER_NEUTRON_CHAIN_KEYRING_BACKENDstringseerequired
RELAYER_NEUTRON_CHAIN_OUTPUT_FORMATjson OR yamlneutron chain provider output formatrequired
RELAYER_NEUTRON_CHAIN_SIGN_MODE_STR stringsee also consider use short variation, e.g. directoptional
RELAYER_TARGET_CHAIN_RPC_ADDRstringrpc address of target chainrequired
RELAYER_TARGET_CHAIN_ACCOUNT_PREFIX stringtarget chain account prefixrequired
RELAYER_TARGET_CHAIN_VALIDATOR_ACCOUNT_PREFIX stringtarget chain validator account prefixrequired
RELAYER_TARGET_CHAIN_TIMEOUT timetimeout of target chain provideroptional
RELAYER_TARGET_CHAIN_DEBUG boolflag to run target chain provider in debug modeoptional
RELAYER_TARGET_CHAIN_OUTPUT_FORMATjson or yamltarget chain provider output formatoptional
RELAYER_ALLOW_KV_CALLBACKSboolif true, will pass proofs as sudo callbacks to contractsrequired

Logging

We are using a little modified zap.Logger, the modification can be seen at the neutron-logger repository. The default version of the logger used in the application is a little bit modified zap.NewProduction. The logger level can be set via the LOGGER_LEVEL env variable. If there is a need for a more significant customisation of the logger behaviour, see the neutron-logger repository readme.

Generate Openapi

The relayer uses a generated swagger client to retrieve queries information from Neutron. You can re-generate the Go client from ./internal/subscriber/querier/openapi.yml by running:

make generate-openapi

The swagger specs can be taken from the Neutron repo (you need to remove most of the generated specification).

Querying api server

You can query any running relayer as an api webserver.

Print available queries:

go run ./cmd/neutron_query_relayer query

# Packages

No description provided by the author