Skip to content

Commit

Permalink
Merge pull request #51 from neutron-org/feat/simplify-config
Browse files Browse the repository at this point in the history
ntrn-252: feat: simplify config by fetching it on app setup
  • Loading branch information
zavgorodnii authored Nov 8, 2022
2 parents 2dc5760 + f6e989e commit 3649445
Show file tree
Hide file tree
Showing 17 changed files with 1,732 additions and 93 deletions.
9 changes: 2 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

RELAYER_NEUTRON_CHAIN_RPC_ADDR=tcp://host.docker.internal:16657
RELAYER_NEUTRON_CHAIN_REST_ADDR=http://host.docker.internal:1316
RELAYER_NEUTRON_CHAIN_CHAIN_ID=test-1
RELAYER_NEUTRON_CHAIN_HOME_DIR=/data/test-1
RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME=demowallet1
RELAYER_NEUTRON_CHAIN_TIMEOUT=1000s
RELAYER_NEUTRON_CHAIN_TIMEOUT=10s
RELAYER_NEUTRON_CHAIN_GAS_PRICES=0.5stake
RELAYER_NEUTRON_CHAIN_GAS_LIMIT=10000000
RELAYER_NEUTRON_CHAIN_GAS_ADJUSTMENT=2.0
RELAYER_NEUTRON_CHAIN_CONNECTION_ID=connection-0
RELAYER_NEUTRON_CHAIN_CLIENT_ID=07-tendermint-0
RELAYER_NEUTRON_CHAIN_DEBUG=true
RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND=test
RELAYER_NEUTRON_CHAIN_OUTPUT_FORMAT=json
RELAYER_NEUTRON_CHAIN_SIGN_MODE_STR=direct

RELAYER_TARGET_CHAIN_RPC_ADDR=tcp://host.docker.internal:26657
RELAYER_TARGET_CHAIN_CHAIN_ID=test-2
RELAYER_TARGET_CHAIN_ACCOUNT_PREFIX=neutron
RELAYER_TARGET_CHAIN_VALIDATOR_ACCOUNT_PREFIX=neutrondeveloper
RELAYER_TARGET_CHAIN_TIMEOUT=1000s
RELAYER_TARGET_CHAIN_CONNECTION_ID=connection-0
RELAYER_TARGET_CHAIN_CLIENT_ID=07-tendermint-0
RELAYER_TARGET_CHAIN_TIMEOUT=10s
RELAYER_TARGET_CHAIN_DEBUG=true
RELAYER_TARGET_CHAIN_OUTPUT_FORMAT=json

Expand Down
12 changes: 0 additions & 12 deletions .env.example.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,17 @@

RELAYER_NEUTRON_CHAIN_RPC_ADDR=tcp://127.0.0.1:16657
RELAYER_NEUTRON_CHAIN_REST_ADDR=http://127.0.0.1:1316
RELAYER_NEUTRON_CHAIN_CHAIN_ID=test-1
RELAYER_NEUTRON_CHAIN_HOME_DIR=../neutron/data/test-1
RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME=demowallet1
RELAYER_NEUTRON_CHAIN_TIMEOUT=1000s
RELAYER_NEUTRON_CHAIN_GAS_PRICES=0.5stake
RELAYER_NEUTRON_CHAIN_GAS_LIMIT=10000000
RELAYER_NEUTRON_CHAIN_GAS_ADJUSTMENT=2.0
RELAYER_NEUTRON_CHAIN_CONNECTION_ID=connection-0
RELAYER_NEUTRON_CHAIN_CLIENT_ID=07-tendermint-0
RELAYER_NEUTRON_CHAIN_DEBUG=true
RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND=test
RELAYER_NEUTRON_CHAIN_OUTPUT_FORMAT=json
RELAYER_NEUTRON_CHAIN_SIGN_MODE_STR=direct

RELAYER_TARGET_CHAIN_RPC_ADDR=tcp://127.0.0.1:26657
RELAYER_TARGET_CHAIN_CHAIN_ID=test-2
RELAYER_TARGET_CHAIN_ACCOUNT_PREFIX=neutron
RELAYER_TARGET_CHAIN_VALIDATOR_ACCOUNT_PREFIX=neutronvaloper
RELAYER_TARGET_CHAIN_TIMEOUT=1000s
RELAYER_TARGET_CHAIN_CONNECTION_ID=connection-0
RELAYER_TARGET_CHAIN_CLIENT_ID=07-tendermint-0
RELAYER_TARGET_CHAIN_DEBUG=true
RELAYER_TARGET_CHAIN_OUTPUT_FORMAT=json

RELAYER_REGISTRY_ADDRESSES=neutron14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s5c2epq

Expand Down
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,41 +84,36 @@ Relayer:
|--------------------------------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|
| `RELAYER_NEUTRON_CHAIN_RPC_ADDR` | `string` | rpc address of neutron chain | required |
| `RELAYER_NEUTRON_CHAIN_REST_ADDR` | `string` | rest address of neutron chain | required |
| `RELAYER_NEUTRON_CHAIN_CHAIN_ID ` | `string` | neutron chain id | required |
| `RELAYER_NEUTRON_CHAIN_HOME_DIR ` | `string` | path to keys directory | required |
| `RELAYER_NEUTRON_CHAIN_SIGN_KEY_NAME` | `string` | key name | required |
| `RELAYER_NEUTRON_CHAIN_TIMEOUT ` | `time` | timeout of neutron chain provider | required |
| `RELAYER_NEUTRON_CHAIN_TIMEOUT ` | `time` | timeout of neutron chain provider | optional |
| `RELAYER_NEUTRON_CHAIN_GAS_PRICES` | `string` | specifies how much the user is willing to pay per unit of gas, which can be one or multiple denominations of token | required |
| `RELAYER_NEUTRON_CHAIN_GAS_LIMIT` | `string` | the maximum price a relayer user is willing to pay for relayer's paid blockchain actions | required |
| `RELAYER_NEUTRON_CHAIN_GAS_ADJUSTMENT` | `float` | used 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 gas | required |
| `RELAYER_NEUTRON_CHAIN_CONNECTION_ID` | `string` | neutron chain connection ID | required |
| `RELAYER_NEUTRON_CHAIN_CLIENT_ID ` | `string` | IBC client ID for an IBC connection between Neutron chain and target chain (where the result was obtained from) | required |
| `RELAYER_NEUTRON_CHAIN_DEBUG ` | `bool` | flag to run neutron chain provider in debug mode | required |
| `RELAYER_NEUTRON_CHAIN_DEBUG ` | `bool` | flag to run neutron chain provider in debug mode | optional |
| `RELAYER_NEUTRON_CHAIN_KEYRING_BACKEND` | `string` | [see](https://docs.cosmos.network/master/run-node/keyring.html#the-kwallet-backend) | required |
| `RELAYER_NEUTRON_CHAIN_OUTPUT_FORMAT` | `json` OR `yaml` | neutron chain provider output format | required |
| `RELAYER_NEUTRON_CHAIN_SIGN_MODE_STR ` | `string` | [see](https://docs.cosmos.network/master/core/transactions.html#signing-transactions) also consider use short variation, e.g. `direct` | required |
| `RELAYER_NEUTRON_CHAIN_SIGN_MODE_STR ` | `string` | [see](https://docs.cosmos.network/master/core/transactions.html#signing-transactions) also consider use short variation, e.g. `direct` | optional |
| `RELAYER_TARGET_CHAIN_RPC_ADDR` | `string` | rpc address of target chain | required |
| `RELAYER_TARGET_CHAIN_CHAIN_ID ` | `string` | target chain id | required |
| `RELAYER_TARGET_CHAIN_ACCOUNT_PREFIX ` | `string` | target chain account prefix | required |
| `RELAYER_TARGET_CHAIN_VALIDATOR_ACCOUNT_PREFIX ` | `string` | target chain validator account prefix | required |
| `RELAYER_TARGET_CHAIN_TIMEOUT ` | `time` | timeout of target chain provider | required |
| `RELAYER_TARGET_CHAIN_CONNECTION_ID` | `time` | target chain connection ID | required |
| `RELAYER_TARGET_CHAIN_CLIENT_ID ` | `string` | IBC client ID for an IBC connection between Neutron chain and target chain (where the result was obtained from) | required |
| `RELAYER_TARGET_CHAIN_DEBUG ` | `bool` | flag to run target chain provider in debug mode | required |
| `RELAYER_TARGET_CHAIN_OUTPUT_FORMAT` | `json` or `yaml` | target chain provider output format | required |
| `RELAYER_TARGET_CHAIN_TIMEOUT ` | `time` | timeout of target chain provider | optional |
| `RELAYER_TARGET_CHAIN_DEBUG ` | `bool` | flag to run target chain provider in debug mode | optional |
| `RELAYER_TARGET_CHAIN_OUTPUT_FORMAT` | `json` or `yaml` | target chain provider output format | optional |
| `RELAYER_REGISTRY_ADDRESSES` | `string` | a list of comma-separated smart-contract addresses for which the relayer processes interchain queries | required |
| `RELAYER_ALLOW_TX_QUERIES` | `bool` | if true relayer will process tx queries (if `false`, relayer will drop them) | required |
| `RELAYER_ALLOW_KV_CALLBACKS` | `bool` | if `true`, will pass proofs as sudo callbacks to contracts | required |
| `RELAYER_MIN_KV_UPDATE_PERIOD` | `uint` | minimal period of queries execution and submission (not less than `n` blocks) | optional |
| `RELAYER_STORAGE_PATH` | `string` | path to leveldb storage, will be created on given path if doesn't exists <br/> (NOTE: required if `RELAYER_ALLOW_TX_QUERIES` is `true`) | optional |
| `RELAYER_STORAGE_PATH` | `string` | path to leveldb storage, will be created on given path if doesn't exists <br/> (required if `RELAYER_ALLOW_TX_QUERIES` is `true`) | optional |
| `RELAYER_CHECK_SUBMITTED_TX_STATUS_DELAY` | `uint` | delay in seconds to wait before transaction is checked for commit status | optional |
| `RELAYER_QUERIES_TASK_QUEUE_CAPACITY` | `int` | capacity of the channel that is used to send messages from subscriber to relayer (better set to a higher value to avoid problems with Tendermint websocket subscriptions). | optional |
| `RELAYER_PROMETHEUS_PORT` | `uint` | listen port for Prometheus | optional |
| `RELAYER_INITIAL_TX_SEARCH_OFFSET` | `uint` | if set to non zero and no prior search height exists, it will initially set to (last_height - X). Set this if you have lots of old tx's on first start you don't need. | optional |

# Logging

We are using a little bit modified [zap.Logger](https://github.com/uber-go/zap), the modification can be seen at the [neutron-logger repository](https://github.com/neutron-org/neutron-logger). The default version of the logger used in the application is a little bit modified [zap.NewProduction](https://github.com/uber-go/zap/blob/master/logger.go#L94). 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.
We are using a little modified [zap.Logger](https://github.com/uber-go/zap), the modification can be seen at the [neutron-logger repository](https://github.com/neutron-org/neutron-logger). The default version of the logger used in the application is a little bit modified [zap.NewProduction](https://github.com/uber-go/zap/blob/master/logger.go#L94). 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

Expand Down
1 change: 1 addition & 0 deletions cmd/neutron_query_relayer/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func init() {
func startRelayer() {
logRegistry, err := nlogger.NewRegistry(
mainContext,
app.AppContext,
app.SubscriberContext,
app.RelayerContext,
app.TargetChainRPCClientContext,
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/go-openapi/runtime v0.24.1
github.com/go-openapi/strfmt v0.21.3
github.com/go-openapi/swag v0.22.3
github.com/go-openapi/validate v0.21.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/neutron-org/neutron v0.0.0-20220916150924-ec7dc591745d
github.com/neutron-org/neutron-logger v0.0.0-20221027125151-535167f2dd73
Expand All @@ -28,6 +29,7 @@ require (
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/CosmWasm/wasmd v0.28.0 // indirect
github.com/CosmWasm/wasmvm v1.0.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
Expand All @@ -41,7 +43,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/containerd/continuity v0.2.2 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
Expand All @@ -68,7 +70,6 @@ require (
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/loads v0.21.1 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/validate v0.21.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
Expand All @@ -78,6 +79,7 @@ require (
github.com/google/btree v1.0.1 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXY
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
Expand Down Expand Up @@ -232,8 +233,8 @@ github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8a
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.2.1/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg=
github.com/containerd/continuity v0.2.2 h1:QSqfxcn8c+12slxwu00AtzXrsami0MJb/MQs9lOLHLA=
github.com/containerd/continuity v0.2.2/go.mod h1:pWygW9u7LtS1o4N/Tn0FoCFDIXZ7rxcMX7HX1Dmibvk=
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down Expand Up @@ -560,8 +561,9 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
Expand Down
Loading

0 comments on commit 3649445

Please sign in to comment.