Jelajahi Sumber

feat: drop jito bundle size and improve packing (#2940)

* feat: drop jito bundle size and improve packing

* add alt

* comment
guibescos 3 bulan lalu
induk
melakukan
dd923bdfdc

+ 3 - 3
apps/price_pusher/config.solana.mainnet.sample.json

@@ -2,14 +2,14 @@
   "endpoint": "https://api.mainnet-beta.solana.com",
   "keypair-file": "./id.json",
   "shard-id": 1,
-  "jito-endpoint": "mainnet.block-engine.jito.wtf",
+  "jito-endpoints": "mainnet.block-engine.jito.wtf,amsterdam.mainnet.block-engine.jito.wtf",
   "jito-keypair-file": "./jito.json",
   "jito-tip-lamports": "100000",
   "dynamic-jito-tips": true,
-  "jito-bundle-size": "5",
   "updates-per-jito-bundle": "6",
   "price-config-file": "./price-config.stable.sample.yaml",
   "price-service-endpoint": "https://hermes.pyth.network/",
   "pyth-contract-address": "pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT",
-  "pushing-frequency": "30"
+  "pushing-frequency": "30",
+  "address-lookup-table-account":"GgPa1XHhkqvdJHjQpHaqxThwejgHW8qeW4k4jKVS4Lod"
 }

+ 1 - 1
apps/price_pusher/package.json

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

+ 0 - 2
apps/price_pusher/src/solana/command.ts

@@ -122,7 +122,6 @@ export default {
       jitoTipLamports,
       dynamicJitoTips,
       maxJitoTipLamports,
-      jitoBundleSize,
       updatesPerJitoBundle,
       addressLookupTableAccount,
       treasuryId,
@@ -230,7 +229,6 @@ export default {
         dynamicJitoTips,
         maxJitoTipLamports,
         jitoClients,
-        jitoBundleSize,
         updatesPerJitoBundle,
         // Set max retry time to pushing frequency, since we want to stop retrying before the next push attempt
         pushingFrequency * 1000,

+ 0 - 2
apps/price_pusher/src/solana/solana.ts

@@ -167,7 +167,6 @@ export class SolanaPricePusherJito implements IPricePusher {
     private dynamicJitoTips: boolean,
     private maxJitoTipLamports: number,
     private searcherClients: SearcherClient[],
-    private jitoBundleSize: number,
     private updatesPerJitoBundle: number,
     private maxRetryTimeMs: number,
     private addressLookupTableAccount?: AddressLookupTableAccount,
@@ -237,7 +236,6 @@ export class SolanaPricePusherJito implements IPricePusher {
       const transactions = await transactionBuilder.buildVersionedTransactions({
         jitoTipLamports: cappedJitoTip,
         tightComputeBudget: true,
-        jitoBundleSize: this.jitoBundleSize,
       });
 
       await sendTransactionsJito(

+ 1 - 1
target_chains/solana/sdk/js/pyth_solana_receiver/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/pyth-solana-receiver",
-  "version": "0.10.2",
+  "version": "0.11.0",
   "description": "Pyth solana receiver SDK",
   "homepage": "https://pyth.network",
   "main": "lib/index.js",

+ 1 - 1
target_chains/solana/sdk/js/solana_utils/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/solana-utils",
-  "version": "0.4.5",
+  "version": "0.5.0",
   "description": "Utility functions for Solana",
   "homepage": "https://pyth.network",
   "main": "lib/index.js",

+ 12 - 10
target_chains/solana/sdk/js/solana_utils/src/transaction.ts

@@ -26,6 +26,11 @@ export const DEFAULT_COMPUTE_BUDGET_UNITS = 200000;
 export const PACKET_DATA_SIZE_WITH_ROOM_FOR_COMPUTE_BUDGET =
   PACKET_DATA_SIZE - 52;
 
+/**
+ * The maximum number of transactions in a Jito bundle.
+ */
+export const JITO_BUNDLE_SIZE = 5;
+
 /**
  * An instruction with some extra information that will be used to build transactions.
  */
@@ -46,7 +51,6 @@ export type PriorityFeeConfig = {
   computeUnitPriceMicroLamports?: number;
   tightComputeBudget?: boolean;
   jitoTipLamports?: number;
-  jitoBundleSize?: number;
 };
 
 /**
@@ -188,7 +192,11 @@ export class TransactionBuilder {
             this.transactionInstructions.length - 1
           ].instructions,
           instruction,
-          buildJitoTipInstruction(this.payer, 1),
+          this.transactionInstructions.length % JITO_BUNDLE_SIZE === 0 // This transaction may be the first of a Jito bundle, so we leave room for a Jito tip transfer.
+            ? buildJitoTipInstruction(this.payer, 1)
+            : ComputeBudgetProgram.setComputeUnitPrice({
+                microLamports: 1,
+              }),
           ComputeBudgetProgram.setComputeUnitLimit({ units: 1 }),
         ],
         true,
@@ -232,9 +240,6 @@ export class TransactionBuilder {
       await this.connection.getLatestBlockhash({ commitment: "confirmed" })
     ).blockhash;
 
-    const jitoBundleSize =
-      args.jitoBundleSize || this.transactionInstructions.length;
-
     return this.transactionInstructions.map(
       ({ instructions, signers, computeUnits }, index) => {
         const instructionsWithComputeBudget: TransactionInstruction[] = [
@@ -255,7 +260,7 @@ export class TransactionBuilder {
             }),
           );
         }
-        if (args.jitoTipLamports && index % jitoBundleSize === 0) {
+        if (args.jitoTipLamports && index % JITO_BUNDLE_SIZE === 0) {
           instructionsWithComputeBudget.push(
             buildJitoTipInstruction(this.payer, args.jitoTipLamports),
           );
@@ -297,9 +302,6 @@ export class TransactionBuilder {
   buildLegacyTransactions(
     args: PriorityFeeConfig,
   ): { tx: Transaction; signers: Signer[] }[] {
-    const jitoBundleSize =
-      args.jitoBundleSize || this.transactionInstructions.length;
-
     return this.transactionInstructions.map(
       ({ instructions, signers, computeUnits }, index) => {
         const instructionsWithComputeBudget: TransactionInstruction[] = [
@@ -320,7 +322,7 @@ export class TransactionBuilder {
             }),
           );
         }
-        if (args.jitoTipLamports && index % jitoBundleSize === 0) {
+        if (args.jitoTipLamports && index % JITO_BUNDLE_SIZE === 0) {
           instructionsWithComputeBudget.push(
             buildJitoTipInstruction(this.payer, args.jitoTipLamports),
           );