diff --git a/apps/price_pusher/package.json b/apps/price_pusher/package.json index 0157ab4ef6..fafdfa6ee7 100644 --- a/apps/price_pusher/package.json +++ b/apps/price_pusher/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/price-pusher", - "version": "8.3.1", + "version": "8.3.2", "description": "Pyth Price Pusher", "homepage": "https://pyth.network", "main": "lib/index.js", diff --git a/apps/price_pusher/src/solana/solana.ts b/apps/price_pusher/src/solana/solana.ts index b331032481..30604c8c2b 100644 --- a/apps/price_pusher/src/solana/solana.ts +++ b/apps/price_pusher/src/solana/solana.ts @@ -100,11 +100,7 @@ export class SolanaPricePusher implements IPricePusher { private computeUnitPriceMicroLamports: number ) {} - async updatePriceFeed( - priceIds: string[], - // eslint-disable-next-line @typescript-eslint/no-unused-vars - _pubTimesToPush: number[] - ): Promise { + async updatePriceFeed(priceIds: string[]): Promise { if (priceIds.length === 0) { return; } @@ -189,11 +185,11 @@ export class SolanaPricePusherJito implements IPricePusher { } } - async updatePriceFeed( - priceIds: string[], - // eslint-disable-next-line @typescript-eslint/no-unused-vars - _pubTimesToPush: number[] - ): Promise { + private async sleep(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); + } + + async updatePriceFeed(priceIds: string[]): Promise { const recentJitoTip = await this.getRecentJitoTipLamports(); const jitoTip = this.dynamicJitoTips && recentJitoTip !== undefined @@ -234,11 +230,32 @@ export class SolanaPricePusherJito implements IPricePusher { jitoBundleSize: this.jitoBundleSize, }); - await sendTransactionsJito( - transactions, - this.searcherClient, - this.pythSolanaReceiver.wallet - ); + let retries = 60; + while (retries > 0) { + try { + await sendTransactionsJito( + transactions, + this.searcherClient, + this.pythSolanaReceiver.wallet + ); + break; + } catch (err: any) { + if (err.code === 8 && err.details?.includes("Rate limit exceeded")) { + this.logger.warn("Rate limit hit, waiting before retry..."); + await this.sleep(1100); // Wait slightly more than 1 second + retries--; + if (retries === 0) { + this.logger.error("Max retries reached for rate limit"); + throw err; + } + } else { + throw err; + } + } + } + + // Add a delay between bundles to avoid rate limiting + await this.sleep(1100); } } }