1

I have a program which is on 0.28.0, and it uses an 0.26.0 dep. It builds without issue. Let's say the deps look like:

[dependencies]
anchor-lang = "0.28.0"
solana-program = "=1.16.23"

#This is an anchor 0.26.0 project (solana program 1.14.x)
whirlpool = { git = "https://github.com/orca-so/whirlpools", rev = "7f7ee90", features = ["cpi"] }

Now I have an account I want to load from the dep:

pub clp_pool: UncheckedAccount<'info>,

In my handler I can do:

let acc: Account<'info, whirlpool::state::Whirlpool> = Account::try_from(&clp_pool)?;

This works great if my program is on 0.26.0, but if I am on 0.28.0, it fails with the trait bound whirlpool::state::Whirlpool: anchor_lang::AccountSerialize is not satisfied perhaps two different versions of crate anchor_lang are being used?, probably because of the borsch changes in solana-program.

How can I get this 0.26.0 account to deserialize in 0.28.0?

Note that the account is not repr(C) so I can't bytemuck it. Also, if I downgrade to 1.14.28 (which would be the default if I didn't lock the version to 1.16.23), I'll get the Invoked an instruction with data that is too large (12884933804 > 10240) error because of those changes.

3
  • This is an option, but if padding changes between Anchor versions it wouldn't work, and it's jank because it ignores discrim checks and other anchor features: let data = &clp_pool.try_borrow_data()?[..]; let whirlpool = whirlpool::state::Whirlpool::try_from_slice(data)?;
    – Whiteseal
    Commented Dec 19, 2023 at 22:39
  • let data = &clp_pool.try_borrow_data()?[8..];
    – Whiteseal
    Commented Dec 20, 2023 at 0:17
  • It's not a great solution, but you could always fork the orca repo, upgrade it to 0.28, and use that in your project. Or push the orca team to upgrade :-D
    – Jon C
    Commented Jan 3 at 19:56

0

Your Answer

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

Browse other questions tagged or ask your own question.