Two fields in the Note format have user ranges:
chunk_typefield of note chunks.
This means that certain ranges of values for these fields have been reserved for internal use by Note consumers. Why? Well, it's likely that note consumers may wish to modify notes internally for easier processing. The two fields currently defined mean:
- Note consumers MAY internally annotate notes with extra chunks.
- Note consumers MAY internally rewrite bytecode with custom operations.
Having specific ranges of values to do this means note consumers can be sure that future additions to Infinity will not break their existing code. They are protected because:
- Outside of note consumers, notes MUST NOT contain user-ranged fields with these values.
- Note consumers SHOULD reject notes they load containing user-ranged fields with these values as INVALID.
To understand which values are in user ranges you need to understand LEB128 encoding. All fields with user ranges are encoded as unsigned LEB128. If the bit below the most significant bit of the last byte of the encoded uleb128 value is set (
x1xxxxxx) then the value is in a user range. If that bit is clear (
x0xxxxxx)then the value is not in a user range and may be used by future additions to Infinity.
In C-like pseudo-code, if the uleb128 value is in an array of bytes:
in_user_range = ((value[N - 1] & 0x40) != 0)
The first 16384 values
|First value||Last value||First value||Last value|
|128||8191||80 01||ff 3f||SYSTEM|
|8192||16383||80 40||ff 7f||USER|
If your consumer needs more than 8256 internal values then calculate more ranges until you have enough.