diff --git a/README.md b/README.md index e495efb..2a35e99 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,63 @@ -# Namada Masp Indexer +# 🟡 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. +## About -## Status +This repository, **Namada MASP Indexer**, is distinct from and incomparable to the similarly named [Namada Indexer](https://github.com/anoma/namada-indexer). -⚠️ This project is still a work-in-progress, use at your own risk! ⚠️ +Note that: `Namada Indexer != Namada MASP Indexer && Namada MASP Indexer != Namada Indexer`. -## How to run +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. -- Copy the `.env.template` to `.env` file and edit the necessary variables. -- Run `docker compose up` +# 🚀 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 +``` + +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 + +# 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..d664b35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,10 +12,14 @@ 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 + restart: unless-stopped + block-index: image: namada-masp-block-index build: @@ -29,6 +33,7 @@ services: condition: service_healthy extra_hosts: - "host.docker.internal:host-gateway" + restart: unless-stopped webserver: image: namada-masp-webserver @@ -42,7 +47,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 +65,8 @@ services: postgres: condition: service_healthy extra_hosts: - - "host.docker.internal:host-gateway" \ No newline at end of file + - "host.docker.internal:host-gateway" + restart: unless-stopped + +volumes: + postgres-data: diff --git a/webserver/Dockerfile b/webserver/Dockerfile index bd4ee46..08c496a 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