History to understand what Koinos Types is

To understand Koinos Types it is good to see what situations have happened in the past and how problems have been fixed. I'm going to give a concrete example: The steem hardfork 21 where the Steem Proposal System (SPS) was introduced.

The SPS was created by @blocktrades and his team. With its introduction many more variables were included in the steem code. And specifically 3 of them were important for wallets: create_proposal_operation, update_proposal_votes_operation, and remove_proposal_operation.

What was the next step? Update the wallet libraries: Steem-js (javascript), dSteem (alternative to steemjs also in javascript), and Beem (python). If I'm not wrong, these are the 3 main libraries from which most websites, apps, wallets, chrome extensions, etc. are derived.

Updating these libraries is not a very complicated job, but it does require someone to take the time to go to these libraries and update them so that those who use them can take advantage of the new features. In fact, I specifically worked on this update for dSteem. If, for example, nobody had updated dSteem then the websites that relied on this library would have to think of different alternatives, such as migrating their code to Steem-js, which would probably require more work.

How complicated is it to update these libraries? Let's look at the SPS example again. While in the blockchain code the remove proposal operation was written like this

struct remove_proposal_operation : public base_operation
{
   account_name_type proposal_owner;

   /// IDs of proposals to be removed. Nonexisting IDs are ignored.
   flat_set_ex<int64_t> proposal_ids;

   extensions_type extensions;

   void validate() const;

   void get_required_active_authorities(flat_set<account_name_type>& a)const { a.insert(proposal_owner); }
};

in dSteem you had to write it like this:

export interface RemoveProposalOperation extends Operation {
    0: 'remove_proposal'
    1: {
        proposal_owner: string
        proposal_ids: number[]
        extensions: any[]
    }
}

If you notice they have many similarities, you just have to write them differently. It is important to note that here we are talking about the "definition" of remove proposal, that is, the variables we expect this operation will contain and how to serialize it, how to transform it into 0's and 1's so that what is signed from dSteem can be interpreted correctly by the blockchain.

Now the question...

What does Koinos Types intend? Make this job automatic. That when a new variable (structure, operation, etc.) is written in the base code, then automatically the corresponding code is generated for other languages ​​(Go, Python, Typescript) and that all of them serialize said variable in the same way. So no one has to constantly update the libraries for each language one by one. Again, just talking about the types, the definitions of the variables.

Do this exercise: Go to https://github.com/koinos/koinos-types-golang and see who made the commits in this repository. You will realize that it's a bot. That's the idea! The original code is written at https://github.com/koinos/koinos-types in C ++ and there are some routines that interpret this original code and automatically generate the code for other languages. This way of "interpreting" the original code is the thing that needs to be done well for every programming language. Right now it is only made for Golang and in the future they hope to include Typescript (and with typescript you have javascript included, two birds with one stone).

And an important final point to mention. In the example that I mentioned above, these libraries updated just 3 operations because they were the only ones that were relevant for wallet purposes, but in reality the SPS added more types to the blockchain that were used internally. Well, Koinos Types also includes all these internal variable types because precisely what is wanted in Koinos is to use microservices, that is, different parts of the blockchain written independently and perhaps in different programming languages, and that they can understand each other.

To see more details check the post of @andrarchy talking about Koinos Types and the interview to @gerbino.

H2
H3
H4
3 columns
2 columns
1 column
1 Comment
Ecency