|
|
@@ -1,54 +1,64 @@
|
|
|
# Pyth Price Service
|
|
|
|
|
|
-This service exposes a REST and WS api to provide latest attestation message for a price feed id.
|
|
|
+The Pyth price service is a webservice that listens to the Wormhole Network for Pyth price updates and serves them via a
|
|
|
+convenient web API. The service allows users to easily query for recent price updates via a REST API, or subscribe to
|
|
|
+a websocket for streaming updates. [The Pyth Network Javascript SDKs](https://github.com/pyth-network/pyth-js) connect
|
|
|
+to an instance of the price service in order to fetch on-demand price updates.
|
|
|
|
|
|
-## Build
|
|
|
+## Public Endpoints
|
|
|
|
|
|
-First, build the wasm container from the repo root:
|
|
|
+The Pyth Data Association operates two public endpoints for the price service, for mainnet and testnet respectively.
|
|
|
+These endpoints can be used to test integrations with Pyth Network:
|
|
|
|
|
|
-```
|
|
|
-docker buildx build -f Dockerfile.wasm -o type=local,dest=. .
|
|
|
-```
|
|
|
+| network | url |
|
|
|
+| ------- | ------------------------------- |
|
|
|
+| mainnet | https://xc-mainnet.pyth.network |
|
|
|
+| testnet | https://xc-testnet.pyth.network |
|
|
|
|
|
|
-Then, build the pyth_price_service docker container from the repo root:
|
|
|
+For production deployments, developers integrating with Pyth Network are **strongly encouraged** to host their own instance of the price service for maximum resilience and decentralization.
|
|
|
+By running an independent instance of this service, developers tap directly into Wormhole's peer-to-peer network to stream Pyth price updates.
|
|
|
+This peer-to-peer network has built-in redundancy and is therefore inherently more reliable than a centralized service operated by the PDA.
|
|
|
|
|
|
-```
|
|
|
-$ docker buildx build -f third_party/pyth/price-service/Dockerfile.price_service -t pyth_price_service .
|
|
|
-```
|
|
|
+## Wormhole Spy
|
|
|
|
|
|
-Run the spy_guardian docker container in TestNet:
|
|
|
+The price service depends on a Wormhole Spy to stream Pyth messages from the Wormhole Network to it. The
|
|
|
+[spy](https://github.com/wormhole-foundation/wormhole/blob/main/node/cmd/spy/spy.go) is a Wormhole component that listens to the Wormhole verified
|
|
|
+messages from the Wormhole Network peer-to-peer network; then, it streams the messages that are coming from certain emitters (e.g., Pyth data emitters) to its subscribers.
|
|
|
|
|
|
-```
|
|
|
-$ docker run --platform linux/amd64 --network=host ghcr.io/certusone/guardiand:v2.8.8.1 spy \
|
|
|
---nodeKey /node.key --spyRPC "[::]:7073" \
|
|
|
---bootstrap /dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWBY9ty9CXLBXGQzMuqkziLntsVcyz4pk1zWaJRvJn6Mmt \
|
|
|
---network /wormhole/testnet/2/1
|
|
|
-```
|
|
|
+The price service subscribes to the spy to fetch all verified prices coming from the Pyth data sources. The Pyth data sources should
|
|
|
+be defined in `SPY_SERVICE_FILTERS` environment variable as a JSON array.
|
|
|
|
|
|
-Or run the spy_guardian docker container in MainNet:
|
|
|
-For the MainNet gossip network parameters, see https://github.com/wormhole-foundation/wormhole-networks/blob/master/mainnetv2/info.md
|
|
|
+## Run
|
|
|
+
|
|
|
+This repository contains testnet and mainnet docker-compose files to run
|
|
|
+both the price service and spy. To run the mainnet docker compose file run
|
|
|
+the following command:
|
|
|
|
|
|
```
|
|
|
-$ docker run --platform linux/amd64 -d --network=host ghcr.io/certusone/guardiand:v2.8.8.1 spy \
|
|
|
---nodeKey /node.key --spyRPC "[::]:7073" \
|
|
|
---bootstrap <guardianNetworkBootstrapParameterForMainNet> \
|
|
|
---network <guardianNetworkPathForMainNet> \
|
|
|
+docker-compose up -f docker-compose.mainnet.yaml
|
|
|
```
|
|
|
|
|
|
-Then to run the pyth_price_service docker container using a config file called `${HOME}/pyth_price_service/env` and logging to directory `${HOME}/pyth_price_service/logs`, do the
|
|
|
-following:
|
|
|
+The compose files use a public release of Pyth price service and spy. If you wish to change the
|
|
|
+price service you should:
|
|
|
+
|
|
|
+1. Build an image for using it first according to the section below.
|
|
|
+2. Change the price service image to your local docker image (e.g., `pyth_price_service`)
|
|
|
+
|
|
|
+## Build an image
|
|
|
+
|
|
|
+First, build the wasm files from [the repo root](../../../) like below. This command generates the wasm files necessary
|
|
|
+for parsing Pyth messages coming from Wormhole and stores them on [this](../p2w-sdk/js/src/solana/p2w-core) directory.
|
|
|
|
|
|
```
|
|
|
-$ docker run \
|
|
|
---volume=${HOME}/pyth_price_service:/var/pyth_price_service \
|
|
|
--e PYTH_PRICE_SERVICE_CONFIG=/var/pyth_price_service/env \
|
|
|
---network=host \
|
|
|
-pyth_price_service
|
|
|
+docker buildx build -f Dockerfile.wasm -o type=local,dest=. .
|
|
|
```
|
|
|
|
|
|
-Or, run docker compose in the `third_party/pyth/price-service` directory using the commands below. It will run a spy listening to the Wormhole testnet network and a price service that connects to it. Then the price service will serve the Pyth prices published to the Wormhole testnet network.
|
|
|
+Then, build the image from [the repo root](../../../) like below. It will create a
|
|
|
+local image named `pyth_price_service`.
|
|
|
|
|
|
```
|
|
|
-$ cd third_party/pyth/price-service
|
|
|
-$ docker compose up
|
|
|
+$ docker buildx build -f third_party/pyth/price-service/Dockerfile.price_service -t pyth_price_service .
|
|
|
```
|
|
|
+
|
|
|
+If you wish to build price service without docker, please follow the instruction of the price service
|
|
|
+[`Dockerfile`](./Dockerfile.price_service)
|