Skip to content

Commit

Permalink
Disallow unreferenced subcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Jun 4, 2024
1 parent 0a3b1e0 commit 2414fd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/evmone/eof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ EOFValidationError validate_eof1(
return EOFValidationError::incompatible_container_kind;
}

// TODO Validate whether subcontainer was referenced by any instruction
if (!referenced_by_eofcreate && !referenced_by_returncontract)
return EOFValidationError::unreferenced_subcontainer;

Check warning on line 712 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L711-L712

Added lines #L711 - L712 were not covered by tests

// Enqueue subcontainers
for (size_t subcont_idx = 0; subcont_idx < subcontainer_count; ++subcont_idx)
Expand Down Expand Up @@ -988,6 +989,8 @@ std::string_view get_error_message(EOFValidationError err) noexcept
return "ambiguous_container_kind";
case EOFValidationError::incompatible_container_kind:
return "incompatible_container_kind";
case EOFValidationError::unreferenced_subcontainer:
return "unreferenced_subcontainer";

Check warning on line 993 in lib/evmone/eof.cpp

View check run for this annotation

Codecov / codecov/patch

lib/evmone/eof.cpp#L992-L993

Added lines #L992 - L993 were not covered by tests
case EOFValidationError::impossible:
return "impossible";
}
Expand Down
1 change: 1 addition & 0 deletions lib/evmone/eof.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ enum class EOFValidationError
eofcreate_with_truncated_container,
ambiguous_container_kind,
incompatible_container_kind,
unreferenced_subcontainer,

impossible,
};
Expand Down
2 changes: 2 additions & 0 deletions test/unittests/eof_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ std::string_view get_tests_error_message(EOFValidationError err) noexcept
return "EOF_AmbiguousContainerKind";
case EOFValidationError::incompatible_container_kind:
return "EOF_IncompatibleContainerKind";
case EOFValidationError::unreferenced_subcontainer:
return "EOF_UnreferencedSubcontainer";

Check warning on line 95 in test/unittests/eof_validation.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/eof_validation.cpp#L94-L95

Added lines #L94 - L95 were not covered by tests
case EOFValidationError::impossible:
return "impossible";
}
Expand Down

0 comments on commit 2414fd6

Please sign in to comment.