-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: Upgrade to borsh 1.2.1 #34355
sdk: Upgrade to borsh 1.2.1 #34355
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #34355 +/- ##
=========================================
- Coverage 81.9% 81.8% -0.1%
=========================================
Files 819 819
Lines 220569 220823 +254
=========================================
+ Hits 180788 180805 +17
- Misses 39781 40018 +237 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I'm fine with the approach. Just a few small questions.
I'm looking forward to seeing most of this removed in solana v2 😅
@@ -46,6 +46,7 @@ const MAX_BASE58_LEN: usize = 44; | |||
Pod, | |||
Zeroable, | |||
)] | |||
#[borsh(crate = "borsh")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incidentally, is there a good place to read documentation of borsh
tags? I looked on their repo and rust docs, but must have missed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs.rs was the best source at https://docs.rs/borsh/latest/borsh/derive.BorshDeserialize.html but I did also have to read the source directly too. This one tripped me up for awhile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wfm, thanks for working through all this!
Problem
Borsh has released major version 1, and we're still on 0.10 everywhere.
Summary of Changes
Add default support borsh v1 on all structs, with backward compatibility on
Pubkey
and theStake
structs. There were some changes in the schema interface with v1, which required updatingget_packed_len
.The concept is to also maintain backwards compatibility with v0.9, and we can drop support for older versions whenever we decide to move to sdk v2.
There's also a bit of copy-pasta for the stake structs, which was copied from
cargo expand
on version 0.10.3. We could eventually go with #32668 to derive everything by macro, but I went the lazy route. Let me know if you prefer the proxy-crate approach!I've tested a few downstream programs, including SPL, Anchor, and the Metaplex token-auth rules. Metaplex token-metadata and some of its upstream dependencies reject anything greater than 1.16, and I didn't want to bother patching many repos for the test, so I just tried the most upstream one.
I'll also check around with some ecosystem teams to see what else I can check.
Fixes #