[英]Error: Custom: Invalid blockhash when solana program deploy
Trying to deploy a program to solana devnet.尝试将程序部署到 solana devnet。
I was using solana program deploy./path/xxxx.so -u devnet
我正在使用
solana program deploy./path/xxxx.so -u devnet
And I got multiple lines of我得到了多行
msg 21AbKBwMcsDR4DciR6Z69X6vrqVj7uHKg2Wf1ap8FB1J
msg 21AbKBwMcsDR4DciR6Z69X6vrqVj7uHKg2Wf1ap8FB1J
msg 21AbKBwMcsDR4DciR6Z69X6vrqVj7uHKg2Wf1ap8FB1J
msg 21AbKBwMcsDR4DciR6Z69X6vrqVj7uHKg2Wf1ap8FB1J
msg 21AbKBwMcsDR4DciR6Z69X6vrqVj7uHKg2Wf1ap8FB1J
It gave me this error in the end它最终给了我这个错误
Error: Custom: Invalid blockhash
Tried search online but didn't get any useful informations尝试在线搜索但没有得到任何有用的信息
This seems to be only because of anchor's version, I had the following versions installed:这似乎只是因为锚的版本,我安装了以下版本:
Rust 1.59.0
solana-cli 1.9.6
anchor-lang 0.22.1
I couldn't deploy to devnet because of我无法部署到 devnet 因为
Error: Custom: Invalid blockhash
There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.
So I just changed anchor-lang
to 0.22.0
and all worked well.所以我只是将
anchor-lang
更改为0.22.0
并且一切正常。
That's very strange, and not the normal output that you should get while deploying a program.这很奇怪,而不是部署程序时应该得到的正常 output。 Have you tried updating to the latest Solana SDK, which is 1.9.2 at the time of writing?
您是否尝试过更新到最新的 Solana SDK,在撰写本文时是 1.9.2? More docs at https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-tool
更多文档位于https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-tool
I just tried this on devnet, and got the following output:我刚刚在 devnet 上尝试过,得到了以下 output:
$ solana program deploy path/to/program.so -u devnet
Finding leader nodes...
[x/y] Transactions sent...
[x/y] Transactions confirmed. Retrying in z blocks.
Program Id: 6sxk3XpYapcRnpSwRKFS1nGK9MJpm8Jkb9aofnBcG1p8
I was able to resolve this error by reverting to earlier versions of solana-cli and anchor-cli我能够通过恢复到 solana-cli 和 anchor-cli 的早期版本来解决此错误
solana-cli 1.8.0 (src:4a8ff62a; feat:1813598585)
anchor-cli 0.18.2
rustc 1.57.0 (f1edd0429 2021-11-29)
I also shared the above solution in this related github issue我还在这个相关的github 问题中分享了上述解决方案
One guess I have is that ExitStatus(unix_wait_status(256))
(which was in my error logs) could be a "time out error" from waiting too long due to slower deployment validation.我的一个猜测是
ExitStatus(unix_wait_status(256))
(在我的错误日志中)可能是由于部署验证较慢而等待太久而导致的“超时错误”。
I did notice my deployments using later versions (solana-cli 1.9.1, anchor-cli 0.20.1) being significantly slower.我确实注意到使用更高版本(solana-cli 1.9.1、anchor-cli 0.20.1)的部署明显变慢了。 These were the versions that showed similar "msg" logging as OP.
这些版本显示了与 OP 类似的“msg”日志记录。
For deploying to devnet via Anchor, the error I got:为了通过 Anchor 部署到 devnet,我得到的错误是:
Error: Custom: Invalid blockhash
There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.
I have solved this:我已经解决了这个问题:
Local npm package: @project-serum/anchor 0.20.1
Solana program dependencies: anchor-lang 0.20.1, anchor-spl 0.20.1, solana-program 1.9.4
deployment to devnet failed
Local npm package: @project-serum/anchor 0.18.2
Solana program dependencies: anchor-lang 0.18.2, anchor-spl 0.18.2, solana-program 1.9.4
deployment to devnet succeeded!
in both cases, the global environment is:在这两种情况下,全球环境是:
Rust 1.57.0
solana-cli 1.9.4
@project-serum/anchor-cli 0.20.1
For Mac M1,对于 Mac M1,
Rust 1.57.0
solana-cli 1.8.0
@project-serum/anchor-cli 0.20.1
these tools' versions work.这些工具的版本有效。 I tried myself.
我自己试过。
https://github.com/project-serum/anchor/issues/1157#issuecomment-1065828414 try solana cli 1.8.12 as 1.9.* seems to have issues deploying on devnet https://github.com/project-serum/anchor/issues/1157#issuecomment-1065828414尝试将 solana cli 1.8.12 as 1.9.* 在 devnet 上部署似乎有问题
I had similar error in chainlink contract github example .我在 chainlink 合约github 示例中遇到了类似的错误。 I changed this line in Execute Struct
我在 Execute Struct 中更改了这一行
pub system_program:Program<'info,System>,
to this:对此:
#[account(address=system_program::ID)]
/// CHECK:
pub system_program:AccountInfo<'info>,
I had to import system_program
我不得不导入
system_program
use anchor_lang::solana_program::system_program;
for me, to solve it my solana-cli version was 1.9.4 and I just updated with对我来说,要解决它,我的 solana-cli 版本是 1.9.4,我刚刚更新了
solana-install update
and it's downgraded to 1.8.16 and deployed my program without any problem.它已降级到 1.8.16 并毫无问题地部署了我的程序。 before this I can't deploy using anchor test(process) or solana program deploy.
在此之前,我无法使用锚测试(过程)或 solana 程序部署进行部署。
Also, If you upgrade to one of the 1.10.X versions the issue will fix.此外,如果您升级到 1.10.X 版本之一,该问题将得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.