var_int ambiguous serialization consequences



Summary:

A discussion about the consequences of using longer than necessary forms of var_int was initiated by Tamas Blummer in 2015. However, the topic being discussed was actually CompactSize and not VarInt as pointed out by Wladimir. The representation of CompactSizes is redundant, meaning the same number can be represented in up to four different byte sequences. In contrast, VARINTs were designed to not have any redundancy in their representation but are not currently used anywhere in the block chain. Tamas expressed interest in the possible implications of applying size limits to a block since transaction count is var_int but not part of the hashed header or merkle tree. Wladimir questioned the relevance of this concern since non-canonical CompactSizes are forbidden, which is flagged in serialize.h's ReadCompactSize function.


Updated on: 2023-06-09T16:19:26.095986+00:00