The header of a Solana transaction contains, among other things:
- a compact-array of account addresses
- a compact-array of instructions
A compact array is defined as follows:
A compact-array is serialized as the array length, followed by each array item. The array length is a special multi-byte encoding called compact-u16.
Compact-u16s exist so that you can express 16-bit values but save space whenever a value can be expressed in 7 bits instead (explanation).
Why is the length of the static account and instruction lists expressed as a compact-u16 (65536 options) instead of a u8 (256 options) when we can't even fit 256 accounts or instructions into a transaction to begin with?