Explorar el Código

[price-service/client] Crash by default on WsError (#934)

* [price-service/client] Crash by default on WsError

* Update docker-compose files

* Update package versions again
Ali Behjati hace 2 años
padre
commit
bef4073b54

+ 4 - 4
package-lock.json

@@ -55928,7 +55928,7 @@
     },
     "price_pusher": {
       "name": "@pythnetwork/price-pusher",
-      "version": "5.4.3",
+      "version": "5.4.4",
       "license": "Apache-2.0",
       "dependencies": {
         "@injectivelabs/sdk-ts": "1.10.72",
@@ -57359,7 +57359,7 @@
     },
     "price_service/client/js": {
       "name": "@pythnetwork/price-service-client",
-      "version": "1.6.0",
+      "version": "1.6.1",
       "license": "Apache-2.0",
       "dependencies": {
         "@pythnetwork/price-service-sdk": "*",
@@ -57976,7 +57976,7 @@
     },
     "target_chains/cosmwasm/sdk/js": {
       "name": "@pythnetwork/pyth-terra-js",
-      "version": "1.3.0",
+      "version": "1.3.1",
       "license": "Apache-2.0",
       "dependencies": {
         "@pythnetwork/price-service-client": "*",
@@ -59019,7 +59019,7 @@
     },
     "target_chains/ethereum/sdk/js": {
       "name": "@pythnetwork/pyth-evm-js",
-      "version": "1.20.0",
+      "version": "1.20.1",
       "license": "Apache-2.0",
       "dependencies": {
         "@pythnetwork/price-service-client": "*",

+ 18 - 10
price_pusher/docker-compose.mainnet.sample.yaml

@@ -1,7 +1,7 @@
 services:
   spy:
     # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
-    image: ghcr.io/wormhole-foundation/guardiand:v2.17.0
+    image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
     command:
       - "spy"
       - "--nodeKey"
@@ -16,7 +16,7 @@ services:
       - "warn"
   price-service:
     # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
-    image: public.ecr.aws/pyth-network/xc-server:v3.0.3
+    image: public.ecr.aws/pyth-network/xc-server:v3.0.8
     environment:
       SPY_SERVICE_HOST: "spy:7072"
       SPY_SERVICE_FILTERS: |
@@ -32,8 +32,8 @@ services:
         ]
       REST_PORT: "4200"
       PROM_PORT: "8081"
-      READINESS_SPY_SYNC_TIME_SECONDS: "20"
-      READINESS_NUM_LOADED_SYMBOLS: "50"
+      READINESS_SPY_SYNC_TIME_SECONDS: "5"
+      READINESS_NUM_LOADED_SYMBOLS: "280"
       LOG_LEVEL: warning
       WORMHOLE_CLUSTER: mainnet
     healthcheck:
@@ -50,12 +50,20 @@ services:
     depends_on:
       - spy
   price-pusher:
-    build:
-      context: .
-    # Uncomment this line (and comment out the above lines) to use a prebuilt image. Replace <version>
-    # with the latest released image of the price pusher from this repo release page:
-    # https://github.com/pyth-network/pyth-crosschain/releases
-    # image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
+    # Use this to build the price pusher from source. A dependency of the pusher docker
+    # image is the pyth-crosschain monorepo lerna docker image. Build lerna image
+    # using the following command from the repo root:
+    # `docker buildx build -f tilt_devnet/docker_images/Dockerfile.lerna -t lerna .`
+    #
+    # Please note that the docker build from source only works in x86_64 platforms
+    # and doesn't work on arm platforms (like Apple M1/M2).
+    #
+    # build:
+    #   context: .
+
+    # Replace <version> with the latest released image of the price pusher from here:
+    # https://gallery.ecr.aws/pyth-network/xc-price-pusher
+    image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
     restart: always
     command:
       - "--"

+ 18 - 10
price_pusher/docker-compose.testnet.sample.yaml

@@ -1,7 +1,7 @@
 services:
   spy:
     # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
-    image: ghcr.io/wormhole-foundation/guardiand:v2.17.0
+    image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
     command:
       - "spy"
       - "--nodeKey"
@@ -16,7 +16,7 @@ services:
       - "warn"
   price-service:
     # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
-    image: public.ecr.aws/pyth-network/xc-server:v3.0.3
+    image: public.ecr.aws/pyth-network/xc-server:v3.0.8
     environment:
       SPY_SERVICE_HOST: "spy:7072"
       SPY_SERVICE_FILTERS: |
@@ -32,8 +32,8 @@ services:
         ]
       REST_PORT: "4200"
       PROM_PORT: "8081"
-      READINESS_SPY_SYNC_TIME_SECONDS: "20"
-      READINESS_NUM_LOADED_SYMBOLS: "50"
+      READINESS_SPY_SYNC_TIME_SECONDS: "5"
+      READINESS_NUM_LOADED_SYMBOLS: "280"
       LOG_LEVEL: warning
       WORMHOLE_CLUSTER: testnet
     healthcheck:
@@ -50,12 +50,20 @@ services:
     depends_on:
       - spy
   price-pusher:
-    build:
-      context: .
-    # Uncomment this line (and comment out the above lines) to use a prebuilt image. Replace <version>
-    # with the latest released image of the price pusher from this repo release page:
-    # https://github.com/pyth-network/pyth-crosschain/releases
-    # image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
+    # Use this to build the price pusher from source. A dependency of the pusher docker
+    # image is the pyth-crosschain monorepo lerna docker image. Build lerna image
+    # using the following command from the repo root:
+    # `docker buildx build -f tilt_devnet/docker_images/Dockerfile.lerna -t lerna .`
+    #
+    # Please note that the docker build from source only works in x86_64 platforms
+    # and doesn't work on arm platforms (like Apple M1/M2).
+    #
+    # build:
+    #   context: .
+
+    # Replace <version> with the latest released image of the price pusher from here:
+    # https://gallery.ecr.aws/pyth-network/xc-price-pusher
+    image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
     restart: always
     command:
       - "--"

+ 1 - 1
price_pusher/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/price-pusher",
-  "version": "5.4.3",
+  "version": "5.4.4",
   "description": "Pyth Price Pusher",
   "homepage": "https://pyth.network",
   "main": "lib/index.js",

+ 1 - 1
price_service/client/js/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/price-service-client",
-  "version": "1.6.0",
+  "version": "1.6.1",
   "description": "Pyth price service client",
   "author": {
     "name": "Pyth Data Association"

+ 32 - 11
price_service/client/js/src/PriceServiceConnection.ts

@@ -62,7 +62,7 @@ export class PriceServiceConnection {
   private wsClient: undefined | ResilientWebSocket;
   private wsEndpoint: undefined | string;
 
-  private logger: undefined | Logger;
+  private logger: Logger;
 
   private priceFeedRequestConfig: PriceFeedRequestConfig;
 
@@ -96,9 +96,30 @@ export class PriceServiceConnection {
 
     this.priceFeedCallbacks = new Map();
 
-    this.logger = config?.logger;
+    // Default logger is console for only warnings and errors.
+    this.logger = config?.logger || {
+      trace: () => {},
+      debug: () => {},
+      info: () => {},
+      warn: console.warn,
+      error: console.error,
+    };
+
     this.onWsError = (error: Error) => {
-      this.logger?.error(error);
+      this.logger.error(error);
+
+      // Exit the process if it is running in node.
+      if (
+        typeof process !== "undefined" &&
+        typeof process.exit === "function"
+      ) {
+        this.logger.error("Halting the process due to the websocket error");
+        process.exit(1);
+      } else {
+        this.logger.error(
+          "Cannot halt process. Please handle the websocket error."
+        );
+      }
     };
 
     this.wsEndpoint = makeWebsocketUrl(endpoint);
@@ -333,28 +354,28 @@ export class PriceServiceConnection {
           binary: this.priceFeedRequestConfig.binary,
         };
 
-        this.logger?.info("Resubscribing to existing price feeds.");
+        this.logger.info("Resubscribing to existing price feeds.");
         this.wsClient?.send(JSON.stringify(message));
       }
     };
 
     this.wsClient.onMessage = (data: WebSocket.Data) => {
-      this.logger?.info(`Received message ${data.toString()}`);
+      this.logger.info(`Received message ${data.toString()}`);
 
       let message: ServerMessage;
 
       try {
         message = JSON.parse(data.toString()) as ServerMessage;
       } catch (e: any) {
-        this.logger?.error(`Error parsing message ${data.toString()} as JSON.`);
-        this.logger?.error(e);
+        this.logger.error(`Error parsing message ${data.toString()} as JSON.`);
+        this.logger.error(e);
         this.onWsError(e);
         return;
       }
 
       if (message.type === "response") {
         if (message.status === "error") {
-          this.logger?.error(
+          this.logger.error(
             `Error response from the websocket server ${message.error}.`
           );
           this.onWsError(new Error(message.error));
@@ -364,10 +385,10 @@ export class PriceServiceConnection {
         try {
           priceFeed = PriceFeed.fromJson(message.price_feed);
         } catch (e: any) {
-          this.logger?.error(
+          this.logger.error(
             `Error parsing price feeds from message ${data.toString()}.`
           );
-          this.logger?.error(e);
+          this.logger.error(e);
           this.onWsError(e);
           return;
         }
@@ -378,7 +399,7 @@ export class PriceServiceConnection {
           }
         }
       } else {
-        this.logger?.warn(
+        this.logger.warn(
           `Ignoring unsupported server response ${data.toString()}.`
         );
       }

+ 4 - 4
price_service/server/docker-compose.mainnet.yaml

@@ -1,7 +1,7 @@
 services:
   spy:
     # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
-    image: ghcr.io/wormhole-foundation/guardiand:v2.17.0
+    image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
     restart: on-failure
     command:
       - "spy"
@@ -17,7 +17,7 @@ services:
       - "warn"
   price-service:
     # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
-    image: public.ecr.aws/pyth-network/xc-server:v3.0.3
+    image: public.ecr.aws/pyth-network/xc-server:v3.0.8
     restart: on-failure
     # Or alternatively use a locally built image
     # image: pyth_price_server
@@ -36,8 +36,8 @@ services:
         ]
       REST_PORT: "4200"
       PROM_PORT: "8081"
-      READINESS_SPY_SYNC_TIME_SECONDS: "20"
-      READINESS_NUM_LOADED_SYMBOLS: "50"
+      READINESS_SPY_SYNC_TIME_SECONDS: "5"
+      READINESS_NUM_LOADED_SYMBOLS: "280"
       LOG_LEVEL: warning
       WORMHOLE_CLUSTER: mainnet
       DB_API_CLUSTER: pythnet

+ 4 - 4
price_service/server/docker-compose.testnet.yaml

@@ -1,7 +1,7 @@
 services:
   spy:
     # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
-    image: ghcr.io/wormhole-foundation/guardiand:v2.17.0
+    image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
     restart: on-failure
     command:
       - "spy"
@@ -17,7 +17,7 @@ services:
       - "warn"
   price-service:
     # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
-    image: public.ecr.aws/pyth-network/xc-server:v3.0.3
+    image: public.ecr.aws/pyth-network/xc-server:v3.0.8
     restart: on-failure
     # Or alternatively use a locally built image
     # image: pyth_price_server
@@ -36,8 +36,8 @@ services:
         ]
       REST_PORT: "4200"
       PROM_PORT: "8081"
-      READINESS_SPY_SYNC_TIME_SECONDS: "20"
-      READINESS_NUM_LOADED_SYMBOLS: "50"
+      READINESS_SPY_SYNC_TIME_SECONDS: "5"
+      READINESS_NUM_LOADED_SYMBOLS: "280"
       LOG_LEVEL: warning
       WORMHOLE_CLUSTER: testnet
       DB_API_CLUSTER: devnet

+ 1 - 1
target_chains/cosmwasm/sdk/js/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/pyth-terra-js",
-  "version": "1.3.0",
+  "version": "1.3.1",
   "description": "Pyth Network Terra Utils in JS",
   "homepage": "https://pyth.network",
   "author": {

+ 1 - 1
target_chains/ethereum/sdk/js/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/pyth-evm-js",
-  "version": "1.20.0",
+  "version": "1.20.1",
   "description": "Pyth Network EVM Utils in JS",
   "homepage": "https://pyth.network",
   "author": {