hyperledger-iroha / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
438 stars 280 forks source link

Use SCALE's `Compact` #4988

Open 0x009922 opened 2 months ago

0x009922 commented 2 months ago

What is Compact

A "compact" or general integer encoding is sufficient for encoding large integers (up to 2**536) and is more efficient at encoding most values than the fixed-width version. (Though for single-byte values, the fixed-width integer is never worse.)

- https://docs.substrate.io/reference/scale-codec/

Here is an example of how it is already used for Status structure:

https://github.com/hyperledger/iroha/blob/b9f28442bf4225f1647901629a4baed3b122cc3c/telemetry/src/metrics.rs#L50-L71

Pros

Cons

TODO

Investigate the cost via profiling & benchmarks.