-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
Description
Current situation
In the current spec the structure of the EVMv1 header is not very generic. In particular we have:
- mandatory and optional sections (therefore also header entries)
- single and array sections; there is no generic rule which section is which
- mandatory sections of size zero (data) and non-empty optional sections (containers)
I believe, two historically separated decisions contributed to this:
- we decided that it is easier to define the data section as mandatory with the potential zero size; back then all sections were mandatory,
- later we added optional subcontainers section; because it is optional we don't allow it to be of size zero.
Also it is important to note that in the future we are going to mostly extend EOFv1 by adding optional sections.
Potential improvements
Data section is optional
- Forbid sections of size 0. For array sections, the count and all sizes must not be 0.
- Having 1, the data section must be optional.
Indicate single/array section kind
- Introduce a bit in the section id indicating a section of this kind is single. E.g. limit the ids range to 0–0x7f. The 0x80 bit indicates the section is single. Sections are ordered by
id & 0x7f. Example new ids in order:- type:
0x81 - code:
0x02 - containers:
0x03 - data:
0xff
- type:
Implementation considerations
The changes allow improving the header parser implementation. You can have a generic EOF version agnostic header parser. The parser should all sections as optional and build internal representation of the EOF sections. In the second phase of validation we can check if the mandatory sections required by specific EOF version are present. Similarly, we can check any other version-specific requirements (e.g. type section matching the number of code sections).