0

here is my code, I'm using anchor 0.26.0. I'm getting some error while building

use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod counter {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
        let count = &mut ctx.accounts.count;
        count.count = 0;
        Ok(())
    }

    pub fn increment(ctx: Context<Increment>) -> Result<()> {
        let count = &mut ctx.accounts.count;
        count.count += 1;
        Ok(())
    }

    pub fn decrement(ctx: Context<Decrement>) -> Result<()> {
        let count = &mut ctx.accounts.count;
        count.count -= 1;
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info>{
    #[account(init, payer = signer, space = Count::SIZE)]
    pub count: Account<'info, Count>,
    #[account(mut)]
    pub signer: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
pub struct Increment<'info>{
    #[account(mut)]
    pub count: Account<'info, Count>,
}

#[derive(Accounts)]
pub struct Decrement<'info>{
    #[account(mut)]
    pub count: Account<'info, Count>,
}

#[account]
pub struct Count{
    pub count: i32,
}

impl Count{
    pub const SIZE: usize = 8 + 4;
}

and error:

Error: Function _ZN94_$LT$$RF$mut$u20$bincode..de..Deserializer$LT$R$C$O$GT$$u20$as$u20$serde..de..Deserializer$GT$17deserialize_tuple17hc95988d4434a0508E Stack offset of 11472 exceeded max offset of 4096 by 7376 bytes, please minimize large stack variables

Error: Function _ZN14solana_program4vote5state9VoteState11deserialize17h8b2a261739cdf8a8E Stack offset of 5664 exceeded max offset of 4096 by 1568 bytes, please minimize large stack variables

how do I fix it?

1
  • This seems to be an issue with the more recent solana releases. Check out this answer. Usually you can just ignore it. Is it actually affecting your program's ability to run?
    – Ademola
    Commented Feb 16, 2023 at 14:00

1 Answer 1

1

This may be related to an incompatibility between the latest versions of anchor and Solana.

Try forcing an older version of Solana in Cargo.toml. Curious if this works.

[workspace.dependencies]
anchor-lang = "0.26.0"
anchor-spl = "0.26.0"
solana-program = "=1.14.14"
4
  • this works ! (i used solana program 1.14.12)
    – Dev Bharel
    Commented Feb 17, 2023 at 23:36
  • hey, I added this, still it's fetching solana-program v1.15.2
    – pramitgaha
    Commented Feb 18, 2023 at 6:06
  • I scaffolded a project and added the above code, still it's compiling with version 1.15.2
    – pramitgaha
    Commented Feb 18, 2023 at 7:11
  • 1
    so I had to add more line to make compile with v1.14.14. I added these line [dependencies] anchor-lang = { workspace = true} solana-program = { workspace = true}
    – pramitgaha
    Commented Feb 18, 2023 at 8:24

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.