Are you interested in exploring the new developments in XMTP (eXtensible Message Transport Protocol)? If so, you're in luck! XMTP has recently released their development node code base on their GitHub repository.
This blog will walk you through the steps to set up an XMTP node on your local machine. However, we should mention that during our setup process, we encountered a few issues and errors. We will discuss these problems in detail, along with their solutions.
Let's get started!
Installing XMTPD
Step 1: Install Go and Docker
Before we dive into setting up the XMTP node, make sure you install Go lang and Docker with Docker Compose. These are essential prerequisites for a smooth setup process.
Step 2: Clone the Code Repository
Once you have the dependencies installed, clone the XMTPD code repository from GitHub. Use the following command to clone the repository:
git clone <repository_url>
Step 3: Start Docker Compose
Navigate into the cloned repository and run the command dev/up
. This command will start Docker Compose and initialize the required pods. If everything goes well, you should see the following output:
~/repo/xmtpd$ dev/up
[+] Running 4/4
✔ Network xmtpd_default Created 0.0s
✔ Container xmtpd-postgres-1 Started 1.1s
✔ Container xmtpd-prometheus-1 Started 1.1s
✔ Container xmtpd-grafana-1 Started 0.9s
Step 4: Start XMTP Deamon Node To start the XMTPD node, run the command dev/up
. This command will initiate the node and print relevant information. If the node starts successfully, you should see an output similar to the following:
~/repo/xmtpd$ dev/start
2023-06-02T16:46:12.276-0400 INFO running {"git-commit": "a4d05e0ae79062206f0bf25e48e3982966fc85bd"}
2023-06-02T16:46:12.276-0400 INFO started admin interface {"address": "0.0.0.0:6666"}
2023-06-02T16:46:12.276-0400 INFO using memory store
2023-06-02T16:46:12.276-0400 INFO api serving grpc {"address": "[::]:5000"}
2023-06-02T16:46:12.278-0400 INFO api serving http {"address": "[::]:5001"}
2023-06-02T16:46:12.281-0400 INFO p2p listening {"node": "12D3KooWL6rAn3Z7f6tDZ4sxxom6DLu7BAhueqYVUqMuLidZF4aQ", "addresses": ["/ip4/0.0.0.0/tcp/9000/p2p/12D3KooWL6rAn3Z7f6tDZ4sxxom6DLu7BAhueqYVUqMuLidZF4aQ"]}
2023-06-02T16:46:12.308-0400 INFO starting topic reaper {"period": 60000000000}
However, if you encounter any errors, here are a few useful tricks and tips to help you resolve them.
Troubleshooting: Issues and Errors
During our setup process, we encountered a couple of issues and errors. Here's how we resolved them:
Issue 1: Missing MockGen
If you encounter an issue running dev/up
due to a missing Mockgen, you might see the following error message:
bash
dev/generate: line 6: mockgen: command not found
To mitigate this error, run the following command in the repository itself:
go get -v -u github.com/golang/mock/mockgen
This command will install the missing Mockgen and resolve the issue.
Issue 2: Mockgen Issue after Installing Mockgen
If you still encounter the Mockgen not found
error after installing Mockgen, you can try running the following command:
bash
export PATH=$PATH:$(go env GOPATH)/bin
This command ensures that 'Mockgen' is included in your system's PATH variable, which should resolve the issue.
Issue 3: Not Finding Postgresql
If you see an error message related to Postgresql while running dev/start
, such as:
~/repo/xmtpd$ dev/start
2023-06-02T16:18:55.636-0400 INFO running {"git-commit": "a4d05e0ae79062206f0bf25e48e3982966fc85bd"}
2023-06-02T16:18:55.636-0400 INFO started admin interface {"address": "0.0.0.0:6666"}
2023-06-02T16:18:55.636-0400 INFO using postgres store
error initializing postgres: EOF
exit status 1
You can resolve this error by making changes to the dev/start
file. Apply the following code changes to start without Postgres:
index 46e508f..ed25960 100755
--- a/dev/start
+++ b/dev/start
@@ -10,6 +10,6 @@ dev/run \
--p2p.port=9000 \
--api.grpc-port=5000 \
--api.http-port="${PORT}" \
- --store.type=postgres \
+ --store.type=mem \
--topic-reaper-period=1m \
"$@"
This change modifies the --store.type
flag from postgres
to mem
, which uses an in-memory store instead. Adjust your code accordingly based on the provided git diff.
Stopping Nodes
Once you have successfully set up and tested the XMTPD node, you may want to stop it from running. To stop the node, use the ctrl+c
command. Additionally, you can stop all other containers by running dev/down
, which will stop all running containers related to XMTPD.
~/repo/xmtpd$ dev/down
[+] Running 4/4
✔ Container xmtpd-grafana-1 Removed 0.6s
✔ Container xmtpd-prometheus-1 Removed 0.8s
✔ Container xmtpd-postgres-1 Removed 0.9s
✔ Network xmtpd_default Removed 0.3s
We hope this guide has helped you set up an XMTPD node successfully. If you would like to explore more about XMTPD, you can visit their official website here.
For any further inquiries or projects, feel free to contact Percs here.
Happy learning with XMTPD!