14
14
#include < cassert>
15
15
#include < limits>
16
16
#include < numeric>
17
- #include < ostream>
18
17
#include < queue>
19
18
#include < unordered_set>
20
19
#include < vector>
@@ -23,8 +22,6 @@ namespace evmone
23
22
{
24
23
namespace
25
24
{
26
- constexpr uint8_t MAGIC_BYTES[] = {0xef , 0x00 };
27
- constexpr bytes_view MAGIC{MAGIC_BYTES, std::size (MAGIC_BYTES)};
28
25
constexpr uint8_t TERMINATOR = 0x00 ;
29
26
constexpr uint8_t TYPE_SECTION = 0x01 ;
30
27
constexpr uint8_t CODE_SECTION = 0x02 ;
@@ -50,7 +47,7 @@ size_t eof_header_size(const EOFSectionHeaders& headers) noexcept
50
47
constexpr auto non_code_section_header_size = 3 ; // (SECTION_ID + SIZE) per each section
51
48
constexpr auto section_size_size = 2 ;
52
49
53
- auto header_size = std::size (MAGIC ) + 1 + // 1 version byte
50
+ auto header_size = std::size (EOF_MAGIC ) + 1 + // 1 version byte
54
51
non_code_section_count * non_code_section_header_size +
55
52
sizeof (CODE_SECTION) + 2 + code_section_count * section_size_size +
56
53
sizeof (TERMINATOR);
@@ -93,7 +90,7 @@ std::variant<EOFSectionHeaders, EOFValidationError> validate_section_headers(byt
93
90
uint16_t section_num = 0 ;
94
91
EOFSectionHeaders section_headers{};
95
92
const auto container_end = container.end ();
96
- auto it = container.begin () + std::size (MAGIC ) + 1 ; // MAGIC + VERSION
93
+ auto it = container.begin () + std::size (EOF_MAGIC ) + 1 ; // MAGIC + VERSION
97
94
uint8_t expected_section_id = TYPE_SECTION;
98
95
while (it != container_end && state != State::terminated)
99
96
{
@@ -719,7 +716,7 @@ size_t EOF1Header::data_size_position() const noexcept
719
716
{
720
717
const auto num_code_sections = code_sizes.size ();
721
718
const auto num_container_sections = container_sizes.size ();
722
- return std::size (MAGIC ) + 1 + // magic + version
719
+ return std::size (EOF_MAGIC ) + 1 + // magic + version
723
720
3 + // type section kind + size
724
721
3 + 2 * num_code_sections + // code sections kind + count + sizes
725
722
// container sections kind + count + sizes
@@ -729,7 +726,7 @@ size_t EOF1Header::data_size_position() const noexcept
729
726
730
727
bool is_eof_container (bytes_view container) noexcept
731
728
{
732
- return container.starts_with (MAGIC );
729
+ return container.starts_with (EOF_MAGIC );
733
730
}
734
731
735
732
std::variant<EOF1Header, EOFValidationError> validate_header (
@@ -806,7 +803,7 @@ std::variant<EOF1Header, EOFValidationError> validate_header(
806
803
EOF1Header read_valid_eof1_header (bytes_view container)
807
804
{
808
805
EOFSectionHeaders section_headers;
809
- auto it = container.begin () + std::size (MAGIC ) + 1 ; // MAGIC + VERSION
806
+ auto it = container.begin () + std::size (EOF_MAGIC ) + 1 ; // MAGIC + VERSION
810
807
while (*it != TERMINATOR)
811
808
{
812
809
const auto section_id = *it++;
0 commit comments