This EIP introduces a new Simple Serialize (SSZ) type to make List[T, N] with large capacities N more efficient in cases where the list is much shorter than the capacity.
Specification
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 and RFC 8174.
ProgressiveByteList container
ProgressiveByteList[CAPACITY, COMMON_RATIO] is defined as a byte list container type that consists of multiple byte vectors of different size. The size of the first vector is 32 bytes (a single chunk) while the size of further vectors is growing according to a geometric sequence with the specified common ratio (a power of 2), with a potential exception for the last vector which might be smaller (but still a power of 2) according to the total number of chunks required for realizing the specified capacity. As shown on the figure below, in the Merkle hashing scheme the smaller vectors are close to the root, allowing less hashing and shorter proofs if the actual list is significantly smaller than the maximum capacity or only the first part of the list needs to be proven.
In this example a list with a capacity limit of 3000 is realized using 5 vectors. Note that the last vector is smaller than what would follow in the geometric sequence because the total size of 32+128+512+2048+512 is already enough to store 3000 bytes.
Rationale
ByteList definitions sometimes are defined with capacities that exceed their typical practical usage, to avoid limiting design space. For example, the Transaction type has a maximum capacity of 1 GB MAX_BYTES_PER_TRANSACTION, despite actual transactions often being below 1 KB. This difference results in at least 20 extra hashes for common cases, to offer a design space that is not practically viable.
With this EIP, common cases can be hashed more efficiently while not restricting the design space, and while also retaining stable generalized Merkle indices for each individual chunk of the ByteList.
Backwards Compatibility
The new SSZ type does not interfere with any existing types.