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

sdk: Upgrade to borsh 1.2.1 #34355

Merged
merged 10 commits into from
Dec 8, 2023
Merged

sdk: Upgrade to borsh 1.2.1 #34355

merged 10 commits into from
Dec 8, 2023

Conversation

joncinque
Copy link
Contributor

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 the Stake structs. There were some changes in the schema interface with v1, which required updating get_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 #

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Merging #34355 (52e2325) into master (ae77131) will decrease coverage by 0.1%.
Report is 5 commits behind head on master.
The diff coverage is 21.3%.

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     

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a 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 😅

sdk/program/src/borsh.rs Outdated Show resolved Hide resolved
sdk/src/compute_budget.rs Show resolved Hide resolved
@@ -46,6 +46,7 @@ const MAX_BASE58_LEN: usize = 44;
Pod,
Zeroable,
)]
#[borsh(crate = "borsh")]
Copy link
Contributor

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.

Copy link
Contributor Author

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

transaction-status/Cargo.toml Show resolved Hide resolved
Copy link
Contributor

@CriesofCarrots CriesofCarrots left a 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!

@joncinque joncinque merged commit cfb16ab into solana-labs:master Dec 8, 2023
46 checks passed
@joncinque joncinque deleted the borshup branch December 8, 2023 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants