You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.8 KiB

  1. # ADR 054: Crypto encoding (part 2)
  2. ## Changelog
  3. 2020-2-27: Created
  4. 2020-4-16: Update
  5. ## Context
  6. Amino has been a pain point of many users in the ecosystem. While Tendermint does not suffer greatly from the performance degradation introduced by amino, we are making an effort in moving the encoding format to a widely adopted format, [Protocol Buffers](https://developers.google.com/protocol-buffers). With this migration a new standard is needed for the encoding of keys. This will cause ecosystem wide breaking changes.
  7. Currently amino encodes keys as `<PrefixBytes> <Length> <ByteArray>`.
  8. ## Decision
  9. Previously Tendermint defined all the key types for use in Tendermint and the Cosmos-SDK. Going forward the Cosmos-SDK will define its own protobuf type for keys. This will allow Tendermint to only define the keys that are being used in the codebase (ed25519).
  10. There is the the opportunity to only define the usage of ed25519 (`bytes`) and not have it be a `oneof`, but this would mean that the `oneof` work is only being postponed to a later date. When using the `oneof` protobuf type we will have to manually switch over the possible key types and then pass them to the interface which is needed.
  11. The approach that will be taken to minimize headaches for users is one where all encoding of keys will shift to protobuf and where amino encoding is relied on, there will be custom marshal and unmarshal functions.
  12. Protobuf messages:
  13. ```proto
  14. message PubKey {
  15. oneof key {
  16. bytes ed25519 = 1;
  17. }
  18. message PrivKey {
  19. oneof sum {
  20. bytes ed25519 = 1;
  21. }
  22. }
  23. ```
  24. > Note: The places where backwards compatibility is needed is still unclear.
  25. All modules currently do not rely on amino encoded bytes and keys are not amino encoded for genesis, therefore a hardfork upgrade is what will be needed to adopt these changes.
  26. This work will be broken out into a few PRs, this work will be merged into a proto-breakage branch, all PRs will be reviewed prior to being merged:
  27. 1. Encoding of keys to protobuf and protobuf messages
  28. 2. Move Tendermint types to protobuf, mainly the ones that are being encoded.
  29. 3. Go one by one through the reactors and transition amino encoded messages to protobuf.
  30. 4. Test with cosmos-sdk and/or testnets repo.
  31. ## Status
  32. Proposed
  33. ## Consequences
  34. - Move keys to protobuf encoding, where backwards compatibility is needed, amino marshal and unmarshal functions will be used.
  35. ### Positive
  36. - Protocol Buffer encoding will not change going forward.
  37. - Removing amino overhead from keys will help with the KSM.
  38. - Have a large ecosystem of supported languages.
  39. ### Negative
  40. - Hardfork is required to integrate this into running chains.
  41. ### Neutral
  42. ## References
  43. > Are there any relevant PR comments, issues that led up to this, or articles referenced for why we made the given design choice? If so link them here!
  44. - {reference link}