Skip to content

Commit 5484606

Browse files
authored
[price-service] Update docs + compose-file (#432)
* [price-service] Update docs + compose-file * Address reviews * Fix pre-commit issues
1 parent 3da1e86 commit 5484606

File tree

5 files changed

+147
-81
lines changed

5 files changed

+147
-81
lines changed

third_party/pyth/price-service/.env.sample

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ SPY_SERVICE_HOST=0.0.0.0:7072
44
## Filters (if provided) should be valid JSON like below:
55
SPY_SERVICE_FILTERS=[{"chain_id":1,"emitter_address":"71f8dcb863d176e2c420ad6610cf687359612b6fb392e0642b0ca6b1f186aa3b"}]
66

7-
# TestNet:
8-
#SPY_SERVICE_HOST=0.0.0.0:7073
9-
#SPY_SERVICE_FILTERS=[{"chain_id":1,"emitter_address":"f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0"}]
10-
11-
# MainNet:
12-
#SPY_SERVICE_HOST=0.0.0.0:7074
13-
#SPY_SERVICE_FILTERS=[{"chain_id":1,"emitter_address":"6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25"}]
14-
157
# Number of seconds to sync with spy to be sure to have latest messages
168
READINESS_SPY_SYNC_TIME_SECONDS=60
179
READINESS_NUM_LOADED_SYMBOLS=5
Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,64 @@
11
# Pyth Price Service
22

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.
47

5-
## Build
8+
## Public Endpoints
69

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:
812

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 |
1217

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.
1421

15-
```
16-
$ docker buildx build -f third_party/pyth/price-service/Dockerfile.price_service -t pyth_price_service .
17-
```
22+
## Wormhole Spy
1823

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.
2027

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.
2730

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:
3036

3137
```
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
3639
```
3740

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.
4051

4152
```
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=. .
4754
```
4855

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`.
5058

5159
```
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 .
5461
```
62+
63+
If you wish to build price service without docker, please follow the instruction of the price service
64+
[`Dockerfile`](./Dockerfile.price_service)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
services:
2+
spy:
3+
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
4+
image: ghcr.io/wormhole-foundation/guardiand:v.2.14.5
5+
command:
6+
- "spy"
7+
- "--nodeKey"
8+
- "/node.key"
9+
- "--spyRPC"
10+
- "[::]:7072"
11+
- "--bootstrap"
12+
- "/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7"
13+
- "--network"
14+
- "/wormhole/mainnet/2"
15+
- "--logLevel"
16+
- "warn"
17+
price-service:
18+
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
19+
image: public.ecr.aws/pyth-network/xc-server:v2.2.3
20+
# Or alternatively use a locally built image
21+
# image: pyth_price_service
22+
environment:
23+
SPY_SERVICE_HOST: "spy:7072"
24+
SPY_SERVICE_FILTERS: |
25+
[
26+
{
27+
"chain_id": 1,
28+
"emitter_address": "6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25"
29+
},
30+
{
31+
"chain_id": 26,
32+
"emitter_address": "f8cd23c2ab91237730770bbea08d61005cdda0984348f3f6eecb559638c0bba0"
33+
}
34+
]
35+
REST_PORT: "4200"
36+
PROM_PORT: "8081"
37+
READINESS_SPY_SYNC_TIME_SECONDS: "20"
38+
READINESS_NUM_LOADED_SYMBOLS: "50"
39+
LOG_LEVEL: warning
40+
healthcheck:
41+
test:
42+
[
43+
"CMD",
44+
"wget",
45+
"--no-verbose",
46+
"--tries=1",
47+
"--spider",
48+
"http://localhost:4200/ready",
49+
]
50+
start_period: 20s
51+
depends_on:
52+
- spy
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
services:
2+
spy:
3+
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
4+
image: ghcr.io/wormhole-foundation/guardiand:v.2.14.5
5+
command:
6+
- "spy"
7+
- "--nodeKey"
8+
- "/node.key"
9+
- "--spyRPC"
10+
- "[::]:7072"
11+
- "--bootstrap"
12+
- "/dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWAkB9ynDur1Jtoa97LBUp8RXdhzS5uHgAfdTquJbrbN7i"
13+
- "--network"
14+
- "/wormhole/testnet/2/1"
15+
- "--logLevel"
16+
- "warn"
17+
price-service:
18+
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
19+
image: public.ecr.aws/pyth-network/xc-server:v2.2.3
20+
# Or alternatively use a locally built image
21+
# image: pyth_price_service
22+
environment:
23+
SPY_SERVICE_HOST: "spy:7072"
24+
SPY_SERVICE_FILTERS: |
25+
[
26+
{
27+
"chain_id": 1,
28+
"emitter_address": "f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0"
29+
},
30+
{
31+
"chain_id": 26,
32+
"emitter_address": "a27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6"
33+
}
34+
]
35+
REST_PORT: "4200"
36+
PROM_PORT: "8081"
37+
READINESS_SPY_SYNC_TIME_SECONDS: "20"
38+
READINESS_NUM_LOADED_SYMBOLS: "50"
39+
LOG_LEVEL: warning
40+
healthcheck:
41+
test:
42+
[
43+
"CMD",
44+
"wget",
45+
"--no-verbose",
46+
"--tries=1",
47+
"--spider",
48+
"http://localhost:4200/ready",
49+
]
50+
start_period: 20s
51+
depends_on:
52+
- spy

third_party/pyth/price-service/docker-compose.yaml

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)