SOLANA:ComputeBudget在打字稿SDK中
我目前正在尝试增加我在DEVNET上的Solana程序上的计算预算。我正在使用Solana版本1.9.9。
我已经检查了锚点,并发现此实现要求更大的计算预算。但是,当我运行此代码 - 尼珀时,
const data = Buffer.from(
Uint8Array.of(0, ...new BN(256000).toArray("le", 4))
);
const additionalComputeIx: TransactionInstruction = new TransactionInstruction({
keys: [],
programId: new PublicKey("ComputeBudget111111111111111111111111111111"),
data,
});
...
我会得到无效的指令数据
。知道为什么这可能是吗?
在将此指令添加到交易中之前,我会得到计算预算超过
。
I am currently trying to increase the Compute-Budget on my Solana Program on devnet. I am using solana version 1.9.9.
I have checked the anchor discord, and found this implementation to request a larger compute-budget. however, when I run this code-snippet
const data = Buffer.from(
Uint8Array.of(0, ...new BN(256000).toArray("le", 4))
);
const additionalComputeIx: TransactionInstruction = new TransactionInstruction({
keys: [],
programId: new PublicKey("ComputeBudget111111111111111111111111111111"),
data,
});
...
I get invalid instruction data
. any idea why this could be?
I was getting Compute Budget Exceeded
before adding this instruction to the transaction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你很近!请求从计算预算计划增加的指令定义包含单位的小
U32
,但随后还包含一个小的u32
,以添加额外费用,即使是0。 /compute_budget.rs#L10" rel="nofollow noreferrer">https://github.com/solana-labs/solana/blob/a6742b5838ffe6f37afcb24ab32ad2287a1514cf/sdk/src/compute_budget.rs#L10
You're very close! The instruction definition for requesting an increase from the compute budget program contains a little-endian
u32
for the units, but then also a little-endianu32
for the additional fee to add, which you must include, even if it's 0. So instead, you should try:More information about the instruction at https://github.com/solana-labs/solana/blob/a6742b5838ffe6f37afcb24ab32ad2287a1514cf/sdk/src/compute_budget.rs#L10