solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.19k stars 4.3k forks source link

Invalid blockhash error when using solana-tokens cli #22900

Closed elliott-w closed 2 years ago

elliott-w commented 2 years ago

Problem

When running solana-tokens distribute-spl-tokens, getting:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
ClientError { request: None, kind: Custom("Invalid blockhash") }', 
/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/solana-tokens-1.9.5/src/spl_token.rs:101:10

I believe this is because the blockhash times out between

  1. Creating the token distribution messages (most recent blockhash assigned to each message here) fn build_messages
  2. Checking the payer has sufficient spl tokens to distribute fn check_spl_token_balances
  3. Sending the messages fn send_messages

Proposed Solution

I don't have that much experience with rust/solana, so this could be completely wrong, but would it be possible - between steps 2 and 3 - to loop through all the messages and re-assign them the latest blockhash?

CriesofCarrots commented 2 years ago

Actually, looks like it's failing for you within step 2. Now that get_fee_for_message depends on a valid blockhash, I think we do probably need to refresh it inside fn check_spl_token_balances.

In the meantime, you may have luck batching distributions in smaller chunks.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any activity in past 7 days after it was closed. Please open a new issue for related bugs.