Eth2 developers designed SSZ to improve the storage and retrieval of data in the blockchain
Serialize:encode data structures as sequences of bytesDeserialize:decode sequences of bytes to reconstruct a given data structureMerkleize:reduce data structure to merkle-rootValidate:make proofs and multiproofs for elements in the data structureSimple
Vector[uint16, 4], Vector[uint32, 2], Vector[uint64, 1], uint64 are all fixed-length and 8 bytes.Container with a Vector[uint32, 8] and uint64 field has the same merkleization structure as a List[uint64, 4].List can be packed together better, and have a smaller key depth, thus more efficiency in multi-proofs and avoiding the cost of unbalanced tree shapes.merkle-root.merkle-root, but also features that:
Efficient to traverse
O(log(N)) lookup speed for deeply nested structures. And offsets even enable O(1) random access in lists of dynamic-length elements.O(log(N)) operation where N is the abstract data size (SSZ does not force a uniform data-structure),and where log(N) matches the length of the generalized index.