diff --git a/third_party/pyth/price-service/package-lock.json b/third_party/pyth/price-service/package-lock.json index b357cd5859..f1c40d9c14 100644 --- a/third_party/pyth/price-service/package-lock.json +++ b/third_party/pyth/price-service/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pythnetwork/pyth-price-service", - "version": "2.2.1", + "version": "2.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@pythnetwork/pyth-price-service", - "version": "2.2.1", + "version": "2.2.2", "license": "Apache-2.0", "dependencies": { "@certusone/wormhole-sdk": "^0.1.4", diff --git a/third_party/pyth/price-service/package.json b/third_party/pyth/price-service/package.json index 5490c733f7..bc3164d4e6 100644 --- a/third_party/pyth/price-service/package.json +++ b/third_party/pyth/price-service/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/pyth-price-service", - "version": "2.2.1", + "version": "2.2.2", "description": "Pyth Price Service", "main": "index.js", "scripts": { diff --git a/third_party/pyth/price-service/src/listen.ts b/third_party/pyth/price-service/src/listen.ts index 1f3a1dfcc6..781302a267 100644 --- a/third_party/pyth/price-service/src/listen.ts +++ b/third_party/pyth/price-service/src/listen.ts @@ -7,8 +7,6 @@ import { import { importCoreWasm } from "@certusone/wormhole-sdk/lib/cjs/solana/wasm"; -import { createHash } from "crypto"; - import { getBatchSummary, parseBatchPriceAttestation, @@ -52,7 +50,7 @@ type ListenerConfig = { readiness: ListenerReadinessConfig; }; -type VaaHash = string; +type VaaKey = string; export class Listener implements PriceStore { // Mapping of Price Feed Id to Vaa @@ -63,7 +61,7 @@ export class Listener implements PriceStore { private spyConnectionTime: TimestampInSec | undefined; private readinessConfig: ListenerReadinessConfig; private updateCallbacks: ((priceInfo: PriceInfo) => any)[]; - private observedVaas: LRUCache; + private observedVaas: LRUCache; constructor(config: ListenerConfig, promClient?: PromClient) { this.promClient = promClient; @@ -162,15 +160,16 @@ export class Listener implements PriceStore { const parsedVaa = parse_vaa(vaa); - const vaaHash: VaaHash = createHash("md5") - .update(Buffer.from(parsedVaa.payload)) - .digest("base64"); + const vaaEmitterAddressHex = Buffer.from( + parsedVaa.emitter_address + ).toString("hex"); + const vaaKey: VaaKey = `${parsedVaa.emitter_chain}#${vaaEmitterAddressHex}#${parsedVaa.sequence}`; - if (this.observedVaas.has(vaaHash)) { + if (this.observedVaas.has(vaaKey)) { return; } - this.observedVaas.set(vaaHash, true); + this.observedVaas.set(vaaKey, true); this.promClient?.incReceivedVaa(); let batchAttestation;