Thanks to visit codestin.com
Credit goes to github.com

Skip to content

blebbit/testnet

Repository files navigation

TestNet

Our setup for building an independent ATProtocol network. It runs the same code as mainnet, production built and configured.

The intention is to run a testnet where the atmosphere can do wild experiments. For example, this setup runs our Permissioned PDS so we can make sure our patches are backwards compatible with mainnet and the protocol.

Following the steps below, you can create your own testnet or independent atproto network. One the foundation settles, we will open our testnet to others.

Setup

Deps:

# build the images
make images

# initialize an env
make env

Warning

You need to adjust the <component>.env files. Most should be straight forward. Follow the PDS setup guide for that one... Depening on how you wish to expose the services, various ENV files will need adjusting. (mainly the PDS again)

k3s / kubernetes setup

There are two methods, docker compose and kubernetes. If you want an easy to use, single-node setup to try it out, we recommend k3s, which handles all the dependencies, has good defaults, and starts in about 30s. It also supports multi-node setups

# install k3s
curl -sfL https://get.k3s.io | sh -

# make config file as user
export KUBECONFIG=~/.kube/config
mkdir -p ~/.kube
sudo k3s kubectl config view --raw > "$KUBECONFIG"
chmod 600 "$KUBECONFIG"

Lifecycle the network

With Docker Compose

make up
make down
make clean

With Kubernetes

Warning

If the k3s machine is not the same as this repo cloned, you'll need to push the images to your preferred registry or copy them over manually.

Caution

You can expose the services to the public internet if you wish. This should be done before you run the following commands. See the sections below on exposing depending on your runtime and networking choices.

# Set the expose method, empty means not exposed, see options below
export TESTNET_EXPOSE=

# pick a top-level domain you control
export TESTNET_DOMAIN=example.com

# prepare kubernetes
make k8s.operators

# prepare namespace
make k8s.namespace

# install testnet services
make plc.service
make relay.service
make jetstream.service
make pds.service

Exposing the services

Domains

For cloudflare tunnels, you need to use a top-level domain because they limit free certs to a single subdomain.

We haven't tried tailscale yet, but it should match the telnet you want to use. There are links to references we intended to use if/when we get to this.

  • plc.<domain>
  • relay.<domain>
  • jetstream.<domain>
  • pds.<domain>
  • *.pds.<domain>/.well-known/atproto-did

Cloudflare Docker Compose setup

Setup a cloudflared tunnel on the host and set the following rules. You can use the UI or CLI as well as adjust the ports by editing the CUE files.

Caution

You will need Advanced Certificate Manager in order to have TLS on the handle domains so that various ATProto tooling can map handle to did. If you use custom identity resolution, you can avoid this requirement.

  • plc.<domain> -> :7000
  • relay.<domain> -> :7001
  • jetstream.<domain> -> :7002
  • pds.<domain> -> :6000
  • *.pds.<domain>/.well-known/atproto-did -> :6000

Cloudflare Kubernetes setup

Follow this tutorial: https://itnext.io/exposing-kubernetes-apps-to-the-internet-with-cloudflare-tunnel-ingress-controller-and-e30307c0fcb0

You only need to follow these sections and set the ENV vars below. The scripts will handle the operator installs, secret creation, and helm invocations.

Sections

  1. Pick a top-levl domain name you own
  2. Cloudflare Token (apikey & email)
  3. Create the tunnel (tunnel-name/id & json_creds)
  4. Change Cloudflare TLS mode
export TESTNET_EXPOSE=cloudflare
export CLOUDFLARE_APIKEY=...
export CLOUDFLARE_EMAIL=...
export CLOUDFLARE_TUNNEL_NAME=testnet
export CLOUDFLARE_TUNNEL_ID=...
export CLOUDFLARE_JSON_CREDS=/home/bob/.cloudflared/<tunnel-id>.json

Tailscale setup

tbd

export TESTNET_EXPOSE=tailscale
export TAILSCALE_CLIENT=...
export TAILSCALE_SECRET=...

Create accounts

You can use the normal pdsadmin scripts, copied into the local pds directory for convenience.

The goat tool now has these features too!

Using Testnet

The main difference is how identity resolution happens (i.e. handle->did->pds). You must configure the @atproto/identity to use the testnet PLC. The Agent works as normal because you configure it with the PDS, from identity resolution, prior to usage; and that PDS is also configured to use the same PLC.

See examples directory for the code and details.

References, Notes, and Links

About

Run independent ATProtocol networks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published