1

I was using anchor version 0.25.0, this error was not in that version, Now I'm using latest version of anchor, I'm using zero_copy on all the structs here are the dependencies

[profile.release]
overflow-checks = true

[dependencies]
#anchor-lang = {version = "0.30.1", features = ["init-if-needed"]}
#anchor-spl = {version = "0.30.1"}
anchor-lang = { git = "https://github.com/coral-xyz/anchor", features = ["init-if-needed"] } 
anchor-spl = { git = "https://github.com/coral-xyz/anchor" } 
borsh = {version = "0.10.3", features = ["const-generics"]}
mpl-token-metadata = {version = "3.2.3"}
solana-program = {version = "1.18.18"}
streamflow-sdk = {version = "0.6.2", features = ["cpi","mainnet"]}
bytemuck = {version = "1.9.1", features = ["derive", "min_const_generics"]}

Build gets finished but i get this type of errors for 4 functions, Will the program and this function work if i were to deploy this program from this build ?

Edit :

I used the anchor-lang and anchor-spl from github rather then 0.30.1 then i get this error

 the trait bound `streamflow_sdk::cpi::accounts::Update<'_>: anchor_lang::ToAccountInfos<'_>` is not satisfied
   --> programs/nodestore/src/helpers.rs:525:9
    |
523 |     let cpi_ctx = CpiContext::new_with_signer(
    |                   --------------------------- required by a bound introduced by this call
524 |         ctx.accounts.streamflow_program.to_account_info(),
525 |         accs,
    |         ^^^^ the trait `anchor_lang::ToAccountInfos<'_>` is not implemented for `streamflow_sdk::cpi::accounts::Update<'_>`
    |
help: trait impl with same name found
   --> src/lib.rs:580:10
    = note: perhaps two different versions of crate `anchor_lang` are being used?
    = help: the following other types implement trait `anchor_lang::ToAccountInfos<'info>`:
              Box<T>
              anchor_spl::associated_token::Create<'info>
              associated_token::__cpi_client_accounts_create::Create<'info>
              anchor_spl::token::Transfer<'info>
              anchor_spl::token::__cpi_client_accounts_transfer::Transfer<'info>
              anchor_spl::token::TransferChecked<'info>
              anchor_spl::token::__cpi_client_accounts_transfer_checked::TransferChecked<'info>
              anchor_lang::prelude::Sysvar<'info, T>
            and 248 others
note: required by a bound in `anchor_lang::context::CpiContext::<'a, 'b, 'c, 'info, T>::new_with_signer`
   --> src/context.rs:195:5
    = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)

This is probably beacuse conflicting anchor versions

Edit 2 :

I commented these version errors, Now i get this stack frame error in 1 function, even when using the anchor version from github

Error: Function _ZN9nodestore9nodestore22advance_rewards_pt_fnd17h04aae59db81a97b7E Stack offset of 6648 exceeded max offset of 4096 by 2552 bytes, please minimize large stack variables
2

3 Answers 3

3

There is an anchor bug in combination with solana version 1.18 which is causing this error:

Function ZN105$LT$vprog..InitializeStrategy$u20$as$u20$anchor_lang
..Accounts$LT$vprog..
InitializeStrategyBumps$GT$$GT$12try_accounts17hb64a220c71e28f36E
 Stack offset of 5168 exceeded max offset of 4096 by 1072 bytes,
 please minimize large stack variables

The issue has been solved here:https://github.com/coral-xyz/anchor/pull/2939 and you can read the whole dicussion about the problem here: https://github.com/anza-xyz/agave/issues/1186

At the moment using 1.18 with plattform tools 1.41 not all stack frame errors are visible at compile time like in the warning. This is fixed here with plattform tools version 1.42. https://github.com/anza-xyz/agave/pull/2461 There is no backport yet to version 1.18.

So most of these errors will be fixed using the new anchor version: https://github.com/coral-xyz/anchor/pull/2939 in combination with Anza Agave 2.0.

The release of this is still blocked by the new meta data program upgrade as can be seen here.
https://github.com/anza-xyz/agave/issues/1186

You can either patch it yourself using force inline like in the Anchor PR or box more of your accounts and decrease the stack size like that manually and get rid of the warning. Its recommended to not have these warning since they can result in runtime errors.

There is a solution on the way for the stack frame problems which will fix these problems forever, but it still needs to go through the SIMD process: (see https://github.com/solana-foundation/solana-improvement-documents/pull/166)

8
  • Trying to add #[inline(never)], over the function like #[inline(never)] pub fn advance_rewards_pt_fnd(, But this only reduces the stack size by a little, Should i add anywhere else ? @Jonas H. Commented Sep 10 at 12:20
  • 1
    I think the inline(never) needs to be on the generate_constraint_init_group github.com/coral-xyz/anchor/pull/2939/files. Did you try build with the master version that has the fix? Like so: anchor-lang = { git = "github.com/coral-xyz/anchor", features = ["init-if-needed"] } anchor-spl = { git = "github.com/coral-xyz/anchor" }
    – Jonas H.
    Commented Sep 10 at 12:37
  • Updated the question, Please have a look Commented Sep 10 at 13:57
  • 1
    looks like smth else is pulling a different anchor version. Can you post your updated toml file?
    – Jonas H.
    Commented Sep 10 at 15:32
  • Updated the question with the new toml file @Jonah H Commented Sep 10 at 17:29
1

Everything Jonas mentioned above is correct.

You'll need to downgrade your Solana CLI version. The last working version I used was 1.18.11.

solana-install init 1.18.11

You can leave your original toml as was.

4
  • Still the same error Commented Sep 11 at 8:00
  • In edit 1 or 2?
    – Jimii
    Commented Sep 11 at 8:46
  • tried it n both of them, same result @Jimii Commented Sep 11 at 10:53
  • 1
    tried it on an older project and got the stack overflow error too. can you downgrade further to 1.17.34?
    – Jimii
    Commented Sep 11 at 14:04
1

What @Jonas H. Says about this case is true , But there are still some stack frame errors, SO Ultimately what i did was Downgraded my anchor version to 0.25.0, which it previously was when it was working, And used 1.14.18 solana cli to compile it. At the current time it is not compilable with the 1.14.18 cli lot of dependency issues. So I found a Cargo.lock file from a year ago when the program was being compiled with 1.14.18 and replaced it with the current cargo.lock file. Now the program is being compiled as well as no runtime execution errors.

Another option was to use 1.16.x,to use this i didn't have to mess with the cargo.lock file and no compile time errors , But It had some runtime errors like Inner instruction too larger ((Some Big number)>1280).

1
  • 1
    Uff ,good you found a solution. I hope you will be able to upgrade when the new anchor release is out.
    – Jonas H.
    Commented Sep 12 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.