Skip to content

Commit 3100ab9

Browse files
add api endpoint to get all supported price feed ids for price service (#259)
* add new /price-feed-ids rest endpoint * add docker-compose.yaml and update README * Update third_party/pyth/price-service/README.md Co-authored-by: Ali Behjati <[email protected]> Co-authored-by: Ali Behjati <[email protected]>
1 parent a17b27f commit 3100ab9

File tree

3 files changed

+69
-6
lines changed

3 files changed

+69
-6
lines changed

third_party/pyth/price-service/README.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ This service exposes a REST and WS api to provide latest attestation message for
44

55
## Build
66

7-
To build the pyth_price_service docker container from the repo root:
7+
First, build the wasm container from the repo root:
88

99
```
10-
$ docker build -f third_party/pyth/price-service/Dockerfile.pyth_price_service -t pyth_price_service .
10+
docker buildx build -f Dockerfile.wasm -o type=local,dest=. .
11+
```
12+
13+
Then, build the pyth_price_service docker container from the repo root:
14+
15+
```
16+
$ docker buildx build -f third_party/pyth/price-service/Dockerfile.price_service -t pyth_price_service .
1117
```
1218

1319
Run the spy_guardian docker container in TestNet:
1420

1521
```
16-
$ docker run --platform linux/amd64 -d --network=host ghcr.io/certusone/guardiand:v2.8.8.1 spy \
22+
$ docker run --platform linux/amd64 --network=host ghcr.io/certusone/guardiand:v2.8.8.1 spy \
1723
--nodeKey /node.key --spyRPC "[::]:7073" \
1824
--bootstrap /dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWBY9ty9CXLBXGQzMuqkziLntsVcyz4pk1zWaJRvJn6Mmt \
1925
--network /wormhole/testnet/2/1
@@ -29,15 +35,21 @@ $ docker run --platform linux/amd64 -d --network=host ghcr.io/certusone/guardian
2935
--network <guardianNetworkPathForMainNet> \
3036
```
3137

32-
Then to run the pyth_price_service docker container using a config file called
33-
${HOME}/pyth_price_service/env and logging to directory ${HOME}/pyth_price_service/logs, do the
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
3439
following:
3540

3641
```
3742
$ docker run \
3843
--volume=${HOME}/pyth_price_service:/var/pyth_price_service \
3944
-e PYTH_PRICE_SERVICE_CONFIG=/var/pyth_price_service/env \
4045
--network=host \
41-
-d \
4246
pyth_price_service
4347
```
48+
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.
50+
51+
52+
```
53+
$ cd third_party/pyth/price-service
54+
$ docker compose up
55+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
services:
2+
spy:
3+
image: ghcr.io/certusone/guardiand:v2.8.8.1
4+
command:
5+
- "spy"
6+
- "--nodeKey"
7+
- "/node.key"
8+
- "--spyRPC"
9+
- "[::]:7072"
10+
- "--bootstrap"
11+
- "/dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWBY9ty9CXLBXGQzMuqkziLntsVcyz4pk1zWaJRvJn6Mmt"
12+
- "--network"
13+
- "/wormhole/testnet/2/1"
14+
- "--logLevel"
15+
- "debug"
16+
price-service:
17+
image: pyth_price_service
18+
ports:
19+
- "4200:4200"
20+
environment:
21+
- SPY_SERVICE_HOST=spy:7072
22+
- SPY_SERVICE_FILTERS=[{"chain_id":1,"emitter_address":"f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0"}]
23+
- REST_PORT=4200
24+
- PROM_PORT=8081
25+
- READINESS_SPY_SYNC_TIME_SECONDS=60
26+
- READINESS_NUM_LOADED_SYMBOLS=8
27+
- LOG_LEVEL=debug
28+
healthcheck:
29+
test:
30+
[
31+
"CMD",
32+
"wget",
33+
"--no-verbose",
34+
"--tries=1",
35+
"--spider",
36+
"http://localhost:4200/ready",
37+
]
38+
start_period: 60s
39+
depends_on:
40+
- spy

third_party/pyth/price-service/src/rest.ts

+11
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ export class RestAPI {
181181
"api/latest_price_feeds?ids[]=<price_feed_id>&ids[]=<price_feed_id_2>&.."
182182
);
183183

184+
app.get(
185+
"/api/price_feed_ids",
186+
(req: Request, res: Response) => {
187+
const availableIds = this.priceFeedVaaInfo.getPriceIds();
188+
res.json([...availableIds]);
189+
}
190+
);
191+
endpoints.push(
192+
"api/price_feed_ids"
193+
);
194+
184195
app.get("/ready", (_, res: Response) => {
185196
if (this.isReady!()) {
186197
res.sendStatus(StatusCodes.OK);

0 commit comments

Comments
 (0)