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

Borsh dependency needs to be updated to v1.5.1 #3277

Open
andreisilviudragnea opened this issue Sep 25, 2024 · 2 comments
Open

Borsh dependency needs to be updated to v1.5.1 #3277

andreisilviudragnea opened this issue Sep 25, 2024 · 2 comments
Labels
dependencies Pull requests that update a dependency file lang

Comments

@andreisilviudragnea
Copy link
Contributor

Solana v2.0.x uses borsh = { version = "1.5.1", features = ["derive", "unstable__schema"] }, while Anchor still uses borsh = "0.10.3".

This leads to compile errors when trying to use Anchor with spl-associated-token-account types in an Anchor program.

@acheroncrypto acheroncrypto added lang dependencies Pull requests that update a dependency file labels Sep 26, 2024
@acheroncrypto
Copy link
Collaborator

The problem is likely to be something else because Solana v2 also supports borsh 0.10.3. The master branch is currently on v2 and it's working fine.

However, Anchor v0.30 is not compatible with Solana v2 (it was released before Solana v2 is out), and v0.30 also specifies borsh = ">=0.9, <0.11" version requirement, meaning you could have borsh 0.9 in your Cargo.lock, which is incompatible with Solana v2. We've removed the borsh 0.9 support recently (#3199) to make it compatible with Solana v2.

The main problem for the upgrade is we're currently depending on internal borsh crates, but those crates no longer exist in v1 (bad timing — they've literally removed them just after we started using the internal crates), making us incapable of upgrading to borsh v1. I'm planning to solve this problem around the time we implement custom serialization, which should either be for v0.32 or v0.33.

@andreisilviudragnea
Copy link
Contributor Author

Yes, my problem was that I had to use borsh crate explicitly in a Solana v2.0.x program and use anchor_lang::prelude::*; imports borsh 0.10.3, so I had to explicitly add borsh = "1.5.1" as a dependency and refer to it as ::borsh instead of borsh in code to disambiguate from borsh exported by use anchor_lang::prelude::*;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file lang
Projects
None yet
Development

No branches or pull requests

2 participants