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

Switch from Borsh to Protobuf #357

Open
macalinao opened this issue Jun 3, 2021 · 1 comment
Open

Switch from Borsh to Protobuf #357

macalinao opened this issue Jun 3, 2021 · 1 comment
Labels

Comments

@macalinao
Copy link
Contributor

Borsh was built for being deterministic and bijective with no upgradability in mind (see near/nearcore#1166). This is not ideal for Solana programs that may want to expand state in future upgrades.

Protobuf is also great because it is already compatible with a lot of programming languages. The downside is that state must now be defined in a separate programming language, but this is not an uncommon practice when building distributed systems.

Protobuf also makes it easy to read any account without having to import a crate. This type of read will never get outdated because Protobuf is able to be reverse compatible with previous state definitions.

Theoretically, programs can even define their instructions and methods using an IDL similar to grpc. This would allow programs to expose their "headers" without revealing their source code.

@armaniferrante
Copy link
Member

As discussed offline, although this is an important issue, it's a major breaking change that will be punted for consideration for v2.0.0.

The main benefit I can tell that we get from proto is upgradeability baked into the IDL. The other benefits mentioned here w.r.t. being agnostic to programming languages and reading accounts without having to import a crate is also achieved with Borsh + IDL as currently implemented in Anchor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants