LNP-BP / client_side_validation

Standard implementation of client-side-validation APIs

Home Page:https://docs.rs/client_side_validation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strict encoding should provide explicit guarantees on collection sizes

dr-orlovsky opened this issue · comments

The main strict encoding rule was to restrict the size of any collection (string, vector of data, maps) to 2^16 elements (i.e. have a length encoded by 2 bytes). This happens implicitly, which leads to a non-obvious bugs missed in code reviews.

To address the issue it is proposed first to perform #97 and than, additionally to that, do the following:

  • Abandon confined_encoding for unordered hash collections (HashSet, HashMap);
  • Remove confined_encoding from all other collection types;
  • Introduce new types for collections, specifically ConfinedString, ConfinedVec, ConfinedSet, ConfinedMap, backed by inner types String, Vec, BTreeSet, BTreeMap) and require all consensus code to explicitly use them.