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

chore: update borsh dependency #9432

Merged
merged 12 commits into from
Oct 10, 2023
Merged

chore: update borsh dependency #9432

merged 12 commits into from
Oct 10, 2023

Conversation

dj8yfo
Copy link
Contributor

@dj8yfo dj8yfo commented Aug 15, 2023

borsh-rs 1.0.0 release is a major milestone and it makes sense to update nearcore to use it.

Here is the migration guide that was captured along the way: https://github.com/near/borsh-rs/blob/borsh-v1.0.0/docs/migration_guides/v0.10.2_to_v1.0.0_nearcore.md

@dj8yfo dj8yfo force-pushed the borsh_update branch 3 times, most recently from f0273d8 to 95314b5 Compare August 16, 2023 12:42
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dj8yfo Enormous effort! Borsh 1.0 is knocking on the door!

@frol
Copy link
Collaborator

frol commented Oct 8, 2023

@dj8yfo Please, update to borsh 1.0, rebase, and let's merge it 🙏

@dj8yfo dj8yfo marked this pull request as ready for review October 9, 2023 19:21
@dj8yfo dj8yfo requested a review from a team as a code owner October 9, 2023 19:21
@dj8yfo dj8yfo requested a review from akhi3030 October 9, 2023 19:21
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I totally did not expect so many places needed https://docs.rs/borsh/latest/borsh/fn.object_length.html

chain/network/src/types.rs Show resolved Hide resolved
core/store/benches/finalize_bench.rs Outdated Show resolved Hide resolved
core/store/src/genesis/state_applier.rs Outdated Show resolved Hide resolved
core/store/src/trie/split_state.rs Outdated Show resolved Hide resolved
genesis-tools/genesis-populate/src/state_dump.rs Outdated Show resolved Hide resolved
integration-tests/src/tests/client/benchmarks.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/verifier.rs Outdated Show resolved Hide resolved
tools/amend-genesis/src/lib.rs Outdated Show resolved Hide resolved
(mostly `borsh::to_vec(&obj).unwrap().len()` -> `borsh::object_length(&obj).unwrap()` )
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dj8yfo Well done!

@Longarithm
Copy link
Member

Looks great. Minor non-blocking question - why try_to_vec was deprecated? Couldn't find the reason in migration guide.

@Longarithm Longarithm added this pull request to the merge queue Oct 10, 2023
Merged via the queue into near:master with commit 3a56da2 Oct 10, 2023
9 checks passed
@dj8yfo
Copy link
Contributor Author

dj8yfo commented Oct 10, 2023

Looks great. Minor non-blocking question - why try_to_vec was deprecated?

@matklad suggested that it didn't make sense to override this trait method => it should not be a trait method, but rather an external helper. Couldn't come up with counterexamples. It may make sense to override initial vector allocation capacity per type, but that can be done with introducing a constant on BorshSerialize trait.
Besides, it kinda looks compact, fully qualified, cool and uniform with serde_json::to_vec.

Couldn't find the reason in migration guide.

i think more context can be found by following a trail hyperlinks, reachable from migration guide

@matklad
Copy link
Contributor

matklad commented Oct 10, 2023

Specific reasons here:

  • to mirror serde::to_vec API. Serde is extremely popular, mirroring its API is good just for that reason.
  • borsh::to_vec(&val) is more obvious at call-site than x.try_to_vec, for two reasons:
    • It doesn't require trait import (and the associated method resolution reasoning)
    • In x.try_to_vec, nothing mentions borsh; that's not great for a method available on a wide array of types.

@frol
Copy link
Collaborator

frol commented Oct 10, 2023

Couldn't find the reason in migration guide.

It was useful for borsh-rs developers and for those who will also need to migrate from older version of borsh to the new one. nearcore team is lucky one for getting the migration done by borsh-rs maintainer, but solana (also uses borsh-rs) is not that lucky :-P, but at least they have some guides to follow.

nikurt pushed a commit that referenced this pull request Oct 11, 2023
[borsh-rs 1.0.0
release](https://github.com/near/borsh-rs/releases/tag/borsh-v1.0.0) is
a major milestone and it makes sense to update nearcore to use it.

Here is the migration guide that was captured along the way:
https://github.com/near/borsh-rs/blob/borsh-v1.0.0/docs/migration_guides/v0.10.2_to_v1.0.0_nearcore.md
nikurt pushed a commit that referenced this pull request Oct 11, 2023
[borsh-rs 1.0.0
release](https://github.com/near/borsh-rs/releases/tag/borsh-v1.0.0) is
a major milestone and it makes sense to update nearcore to use it.

Here is the migration guide that was captured along the way:
https://github.com/near/borsh-rs/blob/borsh-v1.0.0/docs/migration_guides/v0.10.2_to_v1.0.0_nearcore.md
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.

4 participants