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

Favor Marshal/Unmarshal BinaryBare over Length-Prefixing #5748

Closed
4 tasks
alexanderbez opened this issue Mar 4, 2020 · 4 comments · Fixed by #5799
Closed
4 tasks

Favor Marshal/Unmarshal BinaryBare over Length-Prefixing #5748

alexanderbez opened this issue Mar 4, 2020 · 4 comments · Fixed by #5799

Comments

@alexanderbez
Copy link
Contributor

Summary

Nearly throughout the entire SDK, we use length-prefixing during serialization through a codec. There are a handful of places where this makes sense (e.g. result.Data), but a majority of the business logic does not work with or handle streams, so it makes no sense to length-prefix. Replace all occurrences with non-length-prefix variants.

/cc @aaronc


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@aaronc
Copy link
Member

aaronc commented Mar 4, 2020

@alexanderbez what are the cases where it makes sense in result.Data?

@alexanderbez
Copy link
Contributor Author

@alexanderbez what are the cases where it makes sense in result.Data?

https://github.com/cosmos/cosmos-sdk/blob/master/baseapp/baseapp.go#L611-L617

Example:

https://github.com/cosmos/cosmos-sdk/blob/master/x/staking/handler.go#L232-L247

These are the only cases that need to be length-prefixed.

@aaronc
Copy link
Member

aaronc commented Mar 5, 2020

Why not simplify things by just doing the length-prefixing in runMsgs? The less special context that people writing handlers need to know about, the better. IMHO we could get a way with a single MarshalBinary or Marshal method.

@alexanderbez
Copy link
Contributor Author

Why not simplify things by just doing the length-prefixing in runMsgs? The less special context that people writing handlers need to know about, the better. IMHO we could get a way with a single MarshalBinary or Marshal method.

We can -- I'm just letting you know the edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment