Răsfoiți Sursa

Fix: guardian set (#1459)

* Decrease compute budget

* Go

* fix
guibescos 1 an în urmă
părinte
comite
d9c85d8f9d

+ 2 - 0
target_chains/solana/sdk/js/pyth_solana_receiver/src/PythSolanaReceiver.ts

@@ -39,6 +39,7 @@ import {
   buildEncodedVaaCreateInstruction,
   buildWriteEncodedVaaWithSplitInstructions,
   getGuardianSetIndex,
+  overrideGuardianSet,
   trimSignatures,
 } from "./vaa";
 import {
@@ -446,6 +447,7 @@ export class PythSolanaReceiver {
     encodedVaaAddress: PublicKey;
     closeInstructions: InstructionWithEphemeralSigners[];
   }> {
+    vaa = overrideGuardianSet(vaa); // Short term fix Wormhole officially server guardian set 4 vaas
     const postInstructions: InstructionWithEphemeralSigners[] = [];
     const closeInstructions: InstructionWithEphemeralSigners[] = [];
     const encodedVaaKeypair = new Keypair();

+ 1 - 1
target_chains/solana/sdk/js/pyth_solana_receiver/src/compute_budget.ts

@@ -13,7 +13,7 @@ export const POST_UPDATE_COMPUTE_BUDGET = 35000;
 /**
  * A hard-coded budget for the compute units required for the `updatePriceFeed` instruction in the Pyth Push Oracle program.
  */
-export const UPDATE_PRICE_FEED_COMPUTE_BUDGET = 190000;
+export const UPDATE_PRICE_FEED_COMPUTE_BUDGET = 55000;
 /**
  * A hard-coded budget for the compute units required for the `initEncodedVaa` instruction in the Wormhole program.
  */

+ 12 - 0
target_chains/solana/sdk/js/pyth_solana_receiver/src/vaa.ts

@@ -52,6 +52,18 @@ export function trimSignatures(
   return trimmedVaa;
 }
 
+export const PREVIOUS_GUARDIAN_SET_INDEX = 4;
+export const CURRENT_GUARDIAN_SET_INDEX = 4;
+export function overrideGuardianSet(vaa: Buffer): Buffer {
+  let guardianSetIndex = getGuardianSetIndex(vaa);
+
+  if (guardianSetIndex <= 3) {
+    vaa.writeUint32BE(CURRENT_GUARDIAN_SET_INDEX, 1);
+  }
+
+  return vaa;
+}
+
 /**
  * The start of the VAA bytes in an encoded VAA account. Before this offset, the account contains a header.
  */