Skip to content

pyth-network/beacon

Repository files navigation

Pyth Beacon

Beacon is a highly available version of Wormhole Spy. It connects to the Wormhole peer-to-peer gossip network, providing the Spy GRPC API to clients for fetching Wormhole VAAs. Beacon uses NATS as a message broker to aggregate VAAs from multiple clients, minimizing latency and maximizing availability.

Why Beacon?

Beacon enhances the Wormhole Spy for high availability and reduced latency. By deploying multiple replicas, it mitigates the unpredictable latency of a single Spy instance due to the peer-to-peer network's peer selection algorithm. Beacon aggregates VAAs in a NATS stream while deduplicating them, ensuring minimal latency and maximum availability. It includes a health check mechanism to detect and address high latency issues.

How to use Beacon?

To run Beacon, you need to have Go v1.20.10 or older and nats-server installed.

Run a NATS server using this command:

nats-server --jetstream

Configure Beacon by setting the required environment variables in .envrc.sample, including NATS_URL and NATS_STREAM. Then, start Beacon with the following command:

make run

Alternatively, you can use the Docker image of Beacon published here.

Using Beacon in Production

For optimal performance, co-locate Beacon with the NATS server to minimize overal latency. Run multiple Beacon instances to increase availability and reduce latency, but be mindful that this will scale network traffic. Utilize the health check probe to monitor VAA latency and restart instances if they become unhealthy.

Wormhole P2P configuration

You can find the Wormhole peer-to-peer network configuration here.