Error: Custom: Invalid blockhash when solana program deploy

Trying to deploy a program to solana devnet.

I was using 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


Solution 1:

I was able to resolve this error by reverting to earlier versions of solana-cli and 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

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.

I did notice my deployments using later versions (solana-cli 1.9.1, anchor-cli 0.20.1) being significantly slower, especially for larger programs (my small program deployments were still working fine). These were the versions that showed similar "msg" logging as OP.

Solution 2:

For deploying to devnet via Anchor, the error I got:

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
deploy to devnet: failed

Local npm package: @project-serum/anchor 0.19.0
Solana program dependencies: anchor-lang 0.19.0, anchor-spl 0.19.0, solana-program 1.9.4
deploy to devnet: successful or 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
deploy to devnet: successful or failed

in all cases, the global environment is the same:

Rust 1.57.0
solana-cli 1.9.4
@project-serum/anchor-cli 0.20.1

it seems sometimes the transaction may fail and those transactions include program deployment. see reference: https://www.brianfriel.xyz/resending-dropped-transactions-on-solana/