|
1 | 1 | # Pyth Price Service
|
2 | 2 |
|
3 |
| -This service exposes a REST and WS api to provide latest attestation message for a price feed id. |
| 3 | +The Pyth price service is a webservice that listens to the Wormhole Network for Pyth price updates and serves them via a |
| 4 | +convenient web API. The service allows users to easily query for recent price updates via a REST API, or subscribe to |
| 5 | +a websocket for streaming updates. [The Pyth Network Javascript SDKs](https://github.com/pyth-network/pyth-js) connect |
| 6 | +to an instance of the price service in order to fetch on-demand price updates. |
4 | 7 |
|
5 |
| -## Build |
| 8 | +## Public Endpoints |
6 | 9 |
|
7 |
| -First, build the wasm container from the repo root: |
| 10 | +The Pyth Data Association operates two public endpoints for the price service, for mainnet and testnet respectively. |
| 11 | +These endpoints can be used to test integrations with Pyth Network: |
8 | 12 |
|
9 |
| -``` |
10 |
| -docker buildx build -f Dockerfile.wasm -o type=local,dest=. . |
11 |
| -``` |
| 13 | +| network | url | |
| 14 | +| ------- | ------------------------------- | |
| 15 | +| mainnet | https://xc-mainnet.pyth.network | |
| 16 | +| testnet | https://xc-testnet.pyth.network | |
12 | 17 |
|
13 |
| -Then, build the pyth_price_service docker container from the repo root: |
| 18 | +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. |
| 19 | +By running an independent instance of this service, developers tap directly into Wormhole's peer-to-peer network to stream Pyth price updates. |
| 20 | +This peer-to-peer network has built-in redundancy and is therefore inherently more reliable than a centralized service operated by the PDA. |
14 | 21 |
|
15 |
| -``` |
16 |
| -$ docker buildx build -f third_party/pyth/price-service/Dockerfile.price_service -t pyth_price_service . |
17 |
| -``` |
| 22 | +## Wormhole Spy |
18 | 23 |
|
19 |
| -Run the spy_guardian docker container in TestNet: |
| 24 | +The price service depends on a Wormhole Spy to stream Pyth messages from the Wormhole Network to it. The |
| 25 | +[spy](https://github.com/wormhole-foundation/wormhole/blob/main/node/cmd/spy/spy.go) is a Wormhole component that listens to the Wormhole verified |
| 26 | +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. |
20 | 27 |
|
21 |
| -``` |
22 |
| -$ docker run --platform linux/amd64 --network=host ghcr.io/certusone/guardiand:v2.8.8.1 spy \ |
23 |
| ---nodeKey /node.key --spyRPC "[::]:7073" \ |
24 |
| ---bootstrap /dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWBY9ty9CXLBXGQzMuqkziLntsVcyz4pk1zWaJRvJn6Mmt \ |
25 |
| ---network /wormhole/testnet/2/1 |
26 |
| -``` |
| 28 | +The price service subscribes to the spy to fetch all verified prices coming from the Pyth data sources. The Pyth data sources should |
| 29 | +be defined in `SPY_SERVICE_FILTERS` environment variable as a JSON array. |
27 | 30 |
|
28 |
| -Or run the spy_guardian docker container in MainNet: |
29 |
| -For the MainNet gossip network parameters, see https://github.com/wormhole-foundation/wormhole-networks/blob/master/mainnetv2/info.md |
| 31 | +## Run |
| 32 | + |
| 33 | +This repository contains testnet and mainnet docker-compose files to run |
| 34 | +both the price service and spy. To run the mainnet docker compose file run |
| 35 | +the following command: |
30 | 36 |
|
31 | 37 | ```
|
32 |
| -$ docker run --platform linux/amd64 -d --network=host ghcr.io/certusone/guardiand:v2.8.8.1 spy \ |
33 |
| ---nodeKey /node.key --spyRPC "[::]:7073" \ |
34 |
| ---bootstrap <guardianNetworkBootstrapParameterForMainNet> \ |
35 |
| ---network <guardianNetworkPathForMainNet> \ |
| 38 | +docker-compose up -f docker-compose.mainnet.yaml |
36 | 39 | ```
|
37 | 40 |
|
38 |
| -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 |
39 |
| -following: |
| 41 | +The compose files use a public release of Pyth price service and spy. If you wish to change the |
| 42 | +price service you should: |
| 43 | + |
| 44 | +1. Build an image for using it first according to the section below. |
| 45 | +2. Change the price service image to your local docker image (e.g., `pyth_price_service`) |
| 46 | + |
| 47 | +## Build an image |
| 48 | + |
| 49 | +First, build the wasm files from [the repo root](../../../) like below. This command generates the wasm files necessary |
| 50 | +for parsing Pyth messages coming from Wormhole and stores them on [this](../p2w-sdk/js/src/solana/p2w-core) directory. |
40 | 51 |
|
41 | 52 | ```
|
42 |
| -$ docker run \ |
43 |
| ---volume=${HOME}/pyth_price_service:/var/pyth_price_service \ |
44 |
| --e PYTH_PRICE_SERVICE_CONFIG=/var/pyth_price_service/env \ |
45 |
| ---network=host \ |
46 |
| -pyth_price_service |
| 53 | +docker buildx build -f Dockerfile.wasm -o type=local,dest=. . |
47 | 54 | ```
|
48 | 55 |
|
49 |
| -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. |
| 56 | +Then, build the image from [the repo root](../../../) like below. It will create a |
| 57 | +local image named `pyth_price_service`. |
50 | 58 |
|
51 | 59 | ```
|
52 |
| -$ cd third_party/pyth/price-service |
53 |
| -$ docker compose up |
| 60 | +$ docker buildx build -f third_party/pyth/price-service/Dockerfile.price_service -t pyth_price_service . |
54 | 61 | ```
|
| 62 | + |
| 63 | +If you wish to build price service without docker, please follow the instruction of the price service |
| 64 | +[`Dockerfile`](./Dockerfile.price_service) |
0 commit comments