diff --git a/CHANGELOG.md b/CHANGELOG.md index 046b50a86..5694d65ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,7 +125,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump `golang.org/x/net` from 0.20.0 to 0.23.0 ([#1850](https://github.com/NibiruChain/nibiru/pull/1850)) - Bump `github.com/supranational/blst` from 0.3.8-0.20220526154634-513d2456b344 to 0.3.11 ([#1851](https://github.com/NibiruChain/nibiru/pull/1851)) - Bump `golangci/golangci-lint-action` from 4 to 6 ([#1854](https://github.com/NibiruChain/nibiru/pull/1854), [#1867](https://github.com/NibiruChain/nibiru/pull/1867)) -- Bump `github.com/hashicorp/go-getter` from 1.7.1 to 1.7.4 ([#1858](https://github.com/NibiruChain/nibiru/pull/1858)) +- Bump `github.com/hashicorp/go-getter` from 1.7.1 to 1.7.5 ([#1858](https://github.com/NibiruChain/nibiru/pull/1858), [#1938](https://github.com/NibiruChain/nibiru/pull/1938)) - Bump `github.com/btcsuite/btcd` from 0.23.3 to 0.24.0 ([#1862](https://github.com/NibiruChain/nibiru/pull/1862)) - Bump `pozetroninc/github-action-get-latest-release` from 0.7.0 to 0.8.0 ([#1863](https://github.com/NibiruChain/nibiru/pull/1863)) - Bump `bufbuild/buf-setup-action` from 1.30.1 to 1.33.0 ([#1891](https://github.com/NibiruChain/nibiru/pull/1891), [#1900](https://github.com/NibiruChain/nibiru/pull/1900), [#1923](https://github.com/NibiruChain/nibiru/pull/1923)) diff --git a/CHAOSNET.md b/CHAOSNET.md index 3910d4434..8a9e802fa 100644 --- a/CHAOSNET.md +++ b/CHAOSNET.md @@ -17,20 +17,18 @@ Chaosnet is an expanded version of localnet that runs: -- two validators (nibiru-0 and nibiru-1) +- up to two validators (nibiru-0 and nibiru-1) - pricefeeders for each validator -- a hermes relayer between the two validators -- a faucet -- a postgres:14 database -- a heartmonitor instance -- a liquidator instance -- a graphql server +- a hermes relayer between the two validators (if the `ibc` profile is used) +- a postgres:14 database (if the `heartmonitor` profile is used) +- a heartmonitor instance (if the `heartmonitor` profile is used) +- a graphql server (if the `heartmonitor` profile is used) ## How to run "chaosnet" 1. Make sure you have [Docker](https://docs.docker.com/engine/install/) installed and running 2. Make sure you have `make` installed -3. Docker login to ghcr.io +3. (Optional) Docker login to ghcr.io (only if you want to use the `heartmonitor` profile) ```bash docker login ghcr.io @@ -42,9 +40,14 @@ Enter your GitHub username for the `username` field, and your personal access to Note that this will take a while the first time you run it, as it will need to pull all the images from the registry, build the chaonset image locally, and set up the IBC channel (which has a lot of round trip packet commits). +Other profiles include + +- `make chaosnet-ibc`: creates two validator instances and a hermes relayer +- `make chaosnet-heartmonitor`: single validator with heartmonitor+graphql instance + ## How to force pull images from the registry -By default, most images (heart-monitor, liquidator, etc.) are cached locally and won't re-fetch from upstream registries. To force a pull, you can run +By default, most images (heartmonitor, etc.) are cached locally and won't re-fetch from upstream registries. To force a pull, you can run ```sh make chaosnet-build diff --git a/contrib/docker-compose/README.md b/contrib/docker-compose/README.md index f588d5728..e888d4b90 100644 --- a/contrib/docker-compose/README.md +++ b/contrib/docker-compose/README.md @@ -1,13 +1,18 @@ # contrib/docker-compose -- [docker-compose-chaosnet](#docker-compose-chaosnet) - - [Usage Commands:](#usage-commands) - - [Nibiru node services](#nibiru-node-services) - - [Oracle feeder services](#oracle-feeder-services) - - [Hermes IBC relayer services](#hermes-ibc-relayer-services) - - [Faucet Service](#faucet-service) - - [Heart Monitor Services](#heart-monitor-services) -- [Reference Materials](#reference-materials) +- [contrib/docker-compose](#contribdocker-compose) + - [docker-compose-chaosnet](#docker-compose-chaosnet) + - [Usage](#usage) + - [Single validator node + pricefeeder](#single-validator-node--pricefeeder) + - [Two validator nodes + pricefeeder + IBC relayer](#two-validator-nodes--pricefeeder--ibc-relayer) + - [Single validator node + heartmonitor](#single-validator-node--heartmonitor) + - [Other Commands](#other-commands) + - [Services Overview](#services-overview) + - [Nibiru node services](#nibiru-node-services) + - [Pricefeeder services](#pricefeeder-services) + - [Hermes IBC relayer services](#hermes-ibc-relayer-services) + - [Heart Monitor Services](#heart-monitor-services) + - [Reference Materials](#reference-materials) ## docker-compose-chaosnet @@ -18,17 +23,38 @@ Nibiru-specific containers. Features: -- Data volume mounts ensure persistent storage. - Different ports are utilized to mimic a multi-chain configuration on a single machine. -- Enables testing of cross-chain transactions, chain health monitoring, liquidations, and more in a local Docker context across two chains. +- Enables testing of cross-chain transactions, chain health monitoring, and more in a local Docker context across two chains. -### Usage Commands: +## Usage + +### Single validator node + pricefeeder + +```sh +docker compose -f docker-compose-chaosnet.yml up +``` + +### Two validator nodes + pricefeeder + IBC relayer + +```sh +docker compose -f docker-compose-chaosnet.yml --profile ibc up +``` + +### Single validator node + heartmonitor + +```sh +docker compose -f docker-compose-chaosnet.yml --profile heartmonitor up +``` + +### Other Commands - `docker compose up`: Start the services. - `docker compose down`: Stop the services. - `docker compose restart`: Restart all services. - `docker compose ps`: List containers, their status, ports, etc. -- `docker compose logs`: View std output from containers +- `docker compose logs`: View std output from containers + +## Services Overview ### Nibiru node services @@ -36,7 +62,7 @@ Features: running on different ports, using unique mnemonics and chain IDs, imitating two independent blockchain networks. -### Oracle feeder services +### Pricefeeder services - `pricefeeder-0` and `pricefeeder-1` (Service): Two price feeder services that push price data to the respective Nibiru nodes. @@ -44,6 +70,7 @@ Features: ### Hermes IBC relayer services An IBC relayer is set up to connect the two chains using [hermes](https://hermes.informal.systems/). + 1. `hermes-keys-task-0` and `hermes-keys-task-1` (Service): Tasks to generate keys for the validators on `nibiru-0` and `nibiru-1`. 2. `hermes-client-connection-channel-task` (Service): Creates a new channel @@ -59,34 +86,24 @@ Brief IBC reference: Put simply, **connections** represent a secure communication line between two blockchain to transfer IBC **packets** (data). Once a connection is established, light client of two chains, usually called the source chain and destination -chain, is established. +chain, is established. Once a connection is established, **channels** can be formed. A channel represents a logical pathway for specific types communication over the connection (like token transfers and other relaying of IBC packets. -### Faucet Service - -Dispenses testnet tokens. Faucets provide liquidity on test chains. - -Repository: [NibiruChain/go-faucet](https://github.com/NibiruChain/go-faucet) - ### Heart Monitor Services - `heartmonitor-db`: A postgres database for the heart monitor. - `heartmonitor`: An indexing solution that populates a DB based on events and - block responses emitted from Nibiru nodes. - -- `liquidator` : Liquidates underwater positions using the tracked state inside - `hearmonitor-db`. + block responses emitted from Nibiru nodes. - `graphql`: GraphQL API for the heart monitor data. Used in the Nibiru web app and other off-chain tools. Repository: [NibiruChain/go-heartmonitor](https://github.com/NibiruChain/go-heartmonitor). - ## Reference Materials - [Docker Compose file](https://docs.docker.com/compose/compose-file/03-compose-file/) diff --git a/contrib/docker-compose/docker-compose-chaosnet.yml b/contrib/docker-compose/docker-compose-chaosnet.yml index 35708aee0..df9514b01 100644 --- a/contrib/docker-compose/docker-compose-chaosnet.yml +++ b/contrib/docker-compose/docker-compose-chaosnet.yml @@ -48,6 +48,7 @@ services: RPC_PORT: 36657 GRPC_PORT: 19090 LCD_PORT: 11317 + profiles: [ibc] healthcheck: test: ["CMD", "curl", "-f", "http://localhost:36657"] interval: 60s @@ -63,6 +64,7 @@ services: pricefeeder-1: image: ghcr.io/nibiruchain/pricefeeder:latest + profiles: [ibc] restart: always environment: CHAIN_ID: nibiru-localnet-1 @@ -77,6 +79,7 @@ services: hermes-keys-task-0: image: informalsystems/hermes:1.6.0 + profiles: [ibc] user: root command: [ @@ -107,6 +110,7 @@ services: hermes-keys-task-1: image: informalsystems/hermes:1.6.0 + profiles: [ibc] user: root command: [ @@ -139,6 +143,7 @@ services: hermes-client-connection-channel-task: image: informalsystems/hermes:1.6.0 + profiles: [ibc] user: root command: [ @@ -172,6 +177,7 @@ services: hermes: image: informalsystems/hermes:1.6.0 + profiles: [ibc] restart: always user: root command: ["start"] @@ -191,22 +197,9 @@ services: hermes-client-connection-channel-task: condition: service_completed_successfully - faucet: - restart: always - image: ghcr.io/nibiruchain/go-faucet:latest - environment: - NODE: nibiru-0:9090 - MNEMONIC: undo donkey arena rule old portion long forget rescue post stuff normal reduce raw unable warrior method stairs valley enhance glory lens sign zero - SEND_COINS: 11000000unibi - MAX_SEND_COINS: 110000000unibi - depends_on: - nibiru-0: - condition: service_healthy - ports: - - 8000:8000 - heartmonitor-db: image: postgres:14 + profiles: [heartmonitor] restart: always environment: POSTGRES_PASSWORD: postgres @@ -216,6 +209,8 @@ services: heartmonitor: image: ghcr.io/nibiruchain/go-heartmonitor:latest + platform: linux/amd64 + profiles: [heartmonitor] restart: always command: --clean volumes: @@ -231,26 +226,10 @@ services: heartmonitor-db: condition: service_started - liquidator: - image: ghcr.io/nibiruchain/go-heartmonitor:latest - restart: always - command: --liquidator - environment: - - DATABASE_URI=postgresql://postgres:postgres@heartmonitor-db:5432/heart-monitor?sslmode=disable - - TENDERMINT_RPC_ENDPOINT=http://nibiru-0:26657 - - GRPC_ENDPOINT=tcp://nibiru-0:9090 - - GRPC_INSECURE=true - - NO_PARTITIONS=true - - LIQUIDATOR_MNEMONIC=record damage person caution truly riot resource luxury rude guide mushroom athlete fantasy dentist friend mule depth salmon photo unfold exclude coyote idea evoke - - LIQUIDATOR_GAS_LIMIT_INITIAL=500000 - - LIQUIDATOR_GAS_MULTIPLIER=5 - - LIQUIDATOR_GAS_MAX_ATTEMPTS=10 - depends_on: - heartmonitor: - condition: service_started - graphql: image: ghcr.io/nibiruchain/go-heartmonitor:latest + platform: linux/amd64 + profiles: [heartmonitor] restart: always command: --graphql environment: diff --git a/contrib/docker-compose/docker-compose-multi-node.yml b/contrib/docker-compose/docker-compose-multi-node.yml deleted file mode 100644 index e5e5b986e..000000000 --- a/contrib/docker-compose/docker-compose-multi-node.yml +++ /dev/null @@ -1,64 +0,0 @@ -version: '3' - -services: - node0: - container_name: node0 - image: "nibiru/node" - ports: - - "26656-26657:26656-26657" - - "9090:9090" - - "1317:1317" - environment: - - ID=0 - volumes: - - ../../data/node0/nibid:/root/.nibid:Z - networks: - localnet: - ipv4_address: 192.168.11.2 - - node1: - container_name: node1 - image: "nibiru/node" - ports: - - "26659-26660:26656-26657" - environment: - - ID=1 - volumes: - - ../../data/node1/nibid:/root/.nibid:Z - networks: - localnet: - ipv4_address: 192.168.11.3 - - node2: - container_name: node2 - image: "nibiru/node" - environment: - - ID=2 - ports: - - "26661-26662:26656-26657" - volumes: - - ../../data/node2/nibid:/root/.nibid:Z - networks: - localnet: - ipv4_address: 192.168.11.4 - - node3: - container_name: node3 - image: "nibiru/node" - environment: - - ID=3 - ports: - - "26663-26664:26656-26657" - volumes: - - ../../data/node3/nibid:/root/.nibid:Z - networks: - localnet: - ipv4_address: 192.168.11.5 - -networks: - localnet: - driver: bridge - ipam: - driver: default - config: - - subnet: 192.168.11.0/16 diff --git a/contrib/make/chaosnet.mk b/contrib/make/chaosnet.mk index df46d516b..6bcc88ef4 100644 --- a/contrib/make/chaosnet.mk +++ b/contrib/make/chaosnet.mk @@ -12,10 +12,22 @@ chaosnet-build: chaosnet: chaosnet-down docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml up --detach --build -# Stop chaosnet +# Run a chaosnet testnet locally with IBC enabled +.PHONY: chaosnet-ibc +chaosnet-ibc: chaosnet-down + docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml --profile ibc up --detach --build + +# Run a chaosnet testnet locally with heartmonitor+graphql stack enabled +.PHONY: chaosnet-heartmonitor +chaosnet-heartmonitor: chaosnet-down + docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml --profile heartmonitor up --detach --build + +# Stop chaosnet, need to specify all profiles to ensure all services are stopped +# See https://stackoverflow.com/questions/76781634/docker-compose-down-all-profiles .PHONY: chaosnet-down chaosnet-down: - docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml down --timeout 1 --volumes + docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml --profile ibc down --timeout 1 --volumes + docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml --profile heartmonitor down --timeout 1 --volumes ############################################################################### ### Chaosnet Logs ### @@ -25,10 +37,6 @@ chaosnet-down: chaosnet-logs: docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml logs -.PHONY: chaosnet-logs-faucet -chaosnet-logs-faucet: - docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml logs go-faucet - .PHONY: chaosnet-logs-pricefeeder chaosnet-logs-pricefeeder: docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml logs pricefeeder --follow @@ -41,9 +49,13 @@ chaosnet-logs-go-heartmonitor: ### Chaosnet SSH ### ############################################################################### -.PHONY: chaosnet-ssh-nibiru -chaosnet-ssh-nibiru: - docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml exec -it nibiru /bin/sh +.PHONY: chaosnet-ssh-nibiru-0 +chaosnet-ssh-nibiru-0: + docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml exec -it nibiru-0 /bin/sh + +.PHONY: chaosnet-ssh-nibiru-1 +chaosnet-ssh-nibiru-1: + docker compose -f ./contrib/docker-compose/docker-compose-chaosnet.yml exec -it nibiru-1 /bin/sh .PHONY: chaosnet-ssh-go-heartmonitor chaosnet-ssh-go-heartmonitor: diff --git a/contrib/scripts/chaosnet.sh b/contrib/scripts/chaosnet.sh index 40faf61e6..ffee52fd8 100755 --- a/contrib/scripts/chaosnet.sh +++ b/contrib/scripts/chaosnet.sh @@ -25,6 +25,7 @@ sed -i 's/log_format = .*/log_format = "json"/' $HOME/.nibid/config/config.toml sed -i '/\[api\]/,+3 s/enable = false/enable = true/' $HOME/.nibid/config/app.toml sed -i 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/' $HOME/.nibid/config/app.toml sed -i "s/localhost:1317/0.0.0.0:$LCD_PORT/" $HOME/.nibid/config/app.toml +sed -i '/\[grpc\]/,+3 s/enable = false/enable = true/' $HOME/.nibid/config/app.toml sed -i "s/localhost:9090/0.0.0.0:$GRPC_PORT/" $HOME/.nibid/config/app.toml # ------------------------------------------------------------------------ diff --git a/go.mod b/go.mod index 110e426fb..2984a00cc 100644 --- a/go.mod +++ b/go.mod @@ -149,7 +149,7 @@ require ( github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.4 // indirect + github.com/hashicorp/go-getter v1.7.5 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect diff --git a/go.sum b/go.sum index d3a16f130..f60663cd1 100644 --- a/go.sum +++ b/go.sum @@ -780,8 +780,8 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.4 h1:3yQjWuxICvSpYwqSayAdKRFcvBl1y/vogCxczWSmix0= -github.com/hashicorp/go-getter v1.7.4/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4= +github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=