I was experimenting with @pipermerriam 's suggested schema and was mainly curious how the backing tree would look like.
This was my first interaction with SSZ, so sharing my takeaways here:
- Leaves are (padded to) 32 bytes
- The
List
type needs alimit
parameter. This means if we assume a contract could have at most 1024 chunks (768 rounded to the next power of 2), regardless of the actual number of chunks the corresponding subtree will have 1024 leaves. This can affect proof size if empty subtrees are not compressed - I used a
List
of bytes with alimit
of 32 for the chunk code (to accommodate the last chunk which can have a length < 32), this basically doubles the number of leaves. We should probably use fixed 32 byte vectors and encode the last chunk’s length somewhere (maybe metadata) - Also by default SSZ uses sha256. But this should be easily replaceable with keccak256