AvianNetwork/Avian

ans: Implement enhanced serialization to reduce blockchain space used

Opened this issue · 0 comments

Right now ANS (Avian Name System) is serialized directly into ASCII hex, using valuable blockchain space. The less space used, the more scalable ANS is.

Right now to serialize ANS17f00000 will look like:

414E533137663030303030

Which is longer then the actual ID.

It is proposed to use a custom format to serialize different types of ANS IDs (which will introduce slight overhead but reduce space used).

To serialize ANS17f00000 in the new format:

17F00000

There is no need to encode the prefix since we know it will be ANS data and therefore we only need the type hex and IPv4 in hex.

Old format for ANS0RXBurnXXXXXXXXXXXXXXXXXXXXXXWUo9FV:

414E533052584275726E5858585858585858585858585858585858585858585857556F394656

New format for ANS0RXBurnXXXXXXXXXXXXXXXXXXXXXXWUo9FV:

03cf05325e90d5211def86b856c9569e5480820129092d35be8

For serializing, use the raw hex of the Base58 string.

It is important that encoding/decoding these ANS IDs are fast and safe.