Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 55 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <copied-url>
cd <repository-name>
```

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

Expand Down
25 changes: 20 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -29,6 +33,7 @@ services:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped

webserver:
image: namada-masp-webserver
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localhost is wrong here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks correct to me. Also, it works fine. We have the same healthcheck in Namada Indexer.

63513c4b49c9 namada-masp-webserver "./webserver" 4 minutes ago Up 24 seconds (healthy) 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp

interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped

crawler:
build:
context: .
Expand All @@ -54,4 +65,8 @@ services:
postgres:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
- "host.docker.internal:host-gateway"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, the Crawler doesn't connect to Docker. We have the same for block-index. Tested and verified again.

restart: unless-stopped

volumes:
postgres-data:
2 changes: 1 addition & 1 deletion webserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down