docs.waku.org/docs/guides/run-nwaku-node.md

112 lines
4.9 KiB
Markdown
Raw Normal View History

2023-06-08 13:28:25 +01:00
---
2023-06-09 20:32:04 +01:00
title: Run a Nwaku Node
2023-06-08 13:28:25 +01:00
---
2023-06-14 01:26:55 +01:00
Nwaku (formerly `nim-waku`) is a lightweight and robust Nim client for running a Waku node, equipped with tools to monitor and maintain a running node. Nwaku is highly configurable, enabling operators to select the [protocols](/overview/concepts/protocols) they want to support based on their needs, motivations, and available resources.
2023-06-08 13:28:25 +01:00
This guide provides detailed steps to build, configure, and connect a `nwaku` node to the Waku Network. It also covers using existing tools to monitor and maintain the node.
2023-06-15 03:09:14 +01:00
:::info
Nwaku can be built and run on Linux and macOS, while Windows support is currently experimental.
:::
2023-06-08 13:28:25 +01:00
## Build the Node
2023-06-15 03:09:14 +01:00
Before running a `nwaku` node, it is necessary to build it. Nwaku provides multiple options for building a node:
2023-06-09 20:32:04 +01:00
| | Description | Documentation |
| - | - | - |
| Precompiled Binary | Download a precompiled binary of the `nwaku` node | [Download Nwaku Binary](https://github.com/waku-org/nwaku/tags) |
2023-06-15 14:54:02 +01:00
| Build Source | Build a `nwaku` node directly from the source code | [Build Nwaku from Source](/guides/nwaku/build-source) |
2023-06-14 13:08:58 +01:00
| Docker Container | Build and run a `nwaku` node in a Docker Container | [Run Nwaku in Docker Container](/guides/nwaku/run-docker) |
2023-06-15 03:09:14 +01:00
| Docker Compose | Build and run a `nwaku` node with Docker Compose | [Run Nwaku with Docker Compose](/guides/nwaku/run-docker-compose) |
2023-06-09 20:32:04 +01:00
2023-06-15 03:09:14 +01:00
:::tip
2023-06-15 04:33:19 +01:00
- If you want to try the latest `nwaku` updates without compiling the binaries, [download the nightly release](https://github.com/waku-org/nwaku/releases/tag/nightly).
- You can run `nwaku` binaries and Docker images on cloud service providers like [Google Cloud](https://cloud.google.com/), [Microsoft Azure](https://azure.microsoft.com/), [Amazon Web Services](https://aws.amazon.com/), and [DigitalOcean](https://www.digitalocean.com/).
2023-06-09 20:32:04 +01:00
:::
## Run the Node
Once you have built the `nwaku` node, run it using the default configuration:
```bash
# Run with default configuration
./build/wakunode2
# See available command line options
./build/wakunode2 --help
```
By default, a `nwaku` node is configured to do the following:
2023-06-14 01:26:55 +01:00
- Generate a new private key and `PeerID`.
2023-06-09 20:32:04 +01:00
- Listen for incoming libp2p connections on the default TCP port (`60000`).
- Subscribe to the default Pub/Sub topic (`/waku/2/default-waku/proto`).
2023-06-10 00:17:41 +01:00
- Start the `JSON-RPC` HTTP server on the default port (`8545`).
2023-06-09 20:32:04 +01:00
- Enable the `Relay` protocol for relaying messages.
2023-06-14 01:26:55 +01:00
- Enable the `Store` protocol as a client, allowing it to query peers for historical messages but not store any message itself.
2023-06-09 20:32:04 +01:00
2023-06-14 13:08:58 +01:00
:::tip
2023-06-15 14:54:02 +01:00
For more advanced configurations like enabling other protocols or maintaining a consistent `PeerID`, please refer to the [Node Configuration](/guides/nwaku/configuration) guide.
2023-06-09 20:32:04 +01:00
:::
2023-06-08 13:28:25 +01:00
## Connect the Node
2023-06-09 20:32:04 +01:00
To join the Waku Network, nodes must connect with peers. Nwaku provides multiple [peer discovery](/overview/concepts/peer-discovery) mechanisms for locating other peers:
| | Description | Documentation |
| - | - | - |
| Predefined Nodes | Configure the bootstrap nodes that `nwaku` should establish connections upon startup | [Configure Predefined Nodes](https://github.com/waku-org/nwaku/blob/master/docs/operators/how-to/connect.md#option-1-configure-peers-statically) |
2023-06-14 01:26:55 +01:00
| DNS Discovery | Enable `nwaku` to locate peers to connect to using the `DNS Discovery` mechanism | [Configure DNS Discovery](https://github.com/waku-org/nwaku/blob/master/docs/operators/how-to/configure-dns-disc.md) |
| Discv5 | Enable `nwaku` to locate peers to connect to using the `Discv5` mechanism | [Configure Discv5](https://github.com/waku-org/nwaku/blob/master/docs/operators/how-to/connect.md#option-3-discover-peers-using-waku-discovery-v5) |
2023-06-09 20:32:04 +01:00
2023-06-14 13:08:58 +01:00
:::tip
2023-06-09 20:32:04 +01:00
You can configure a `nwaku` node to use multiple peer discovery mechanisms simultaneously.
:::
2023-06-08 13:28:25 +01:00
## Interact with the Node
2023-06-09 20:32:04 +01:00
You can interact with a running `nwaku` node through the [JSON RPC API](https://rfc.vac.dev/spec/16/), such as querying the node information using the `get_waku_v2_debug_v1_info` method:
2023-06-14 01:26:55 +01:00
```mdx-code-block
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
```
<Tabs>
<TabItem value="request" label="Request">
2023-06-09 20:32:04 +01:00
```bash
2023-06-14 01:26:55 +01:00
curl --location --request GET 'http://localhost:8545' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": "id",
"method": "get_waku_v2_debug_v1_info",
"params": []
}'
2023-06-09 20:32:04 +01:00
```
2023-06-14 01:26:55 +01:00
</TabItem>
<TabItem value="response" label="Response">
2023-06-09 20:32:04 +01:00
```json
{
2023-06-14 01:26:55 +01:00
"jsonrpc": "2.0",
"id": "id",
"result": {
"listenAddresses": [
"/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmUbPquFQqje3jiqoB5YoiUbBya59NB4qqEzeiTNGHeA6w"
2023-06-09 20:32:04 +01:00
],
2023-06-14 01:26:55 +01:00
"enrUri": "enr:-Iu4QCQZXZDb_JsYmLoYor0F5E_95HbIywgO_wgx2rIdDbmCJZkTzmlCr0wmMzV47lgik_tVwww5mIng90Ris83TisMBgmlkgnY0gmlwhAAAAACJc2VjcDI1NmsxoQPszztG-Ev52ZB7tk0jF8s6Md4KvyY_rhzNZokaaB_ABIN0Y3CC6mCFd2FrdTIB"
2023-06-09 20:32:04 +01:00
}
}
2023-06-10 00:17:41 +01:00
```
2023-06-14 01:26:55 +01:00
</TabItem>
</Tabs>
2023-06-10 00:17:41 +01:00
:::info
The `listenAddresses` field stores the transport addresses for accepting connections, while the `enrUri` field stores the `ENR` URI for peer discovery.
:::