Skip to content

Commit

Permalink
Merge pull request #169 from anoma/bengt/namadexer
Browse files Browse the repository at this point in the history
Bengt/namadexer
  • Loading branch information
bengtlofgren authored Oct 10, 2023
2 parents b0b9cd2 + 52fc600 commit dffa6b8
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 7 deletions.
6 changes: 5 additions & 1 deletion packages/docs/pages/integrating-with-namada.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
This guide is for integrating with Namada. It is intended for developers who want to integrate with Namada in their own applications, and for engineers who want to extend Namada.

## License
Namada operates under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.html) and is free to use and modify. Please see the [LICENSE](https://github.com/anoma/namada/blob/main/LICENSE) for more information.
Namada operates under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.html) and is free to use and modify. Please see the [LICENSE](https://github.com/anoma/namada/blob/main/LICENSE) for more information.

## Table of Contents
- [SDK](./integrating-with-namada/sdk.mdx)
- [Indexer](./integrating-with-namada/indexer.mdx)
103 changes: 103 additions & 0 deletions packages/docs/pages/integrating-with-namada/indexer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import Expandable from '../../components/Expandable';
import { Callout } from 'nextra-theme-docs'

# Namada Indexer

In collaboration with [Zondax](https://zondax.ch/), an indexer for the Namada blockchain has been born.

The Namada indexer (a.k.a `namadexer`) constantly queries the Namada blockchain, and together with the [SDK](./sdk.mdx), is able to map blocks, transactions, along with other valuable information into a relational database (postgres).

This is especially useful for performing analytics over the blockchain, including storing historical data in a way that could be easily queried.

## Setting up

The namada indexer's source code can be found [here](https://github.com/zondax/namadexer) and is simple to set up.

The `namadexer` works best together with [Docker](https://www.docker.com/products/docker-desktop)

```bash
git clone https://github.com/Zondax/namadexer.git
cd namadexer
make compose
```

## Running the server and db
Once the DockerFile has run, it is straightforward to both set up the postgres database as well as the server that will query the database.

Make sure that `postgres` [is installed](https://www.postgresql.org/download/) on the local machine.

**Run postgres in docker**
```bash
make postgres
# or run (and change arguments, e.g port):
# docker run --name postgres -e POSTGRES_PASSWORD=wow -e POSTGRES_DB=blockchain -p 5432:5432 -d postgres
```
Once the postgres server is up and running, it is time to set up the server that will query the postgres db.

Execute the following command in order to set up the server
```
make run_server
```

If successful, the server should be running as a daemon on the localhost at port `30303`.

## Run the indexer

First, ensure that the `Settings.toml` within `config/Settings.toml` is configured correctly.

<Expandable>
```toml
log_level = "info"
network = "public-testnet-14"

[database]
host = "0.0.0.0:5435"
user = "postgres"
password = "wow"
dbname = "blockchain"
# Optional field to configure a timeout if database connection
# fails.
connection_timeout = 20


[server]
serve_at = "0.0.0.0"
port = 30303

[indexer]
tendermint_addr = "0.0.0.0"
port = 26657

[jaeger]
enable = false
host = "localhost"
port = 6831

[prometheus]
host = "0.0.0.0"
port = 9000
```

</Expandable>

<Callout type="info" emoji="👀">
**Interpreting the toml**

It is important to change the following parameters:

1. `indexer.tendermint_addr` - This should be the address and corresponding port of a synced Namada full node

2. `database.host` - This should be the tcp address (with port) where the postgres database is running.
</Callout>

Once the setup is complete, it is possible to start the indexer

```bash
make run_indexer
```

## Querying the database

The pre-defined endpoints to query the database are described in the documentation [here](https://github.com/Zondax/namadexer/blob/main/docs/04-server.md).


12 changes: 6 additions & 6 deletions packages/docs/pages/operators/ibc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Below, we discuss first how to enable this connection between two pre-existing c

## Setup Hermes
Hermes is an IBC relayer to relay IBC packets between chains (instances).
We have our [fork of Hermes supporting Namada instances](https://github.com/heliaxdev/hermes/tree/1.6.0-namada).
Before packet relay, we need the following steps to configure and start Hermes.
Namada uses a [fork of Hermes supporting Namada instances](https://github.com/heliaxdev/hermes/tree/1.6.0-namada).
Before packet relay, the user needs the following steps to configure and start Hermes.

1. Make Hermes config file
2. Create IBC client/connection/channel between instances
Expand Down Expand Up @@ -113,7 +113,7 @@ These are the pieces of this puzzle you want to keep your 👀 on:
Hermes CLI has commands to create them. Before the creation, a node of each instance should be running at the specified rpc addresses. If you don't have nodes, please set up nodes manually or through our [scripts](#set-up-local-namada-instances-using-the-hermes-script).

### Export environment variables
We will need to save certain environment variables. These are:
The relaying user will need to save certain environment variables. These are:
```bash copy
export CHAIN_A_ID="<replace-with-chain-a-id>"
export CHAIN_B_ID="<replace-with-chain-b-id>"
Expand Down Expand Up @@ -183,7 +183,7 @@ cp $HOME/.local/share/namada/$CHAIN_A_ID/wallet.toml $HERMES/namada_wallet/$CHAI
# Make sure this is done for both wallets on each chain!
```

We are now ready to set up the client.
It is now possible to set up the client.

### Create IBC channel
The "create channel" command (below) creates not only the IBC channel but also the necessary IBC client connection.
Expand Down Expand Up @@ -269,7 +269,7 @@ hermes --config $HERMES_CONFIG start

You can see more details of Hermes at [the official document](https://hermes.informal.systems/).

After the sync, you can create the channel and start Hermes as we explain [above](#create-ibc-channel).
After the sync, you can create the channel and start Hermes as explained [above](#create-ibc-channel).
```bash copy
# create a channel
hermes --config $HERMES_CONFIG \
Expand All @@ -293,7 +293,7 @@ cd hermes
./scripts/setup-namada $NAMADA_DIR $CHAIN_ID_A $CHAIN_ID_B
```

In this case, we don't have to wait for sync. If the relayer account on each instance has enough balance, you can create a channel and start Hermes immediately as we explain [above](#create-ibc-channel). You find these chain IDs of the instances in the config file `config_for_namada.toml`. One can run `grep "id" ${HERMES_CONFIG}`.
In this case, the user doesn't have to wait for sync. If the relayer account on each instance has enough balance, the user can create a channel and start Hermes immediately as explained [above](#create-ibc-channel). The user finds these chain IDs of the instances in the config file `config_for_namada.toml`. One can run `grep "id" ${HERMES_CONFIG}`.
```bash copy
# create a channel
hermes --config $HERMES_CONFIG \
Expand Down

0 comments on commit dffa6b8

Please sign in to comment.