Skip to content

Commit

Permalink
Add testnet README (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkysel authored Oct 10, 2024
1 parent c9e7218 commit a29e144
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 18 deletions.
25 changes: 7 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# xmtpd

[![Test](https://github.com/xmtp/xmtpd/actions/workflows/test.yml/badge.svg)](https://github.com/xmtp/xmtpd/actions/workflows/test.yml)
[![Build](https://github.com/xmtp/xmtpd/actions/workflows/build.yml/badge.svg)](https://github.com/xmtp/xmtpd/actions/workflows/build.yml)
[![Publish](https://github.com/xmtp/xmtpd/actions/workflows/publish-node.yml/badge.svg)](https://github.com/xmtp/xmtpd/actions/workflows/publish-node.yml)
[![Build](https://github.com/xmtp/xmtpd/actions/workflows/build-xmtpd.yml/badge.svg)](https://github.com/xmtp/xmtpd/actions/workflows/build-xmtpd.yml)

**⚠️ Experimental:** This software is in early development. Expect frequent changes and unresolved issues.

Expand All @@ -18,6 +17,7 @@ To keep up with and provide feedback about `xmtpd` development, see the [Issues

- [Go 1.22](https://go.dev/doc/install) -- On macOS install with `brew install go@1.22`
- [Docker](https://www.docker.com/get-started/)
- [Foundry](https://github.com/foundry-rs/foundry)

Note that a dependency of this repo will not compile with version of go newer than 1.22.

Expand All @@ -35,8 +35,6 @@ This starts the following background services in Docker:

- A [Prometheus](https://prometheus.io/) instance that enables you to view metrics and data about the node, such as resource usage and errors

- A [Grafana](https://grafana.com/) instance that enables you to monitor the health and performance of the node

To stop the background services running in Docker, run:

```sh
Expand All @@ -63,24 +61,13 @@ These tests provide a full suite of unit and integration tests for the `xmtpd` r

## Monitor the node

The `xmtpd` node build provides two options for monitoring your node.

- To access your local Prometheus instance to explore node metrics, run:
To enable metrics you need to start the node with `--metrics.enable`.
By default, we expose Prometheus metrics on port `8008`.

```sh
open http://localhost:9090
curl http://localhost:8008
```

To learn how to query node data in Prometheus, see [Metric Types in Prometheus and PromQL](https://promlabs.com/blog/2020/09/25/metric-types-in-prometheus-and-promql) and [The Anatomy of a PromQL Query](https://promlabs.com/blog/2020/06/18/the-anatomy-of-a-promql-query/).

- To access your local Grafana instance to explore and build node dashboards, run:

```sh
open http://localhost:3000
```

To learn how to visualize node data in Grafana, see [Prometheus Histograms with Grafana Heatmaps](https://towardsdatascience.com/prometheus-histograms-with-grafana-heatmaps-d556c28612c7) and [How to visualize Prometheus histograms in Grafana](https://grafana.com/blog/2020/06/23/how-to-visualize-prometheus-histograms-in-grafana/).

# Contributing

Please follow the [style guide](https://google.github.io/styleguide/go/decisions).
Expand All @@ -93,6 +80,8 @@ Submit and land a PR to https://github.com/xmtp/proto. Then run:
dev/generate
```

Or wait for the [nightly automation](https://github.com/xmtp/xmtpd/actions/workflows/nightly.yml) to finish.

## Modifying the database schema

Create a new migration by running:
Expand Down
101 changes: 101 additions & 0 deletions doc/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# How to deploy to Testnet

**⚠️ Experimental:** warning, this file might be out of date!

## Deploy a new Contract

The current environment lives in [Conduit Testnet Staging](https://explorer-testnet-staging-88dqtxdinc.t.conduit.xyz/).
To deploy a new contract you need to run `./dev/contracts/deploy-testnet`
You will need:
- $PRIVATE_KEY which is accessible to all members of @ephemerahq/backend
- $VERIFIER_URL: https://explorer-testnet-staging-88dqtxdinc.t.conduit.xyz/api
- $RPC_URL: https://rpc-testnet-staging-88dqtxdinc.t.conduit.xyz/

If the contract gets deployed correctly, you will get a few addresses.
We definitely need the node contract address (for example `0x7c9A7c92e21E9aC25Ce26C5e724920D84BD5BD9b`)

## Register nodes

Before nodes can start or peer, they need to be registered with the contract.
To do so, run:
```shell
export XMTPD_CONTRACTS_RPC_URL="https://rpc-testnet-staging-88dqtxdinc.t.conduit.xyz/"
export XMTPD_CONTRACTS_CHAIN_ID=34498
export XMTPD_CONTRACTS_NODES_ADDRESS=<from above>
export PRIVATE_KEY=<secret>

dev/cli register-node \
--http-address=<node DNS> \
--owner-address=0xd27FDB90A393Ce0E390120aeB58b326AbA910BE0 \
--admin-private-key=$PRIVATE_KEY \
--signing-key-pub=<node pub key>
```

You need to register all (both) nodes with their correct DNS entries and public keys.

### Verify Registration

To verify registration, use:
```shell
export XMTPD_CONTRACTS_RPC_URL="https://rpc-testnet-staging-88dqtxdinc.t.conduit.xyz/"
export XMTPD_CONTRACTS_CHAIN_ID=34498
export XMTPD_CONTRACTS_NODES_ADDRESS=<from above>
export PRIVATE_KEY=<secret>

dev/cli get-all-nodes \
--admin-private-key=$PRIVATE_KEY
```

And you should get something along these lines:
```json
{
"size": 2,
"nodes": [
{
"NodeId": 100,
"Node": {
"SigningKeyPub": "BOVELF0f4vAra5oaOGODp3ZoYLQKYHmgIjmU/6LOEFEsToqIY97q2FnD1lQKsgJsgvi4k8HFvvbGP0fZ3zOiB9s=",
"HttpAddress": "https://grpc.testnet.xmtp.network",
"IsHealthy": true
}
},
{
"NodeId": 200,
"Node": {
"SigningKeyPub": "BPwmHUOgFTU5pMZMKXY8sOfjd8DqwpEMPUvtsiNaxwNxz+fKU3SsqOdYJQDVjLfRL5XsA5XVZIge2WDZ7S0zpx4=",
"HttpAddress": "https://grpc2.testnet.xmtp.network",
"IsHealthy": true
}
}
]
}

```

## Deploy XMTPD nodes

Node deployment is currently fully handled by [Ephemera](https://github.com/ephemeraHQ/infrastructure) and only members of @ephemerahq/backend have access to it.

There are currently two nodes running:

| DNS Name | Location | Public Key |
| --- | ---| -- |
| https://grpc.testnet.xmtp.network | US-EAST-2 | 0x03e5442c5d1fe2f02b6b9a1a386383a7766860b40a6079a0223994ffa2ce10512c |
| https://grpc2.testnet.xmtp.network | EU-NORTH-1 | 0x02fc261d43a0153539a4c64c29763cb0e7e377c0eac2910c3d4bedb2235ac70371 |

For more info, refer to the infrastructure README.

### Verify deployed nodes

The easiest way is to use [GRPC Health Probe](https://github.com/grpc-ecosystem/grpc-health-probe)


```shell
grpc-health-probe -tls -addr grpc.testnet.xmtp.network:443
status: SERVING
```

```shell
grpc-health-probe -tls -addr grpc2.testnet.xmtp.network:443
status: SERVING
```

0 comments on commit a29e144

Please sign in to comment.