Page properties | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||
|
Background
...
- Iroha 2 peer receive messages from it clients primarily serialized in SCALE codec, but also some endpoint receive JSON messages
- Iroha 2 has some client libraries in development (Java/Kotlin, JavaScript, Python)
- Scale codec do not need the name of the properties, but JSON do need
Problem
Iroha 2 has a lot of model-objects that peer can receive as input from blockchain clients and can respond with. Currently Iroha 2 in the active development process and set of this model-objects changes very often. These changes must be reflected in the Iroha 2 client's library and it requires a lot of affords to keep client's implementation up to date.
Solution
We can generate a scheme which would introspect details of object-models. These scheme allow to achieve The scheme brings such benefits:
- Code generation of models and deser serialization/deserialization tests
- Type safe checks in clients code (if programming language support such checkstype safety)
Requirements for scheme
Basically we can consider three type of items 3 types of items
1. Scalars
- int: in SCALE can be encoded as fixed-width integer and compact integer. Compact integer itself has 3 modes. So generally we have 4 ways to serde integer (1 fixed-width + 3 modes of compact integers)
- bool: no tricks here
2. Built-in containers
- Option / Result / Vec / typle / array : basically we are interested in only inner values of the container
3. Custom containers
- Structures
- Enums: similar to Structures but also every variant of enum has a discriminator that used in Scale. By default based on 0, but can be overriden by attributes
- Scalars (int, bool)
- Built-in containers (Option, Result, Vec, tuples)
- Custom containers (custom struct and enums)
Alternatives
Present at least two alternatives to the solution you suggested
...