The official documentation is comprehensive for setting up a Chainweb node on the mainnet (refer to Chainweb Get Started). However, deploying on the testnet requires additional configuration, as detailed below.
A Linux machine meeting the minimum requirements (see Chainweb Node README) with the following software installed:
- Docker
- rsync
- Git
This was my configuration: I used a Digital Ocean droplet with 8GB RAM, 2 vCPUs, and an attached volume. Higher disk space is recommended to maintain the full history of the node, especially if it will support a dApp.
Feel free to adjust based on your own requirements and workload.
mkdir testnet && cd testnetSave the following content in docker-compose.yaml:
services:
chainweb-node:
image: chainweb-node-custom
environment:
- CHAINWEB_NETWORK=testnet04
container_name: chainweb-node
ports:
- mode: host
protocol: tcp
published: 1789
target: 1789
- mode: host
protocol: tcp
published: 1848
target: 1848
restart: unless-stopped
volumes:
- ./data:/data
volumes: {}git clone https://github.com/kadena-io/chainweb-node-dockerBefore building the Docker image, edit the configuration file chainweb.testnet04.yaml in the chainweb-node-docker directory if needed. For instance, to enable Pact table read queries, add:
allowReadsInLocal: trueThis step is optional and should be done only if your application requires specific parameters.
After editing the configuration file, build the custom Docker image and tag it as chainweb-node-custom:
cd chainweb-node-docker
docker build -t chainweb-node-custom .Once built, return to the testnet directory:
cd ../testnetThis step significantly reduces the synchronization time (from about a week to a few minutes).
-
Choose a bootstrap node close to your server location. A list of testnet bootstrap nodes is available here.
-
Copy the database using
rsync:
rsync -aP --no-compress --delete --progress "rsync://eu1.testnet.chainweb.com/db/0" ./data/chainweb-dbThis downloads the pre-synced database, saving hours of synchronization time.
Once the database copy is complete, bring up the container:
docker compose up -dAfter a few minutes, you can test the node using curl:
curl -sk https://localhost:1789/chainweb/0.0/testnet04/cutCompare the cut height from your node with the height shown at:
https://api.testnet.chainweb.com/chainweb/0.0/testnet04/cut
If the heights are close and your node's height continues to grow quickly, your node is syncing correctly and should be running fine.
If this setup is on a server, you should configure a reverse proxy with Nginx and Certbot to expose the following ports:
- 1789 (P2P API)
- 1848 (Service API)
Refer to the Chainweb API documentation for detailed information on the exposed endpoints.
To update the node, simply pull the latest changes from the chainweb-node-docker repository and rebuild the Docker image. No additional steps are required if the docker-compose.yaml file remains unchanged.
This tutorial can likely be adapted for testnet05, but it has not been tested by the author. If you want to experiment, you can use the following bootstrap nodes for testnet05:
rsync://us1.testnet05.chainweb.com/db/0rsync://us2.testnet05.chainweb.com/db/0
Please let us know if you succeed in setting up a testnet05 node!
- Special thanks to @peppinho89 for the original
docker-compose.yamlfile. - Additional thanks to Discord user
xiownthispfor guidance (original message in Kadena Discord).
Thank you for this!