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

declare_program! panics when program has a shared Accounts context #3349

Open
tomjohn1028 opened this issue Nov 7, 2024 · 1 comment · May be fixed by #3350
Open

declare_program! panics when program has a shared Accounts context #3349

tomjohn1028 opened this issue Nov 7, 2024 · 1 comment · May be fixed by #3350
Labels
bug Something isn't working lang

Comments

@tomjohn1028
Copy link
Contributor

tomjohn1028 commented Nov 7, 2024

Description

The declare_program! macro is panicking with the error below when used with a program that uses shared contexts across multiple instructions.

error[E0428]: the name `__cpi_client_accounts_shared_accounts` is defined multiple times
 --> lib/my-crate/src/lib.rs:3:1
  |
3 | declare_program!(external_program);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `__cpi_client_accounts_shared_accounts` redefined here
  |
  = note: `__cpi_client_accounts_shared_accounts` must be defined only once in the type namespace of this module
  = note: this error originates in the macro `declare_program` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0428]: the name `__client_accounts_shared_accounts` is defined multiple times
 --> lib/my-crate/src/lib.rs:3:1
  |
3 | declare_program!(external_program);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `__client_accounts_shared_accounts` redefined here
  |
  = note: `__client_accounts_shared_accounts` must be defined only once in the type namespace of this module
  = note: this error originates in the macro `declare_program` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0428`.
error: could not compile `my-crate` (lib) due to 2 previous errors

Steps to Reproduce

  1. Checkout branch on this fork https://github.com/exo-tech-xyz/anchor/tree/declare-program-client-redefined
  2. cd /tests/declare-program
  3. cargo build
@acheroncrypto acheroncrypto added bug Something isn't working lang labels Nov 7, 2024
@tomjohn1028
Copy link
Contributor Author

tomjohn1028 commented Nov 8, 2024

Came back to this and realized it only happens when running cargo build, so worth noting I'm attempting to use declare_program! in an off-chain program.

On this branch I was able to reproduce the error and edited the above to include the steps.

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