near / borsh

Binary Object Representation Serializer for Hashing
https://borsh.io/
487 stars 41 forks source link

Rewrite `BorshSchema` to use const functions #79

Open MaksymZavershynskyi opened 4 years ago

MaksymZavershynskyi commented 4 years ago

Currently BorshSchema has static but not constant methods. These methods when compiled to Wasm occupy significant space. Also, they create a significant execution overhead when self-described borsh deserialization/serialization is called using https://docs.rs/borsh/0.6.2/borsh/schema_helpers/index.html

To fix it we need to implement const version of BorshSchema:: schema_container(). Unfortunately, it means two things:

We currently intend to serialize BorshSchemaContainer using either borsh or JSON. Therefore we can have two versions of schema_container():

This will improve performance in the following way: