From 12391f0696a1bbaff80348e9c6b17900499c8cbf Mon Sep 17 00:00:00 2001 From: maxpower-01 Date: Sun, 23 Feb 2025 12:01:21 +0100 Subject: [PATCH 1/4] docs: update README & .env.template; fix: persistent Postgres volume & webserver healthcheck - README.md: updated installation instructions - .env.template: added an example - persistent postgres volume - webserver: added a curl and healthcheck --- .env.template | 2 +- README.md | 75 +++++++++++++++++++++++++++++++++++--------- docker-compose.yml | 20 +++++++++--- webserver/Dockerfile | 2 +- 4 files changed, 79 insertions(+), 20 deletions(-) diff --git a/.env.template b/.env.template index c0b3294..b69d293 100644 --- a/.env.template +++ b/.env.template @@ -1 +1 @@ -COMETBFT_URL="" \ No newline at end of file +COMETBFT_URL="http://host.docker.internal:26657" \ No newline at end of file diff --git a/README.md b/README.md index e495efb..d5763b7 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,69 @@ -# Namada Masp Indexer - -The [`namada-masp-indexer`](https://github.com/anoma/namada-masp-indexer) is a -specialized indexer that crawls [Namada](https://github.com/anoma/namada) -networks, extracting [MASP](https://github.com/anoma/masp) transaction data. In -addition to indexing fetched MASP transactions, the `namada-masp-indexer` builds -a panoply of data structures that keep track of the state of the current MASP -commitment tree, note positions, etc. By exposing this data via an HTTP RPC API, -Namada clients are able to synchronize with the latest state of the MASP very -quickly, alleviating remote procedure calls to full nodes. +# 🟡 Namada MASP Indexer ## Status -⚠️ This project is still a work-in-progress, use at your own risk! ⚠️ +- 🔧 - This project is a work in progress. +- 🚧 - Functionality is not guaranteed at this stage. +- ⚠️ - Use at your own risk. + +## About + +This repository, **Namada MASP Indexer**, is distinct from and incomparable to the similarly named [Namada Indexer](https://github.com/anoma/namada-indexer). + +Note that: `Namada Indexer != Namada MASP Indexer && Namada MASP Indexer != Namada Indexer`. + +The **Namada MASP Indexer** is a specialized indexer that crawls [Namada](https://github.com/anoma/namada) networks, extracting [MASP](https://github.com/anoma/masp) transaction data. In addition to indexing fetched MASP transactions, the Namada MASP Indexer builds a panoply of data structures that keep track of the state of the current MASP commitment tree, note positions, etc. By exposing this data via an HTTP RPC API, Namada clients are able to synchronize with the latest state of the MASP very quickly, alleviating remote procedure calls to full nodes. + +# 🚀 Getting Started + +Follow these instructions to set up the project locally. The steps below will guide you through the process of getting a local copy up and running. + +It is strongly recommended to change the default username and password for your PostgreSQL database for security purposes. Update these credentials in the `docker-compose.yml` file. + +## 🐳 Docker Deployment + +### Prerequisites + +Before starting, ensure you have the necessary tools and dependencies installed. Below are the steps to set up the required environment. + +- **Packages**: Install prerequisite packages from the APT repository. + +```sh +apt-get install -y curl apt-transport-https ca-certificates software-properties-common git nano just build-essential +``` + +- **Docker**: Follow the official instructions provided by Docker to install it: [Install Docker Engine](https://docs.docker.com/engine/install/). + +### Usage +Ensure you have the latest repository cloned to maintain compatibility with other Namada interfaces. Use the following commands to clone the repository and navigate into its directory. + +```sh +# Clone this repository, copy the URL from the Code button above. +git clone +cd +``` + +Create the `.env` file in the root of the project. You can use the `.env.template` file as a reference. + +```sh +cp .env.template .env +``` +- The `COMETBFT_URL` variable must point to a Namada RPC URL, which can be either public or local. For a public RPC URL, refer to the [Namada Ecosystem Repository](https://github.com/Luminara-Hub/namada-ecosystem/tree/main/user-and-dev-tools/mainnet). If running the Namada Node locally, use the preconfigured `http://host.docker.internal:26657`. +- When running locally, ensure that CometBFT allows RPC calls by setting the the configuration in your `config.toml` file. + +Build the required Docker containers for the project. +```sh +docker compose build +``` -## How to run +Launch the Namada Indexer. +```sh +# Run the Docker containers in the foreground, displaying all logs and keeping the terminal active until stopped. +docker compose up -- Copy the `.env.template` to `.env` file and edit the necessary variables. -- Run `docker compose up` +# Run the Docker containers in detached mode, starting them in the background without showing logs in the terminal. +docker compose up -d +``` ## License diff --git a/docker-compose.yml b/docker-compose.yml index 02876c3..5ca2771 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,9 +12,12 @@ services: healthcheck: test: ["CMD-SHELL", "pg_isready", "-d", "masp_indexer_local"] interval: 5s - timeout: 10s + timeout: 5s retries: 5 - start_period: 80s + volumes: + - type: volume + source: postgres-data + target: /var/lib/postgresql/data block-index: image: namada-masp-block-index @@ -42,7 +45,13 @@ services: DATABASE_URL: postgres://postgres:password@postgres:5432/masp_indexer_local depends_on: - crawler - + healthcheck: + test: curl --fail http://localhost:5000/health || exit 1 + interval: 5s + timeout: 5s + retries: 5 + restart: unless-stopped + crawler: build: context: . @@ -54,4 +63,7 @@ services: postgres: condition: service_healthy extra_hosts: - - "host.docker.internal:host-gateway" \ No newline at end of file + - "host.docker.internal:host-gateway" + +volumes: + postgres-data: diff --git a/webserver/Dockerfile b/webserver/Dockerfile index 19deeb6..41921d7 100644 --- a/webserver/Dockerfile +++ b/webserver/Dockerfile @@ -19,7 +19,7 @@ FROM debian:bookworm-slim AS runtime WORKDIR /app COPY --from=builder /app/target/release/webserver /app/webserver -RUN apt-get update && apt-get install -y libpq5 +RUN apt-get update && apt-get install -y libpq5 curl WORKDIR /app From 9f193f79c9a1837c0f6ca06bd896ef56f2624034 Mon Sep 17 00:00:00 2001 From: maxpower-01 Date: Tue, 25 Feb 2025 13:07:59 +0100 Subject: [PATCH 2/4] docs: update README & .env.template --- .env.template | 2 +- README.md | 6 ------ docker-compose.yml | 2 -- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.env.template b/.env.template index b69d293..c0b3294 100644 --- a/.env.template +++ b/.env.template @@ -1 +1 @@ -COMETBFT_URL="http://host.docker.internal:26657" \ No newline at end of file +COMETBFT_URL="" \ No newline at end of file diff --git a/README.md b/README.md index d5763b7..2a35e99 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,5 @@ # 🟡 Namada MASP Indexer -## Status - -- 🔧 - This project is a work in progress. -- 🚧 - Functionality is not guaranteed at this stage. -- ⚠️ - Use at your own risk. - ## About This repository, **Namada MASP Indexer**, is distinct from and incomparable to the similarly named [Namada Indexer](https://github.com/anoma/namada-indexer). diff --git a/docker-compose.yml b/docker-compose.yml index 5ca2771..4f9b7a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,8 +62,6 @@ services: depends_on: postgres: condition: service_healthy - extra_hosts: - - "host.docker.internal:host-gateway" volumes: postgres-data: From 7dafc8c3e5cd2ea37969fb3bf5b98c723dba05ba Mon Sep 17 00:00:00 2001 From: maxpower-01 Date: Tue, 25 Feb 2025 13:50:05 +0100 Subject: [PATCH 3/4] fix: update docker-compose.yml --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 4f9b7a8..5ca2771 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,6 +62,8 @@ services: depends_on: postgres: condition: service_healthy + extra_hosts: + - "host.docker.internal:host-gateway" volumes: postgres-data: From b01741fa1fe76861422ddd3f7dc5c3c16e4aa714 Mon Sep 17 00:00:00 2001 From: maxpower-01 Date: Tue, 11 Mar 2025 09:44:06 +0100 Subject: [PATCH 4/4] feat(docker): add restart policy to docker-compose.yml add the `restart: unless-stopped` policy to have consistency with the `namada-indexer` --- docker-compose.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5ca2771..d664b35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,8 @@ services: - type: volume source: postgres-data target: /var/lib/postgresql/data - + restart: unless-stopped + block-index: image: namada-masp-block-index build: @@ -32,6 +33,7 @@ services: condition: service_healthy extra_hosts: - "host.docker.internal:host-gateway" + restart: unless-stopped webserver: image: namada-masp-webserver @@ -64,6 +66,7 @@ services: condition: service_healthy extra_hosts: - "host.docker.internal:host-gateway" + restart: unless-stopped volumes: postgres-data: