Description
Summary
Encoding in the SDK is currently handled by the go-amino wire codec. The implementation and use of this encoding protocol has introduced several major concerns over time, with the two biggest being performance and cross-client/language support.
The context and discussions had over amino are dense, so the above is solely meant to be a high-level primer.
Problem Definition
In order to facilitate easier integration for clients and drastically improve the usability of the SDK and its performance, alternative encoding methods need to be explored.
Proposal
As it stands, the proposals are as follows:
- Update go-amino to be fully proto3 compatible. There is already a PR that attempts to achieve this.
a. This is probably the path of least resistance but doesn't actually solve any of our problems directly and seems like a fragile attempt that will require handling corner-cases increasing the surface area for bugs and poor UX support. - Remove go-amino entirely in favor of gogo-proto.
a. This seems to be the most viable and promising approach. It will address both performance and client UX concerns. - Remove go-amino entirely in favor of capn-proto.
a. Similar to proposal (2) but with zero-copy and canonicalization features. However, the concern is somewhat of "vendor-lockin" in terms of not having as rich of a multi-client support as pure proto. AFAIK, encoding uses fixed-width integers so this approach could lead to larger encoding size. Compaction is available, but doing so negates the zero-copy feature. - Consider another encoding scheme entirely (e.g. flatbuffers).
a. Too late for this most likely (atm). It would require heavy research and pretty compelling arguments to steer toward this direction. In addition, it would probably take drastically more time than any other proposal.
Accepted Proposal
Proposal (2) will be adopted. However, @jaekwon will continue to develop go-amino with the goal of it being fully wire-compatible with this proposal. The go-amino proposal is tracked in tendermint/go-amino#302.
What does this mean?
- When the amino changes are complete, we shall revisit reincorporating go-amino based mainly on UX and performance.
- Interfaces must adhere to the
oneof
implementation where theoneof
is the only field member and the sum fields must start at 1. - Modules will define their own messages and types that must be binary serialized and persisted using package name
cosmos_sdk.{module}.v1
. - An application-level codec will exist with a single
oneof
to handle messages.
Roadmap & Actionables
State
- x/staking Migrate x/staking to Protobuf #5600
- x/distribution proto: migrate x/distr to use hybrid codec #5610
- x/crisis proto: migrate x/distr to use hybrid codec #5610
- x/auth Protobuf: x/auth & x/supply #5533
- x/supply Protobuf: x/auth & x/supply #5533
- x/evidence proto: migrate x/evidence to hybridcodec #5634
- x/params proto: migrate params to hybrid codec #5619
- x/upgrade Migrate upgrade module to protobuf #5659
- x/mint proto: migrate x/evidence to hybridcodec #5634
- x/bank proto: migrate bank to hybridcodec #5681
- x/gov
- x/slashing Regen Network/Slashing protobuf #5627
- x/capability Migrate x/capability to Protobuf #5926
- x/ibc x/ibc proto migration #5704 - only pending ibc client migration
- x/params reliance on Amino JSON encoding for parameter serialization
- Pubkeys???
Client
TX CLI/REST
- Transaction Client (CLI & REST) Protobuf Migration #5864
- Simulation Decoder Refactor #5664
- Reconsider Code Usage in x/auth Client #5663
Tutorials
- nameservice
- scavenge
Documentation & Upgrade Guide
- Update Encoding Doc #5647
- Write a blog post for how users should upgrade
Client libs
- cosmos/amino-js (if need be)
@jordansexton @aaronc
For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate contributors tagged
- Contributor assigned/self-assigned
Activity