diff --git a/third_party/pyth/price-service/README.md b/third_party/pyth/price-service/README.md index b19a84d3b3..3055455028 100644 --- a/third_party/pyth/price-service/README.md +++ b/third_party/pyth/price-service/README.md @@ -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 @@ -29,8 +35,7 @@ $ docker run --platform linux/amd64 -d --network=host ghcr.io/certusone/guardian --network \ ``` -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: ``` @@ -38,6 +43,13 @@ $ 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 +``` diff --git a/third_party/pyth/price-service/docker-compose.yaml b/third_party/pyth/price-service/docker-compose.yaml new file mode 100644 index 0000000000..d858adbd2f --- /dev/null +++ b/third_party/pyth/price-service/docker-compose.yaml @@ -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 diff --git a/third_party/pyth/price-service/src/rest.ts b/third_party/pyth/price-service/src/rest.ts index 728adabfc6..d19731ad05 100644 --- a/third_party/pyth/price-service/src/rest.ts +++ b/third_party/pyth/price-service/src/rest.ts @@ -181,6 +181,17 @@ export class RestAPI { "api/latest_price_feeds?ids[]=&ids[]=&.." ); + 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);