Skip to content

Commit fb000d4

Browse files
fix(pyth-solana-receiver): Only split VAA when needed (#2875)
* feat(governance,xc_admin): add fogo testnet * fix(pyth_solana_receiver): improve VAA split handling
1 parent 23ff8fb commit fb000d4

File tree

2 files changed

+34
-30
lines changed

2 files changed

+34
-30
lines changed

target_chains/solana/sdk/js/pyth_solana_receiver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-solana-receiver",
3-
"version": "0.10.1",
3+
"version": "0.10.2",
44
"description": "Pyth solana receiver SDK",
55
"homepage": "https://pyth.network",
66
"main": "lib/index.js",

target_chains/solana/sdk/js/pyth_solana_receiver/src/vaa.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,35 +133,39 @@ async function generateVaaInstructionGroups(
133133

134134
// Second write and verify instructions
135135
const writeSecondPartAndVerifyInstructions: InstructionWithEphemeralSigners[] =
136-
[
137-
{
138-
instruction: await wormhole.methods
139-
.writeEncodedVaa({
140-
index: VAA_SPLIT_INDEX,
141-
data: vaa.subarray(VAA_SPLIT_INDEX),
142-
})
143-
.accounts({
144-
draftVaa: encodedVaaKeypair.publicKey,
145-
})
146-
.instruction(),
147-
signers: [],
148-
computeUnits: WRITE_ENCODED_VAA_COMPUTE_BUDGET,
149-
},
150-
{
151-
instruction: await wormhole.methods
152-
.verifyEncodedVaaV1()
153-
.accounts({
154-
guardianSet: getGuardianSetPda(
155-
getGuardianSetIndex(vaa),
156-
wormhole.programId,
157-
),
158-
draftVaa: encodedVaaKeypair.publicKey,
159-
})
160-
.instruction(),
161-
signers: [],
162-
computeUnits: VERIFY_ENCODED_VAA_COMPUTE_BUDGET,
163-
},
164-
];
136+
[];
137+
138+
// The second write instruction is only needed if there are more bytes past the split index in the VAA
139+
if (vaa.length > VAA_SPLIT_INDEX) {
140+
writeSecondPartAndVerifyInstructions.push({
141+
instruction: await wormhole.methods
142+
.writeEncodedVaa({
143+
index: VAA_SPLIT_INDEX,
144+
data: vaa.subarray(VAA_SPLIT_INDEX),
145+
})
146+
.accounts({
147+
draftVaa: encodedVaaKeypair.publicKey,
148+
})
149+
.instruction(),
150+
signers: [],
151+
computeUnits: WRITE_ENCODED_VAA_COMPUTE_BUDGET,
152+
});
153+
}
154+
155+
writeSecondPartAndVerifyInstructions.push({
156+
instruction: await wormhole.methods
157+
.verifyEncodedVaaV1()
158+
.accounts({
159+
guardianSet: getGuardianSetPda(
160+
getGuardianSetIndex(vaa),
161+
wormhole.programId,
162+
),
163+
draftVaa: encodedVaaKeypair.publicKey,
164+
})
165+
.instruction(),
166+
signers: [],
167+
computeUnits: VERIFY_ENCODED_VAA_COMPUTE_BUDGET,
168+
});
165169

166170
// Close instructions
167171
const closeInstructions: InstructionWithEphemeralSigners[] = [

0 commit comments

Comments
 (0)