Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spl-transfer-hook create-extra-metas : Result::unwrap() on an Err` value: Downcast #6623

Closed
Ai-Artsca opened this issue Apr 24, 2024 · 10 comments · Fixed by #6625
Closed

spl-transfer-hook create-extra-metas : Result::unwrap() on an Err` value: Downcast #6623

Ai-Artsca opened this issue Apr 24, 2024 · 10 comments · Fixed by #6625
Assignees
Labels
bug Something isn't working

Comments

@Ai-Artsca
Copy link

metaharm@MSI:~/extensions/solana-program-library/token/transfer-hook/example$ ../../../target/debug/spl-transfer-hook create-extra-metas HookqC4zUVMzYkVVZiGz9vu13XHc9XTBcqgtMb9yUtHt TokDibMzhbqs833NcxTFq7J6pfb6mB6hhCRiydHCgcv
thread 'main' panicked at token/transfer-hook/cli/src/main.rs:447:18:
called Result::unwrap() on an Err value: Downcast { actual: solana_clap_v3_utils::keypair::SignerSource, expected: alloc::string::String }
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Backtrace:
RUST_BACKTRACE=1 ../../../target/debug/spl-transfer-hook create-extra-metas HookqC4zUVMzYkVVZiGz9vu13XHc9XTBcqgtMb9yUtHt TokDibMzhbqs833NcxTFq7J6pfb6mB6hhCRiydHCgcv
thread 'main' panicked at token/transfer-hook/cli/src/main.rs:447:18:
called Result::unwrap() on an Err value: Downcast { actual: solana_clap_v3_utils::keypair::SignerSource, expected: alloc::string::String }
stack backtrace:
0: rust_begin_unwind
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
3: core::result::Result<T,E>::unwrap
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1073:23
4: spl_transfer_hook::main::{{closure}}
at /home/metaharm/extensions/solana-program-library/token/transfer-hook/cli/src/main.rs:446:30
5: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/park.rs:281:63
6: tokio::runtime::coop::with_budget
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:107:5
7: tokio::runtime::coop::budget
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:73:5
8: tokio::runtime::park::CachedParkThread::block_on
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/park.rs:281:31
9: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/context/blocking.rs:66:9
10: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
11: tokio::runtime::context::runtime::enter_runtime
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/context/runtime.rs:65:16
12: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
13: tokio::runtime::runtime::Runtime::block_on
at /home/metaharm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/runtime.rs:351:45
14: spl_transfer_hook::main
at /home/metaharm/extensions/solana-program-library/token/transfer-hook/cli/src/main.rs:528:5
15: core::ops::function::FnOnce::call_once
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

@buffalojoec
Copy link
Contributor

Hey @Ai-Artsca you'll have to provide a little context here to describe why you think this is a bug with one of the SPL crates, and not a test panic you're hitting with the example test suite.

@Ai-Artsca
Copy link
Author

Ai-Artsca commented Apr 24, 2024

Hey @Ai-Artsca you'll have to provide a little context here to describe why you think this is a bug with one of the SPL crates, and not a test panic you're hitting with the example test suite.

I encountered a runtime panic while running the spl-transfer-hook create-extra-metas command from the Solana Program Library (SPL) token transfer-hook example. The error arises due to an unwrapped Result returning an Err value. Below is the command and error output for reference.

../../../target/debug/spl-transfer-hook create-extra-metas HookqC4zUVMzYkVVZiGz9vu13XHc9XTBcqgtMb9yUtHt TokDibMzhbqs833NcxTFq7J6pfb6mB6hhCRiydHCgcv
Error Output

thread 'main' panicked at token/transfer-hook/cli/src/main.rs:447:18:
called Result::unwrap() on an Err value: Downcast { actual: solana_clap_v3_utils::keypair::SignerSource, expected: alloc::string::String }
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Context
This issue occurred while attempting to run one of the provided example commands in the SPL token transfer-hook example. It seems the error originates from an incorrect type expectation during unwrapping.

Attempted Resolution
I attempted running the command with RUST_BACKTRACE=1 for a more detailed backtrace, confirming the issue is consistent and replicable:

Backtrace Excerpt

0: rust_begin_unwind
...
15: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
Request for Assistance
Can someone help clarify if this is a bug within the SPL crates, or if there might be a mistake in how the example test suite is being executed? Any guidance on how to properly handle or prevent this panic would be greatly appreciated.

Thank you for your time and assistance!

@buffalojoec
Copy link
Contributor

Gotcha! Thanks. I can re-produce your issue. Looks like a bug!

@buffalojoec buffalojoec added the bug Something isn't working label Apr 24, 2024
@buffalojoec
Copy link
Contributor

Looks like this PR caused the breakage.
#6525

If I revert back to the deprecated functions, everything works fine.

@samkim-crypto have you seen this at all with the new Clap v3 stuff?

@samkim-crypto
Copy link
Contributor

Yeah, sorry about that! The new clap-v3-utils parsers are used when declaring the arguments, but the original incompatible parsers are used when actually parsing the arguments. I think we will need to upgrade to the latest solana-clap-v3-utils = 1.18.11 to fix this, but I'll fix it once we do.

@samkim-crypto samkim-crypto self-assigned this Apr 24, 2024
@buffalojoec
Copy link
Contributor

Yeah, sorry about that! The new clap-v3-utils parsers are used when declaring the arguments, but the original incompatible parsers are used when actually parsing the arguments. I think we will need to upgrade to the latest solana-clap-v3-utils = 1.18.11 to fix this, but I'll fix it once we do.

Great, thanks! Saw your PR to bump to 1.18.11. Let me know if you need anything!

@Ai-Artsca
Copy link
Author

Thanks again for the help! Could you please specify which version of solana-clap-v3-utils does not have this bug, so I can continue with my tutorial? Also, would updating the cargo.toml file in the cli folder to this version and running cargo update be the correct steps to resolve this issue? Any guidance on the easiest steps to update would be greatly appreciated!

@samkim-crypto
Copy link
Contributor

The fix requires both an upgrade to solana-clap-v3-utils = 1.18.11 (#6624) and the removal of pubkey_of_signer (#6625). The first PR is merged, so you can checkout branch from the second PR and continue with the tutorial. Alternatively, you can also wait until the second PR is also merged to master.

@Ai-Artsca
Copy link
Author

Ai-Artsca commented Apr 24, 2024

I've updated the main.rs and modified the cargo.toml in the cli folder as discussed, and then ran cargo build for the CLI. Afterward, I executed the following command:

../../../target/debug/spl-transfer-hook create-extra-metas HookSNukpeokYkzRdKwK1d4LYMmNXGPkotw5cwqnwVyz TokkZcu8RTE46yWjF7LMTqqKa6LzTVM438qZDfz3qZH

However, I encountered a new error related to transaction simulation:
error: send transaction: error: send transaction: RPC response error -32002: Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction [7 log messages]

solana config get:
RPC URL: https://api.devnet.solana.com

Could you help me understand what might be causing this new issue? Any advice on how to troubleshoot or correct this would be greatly appreciated. Thank you!

@buffalojoec
Copy link
Contributor

Hey @Ai-Artsca the original issue you've reported here has been fixed with #6625, so I'm going to close the issue. The error you're reporting now is not a bug with the CLI, it likely means you need to configure your "extra account metas" account and/or hook program.

Feel free to ask for assistance with the Transfer Hook example on Stack Exchange!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants