-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
sdk: Limited Borsh 0.9 support (Pubkey and helpers) #32511
Conversation
To build metaplex, would a borsh 0.9 version of |
can we not that is, something like... #[derive(BorshSerialized, borsh0_9::BorshSerialize)]
struct Pubkey... |
Yes, but only if it's at
No, the macro uses |
ugh. didn't realize that carry on |
Codecov Report
@@ Coverage Diff @@
## master #32511 +/- ##
=========================================
- Coverage 82.0% 82.0% -0.1%
=========================================
Files 785 785
Lines 211100 211073 -27
=========================================
- Hits 173170 173106 -64
- Misses 37930 37967 +37 |
Restore |
We could, but then we break people who have upgraded 😅 |
Yeah, ⚖️. That's ideally what we would have done from the start probably, but yeah probably too late for that now. Are you thinking of adding a |
I wasn't planning on it, since it wouldn't solve the initial metaplex build issue. But thinking on it more, it could be used if an upgraded program wants to do use the helpers on older types. I'll add it in |
Sorry for the holdup here, I added the |
There are solutions like this: https://docs.rs/proc-macro-crate/1.3.1/proc_macro_crate/ My bad. |
There is a way to use
I do not think this is possible. |
Very cool, thanks for showing how to do it! Actually, while I have you here @ilya-bobyr ... I was thinking of moving the borsh dependency entirely out of the sdk, and do it through some sort of new crate like And what do you think of this PR? I'd like to land it soon to help adoption of 1.16 |
@ilya-bobyr as discussed offline, I've also added |
* sdk: Implement Borsh 0.9 traits on Pubkey * Alphabetize cargo.toml * Add backwards-compatible borsh file * Add borsh0_10.rs for more clarity * Deprecate `borsh` utils, use borsh0_10 everywhere * Mark borsh 0.9 helpers as deprecated * Add macros for deriving helper impls * Add borsh 0.9 tests * Refactor tests into macro (cherry picked from commit 8c14886) # Conflicts: # sdk/src/lib.rs
#32511) (#32697) * sdk: Limited Borsh 0.9 support (Pubkey and helpers) (#32511) * sdk: Implement Borsh 0.9 traits on Pubkey * Alphabetize cargo.toml * Add backwards-compatible borsh file * Add borsh0_10.rs for more clarity * Deprecate `borsh` utils, use borsh0_10 everywhere * Mark borsh 0.9 helpers as deprecated * Add macros for deriving helper impls * Add borsh 0.9 tests * Refactor tests into macro (cherry picked from commit 8c14886) # Conflicts: # sdk/src/lib.rs * Fix merge conflict on re-exports --------- Co-authored-by: Jon Cinque <me@jonc.dev>
Problem
The upgrade to Solana 1.16 crates has been very painful for a number of teams due to the incompatibility between Borsh 0.9 and 0.10, which should have constituted a major version upgrade for the Solana SDK crates. A lot of these are due to the borsh 0.9 traits not being implemented on the SDK types, not counting the issues like #31960
Summary of Changes
To alleviate one class of issues, also implement the borsh 0.9 traits on
Pubkey
.Note that it still won't be possible to build the metaplex crates because they use the
solana_program::borsh::get_packed_len
helper, which targets borsh 0.10 in the solana crates. The solution here is to version the solana helpers and deprecate the generalsolana_program::borsh
file. This way, it's impossible to break people when we add support for a new version of borsh.This will also be backported to 1.16.
These manual implementations were generated by running
cargo expand
on borsh 0.9, copy-pasting, and then adding the proper annotations everywhere to use borsh 0.9 versions.Fixes #