Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add api endpoint to get all supported price feed ids for price service #259

Merged
merged 3 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions third_party/pyth/price-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ This service exposes a REST and WS api to provide latest attestation message for

## Build

To build the pyth_price_service docker container from the repo root:
First, build the wasm container from the repo root:

```
$ docker build -f third_party/pyth/price-service/Dockerfile.pyth_price_service -t pyth_price_service .
docker buildx build -f Dockerfile.wasm -o type=local,dest=. .
```

Then, build the pyth_price_service docker container from the repo root:

```
$ docker buildx build -f third_party/pyth/price-service/Dockerfile.price_service -t pyth_price_service .
```

Run the spy_guardian docker container in TestNet:

```
$ docker run --platform linux/amd64 -d --network=host ghcr.io/certusone/guardiand:v2.8.8.1 spy \
$ 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
Expand All @@ -29,15 +35,21 @@ $ docker run --platform linux/amd64 -d --network=host ghcr.io/certusone/guardian
--network <guardianNetworkPathForMainNet> \
```

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

```
$ docker run \
--volume=${HOME}/pyth_price_service:/var/pyth_price_service \
-e PYTH_PRICE_SERVICE_CONFIG=/var/pyth_price_service/env \
--network=host \
-d \
pyth_price_service
```

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.


```
$ cd third_party/pyth/price-service
$ docker compose up
```
40 changes: 40 additions & 0 deletions third_party/pyth/price-service/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
spy:
image: ghcr.io/certusone/guardiand:v2.8.8.1
command:
- "spy"
- "--nodeKey"
- "/node.key"
- "--spyRPC"
- "[::]:7072"
- "--bootstrap"
- "/dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWBY9ty9CXLBXGQzMuqkziLntsVcyz4pk1zWaJRvJn6Mmt"
- "--network"
- "/wormhole/testnet/2/1"
- "--logLevel"
- "debug"
price-service:
image: pyth_price_service
ports:
- "4200:4200"
environment:
- SPY_SERVICE_HOST=spy:7072
- SPY_SERVICE_FILTERS=[{"chain_id":1,"emitter_address":"f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0"}]
- REST_PORT=4200
- PROM_PORT=8081
- READINESS_SPY_SYNC_TIME_SECONDS=60
- READINESS_NUM_LOADED_SYMBOLS=8
- LOG_LEVEL=debug
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:4200/ready",
]
start_period: 60s
depends_on:
- spy
11 changes: 11 additions & 0 deletions third_party/pyth/price-service/src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ export class RestAPI {
"api/latest_price_feeds?ids[]=<price_feed_id>&ids[]=<price_feed_id_2>&.."
);

app.get(
"/api/price_feed_ids",
(req: Request, res: Response) => {
const availableIds = this.priceFeedVaaInfo.getPriceIds();
res.json([...availableIds]);
}
);
endpoints.push(
"api/price_feed_ids"
);

app.get("/ready", (_, res: Response) => {
if (this.isReady!()) {
res.sendStatus(StatusCodes.OK);
Expand Down