Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validate_eof flag for EOF creation txs #960

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion evmc
7 changes: 5 additions & 2 deletions lib/evmone/baseline_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,13 @@ evmc_result execute(evmc_vm* c_vm, const evmc_host_interface* host, evmc_host_co
auto vm = static_cast<VM*>(c_vm);
const bytes_view container{code, code_size};

if (vm->validate_eof && rev >= EVMC_PRAGUE && is_eof_container(container))
// Since EOF validation recurses into subcontainers, it only makes sense to do for top level
// message calls. The condition for `msg->kind` inside differentiates between creation tx code
// (initcode) and already deployed code (runtime).
if (vm->validate_eof && rev >= EVMC_PRAGUE && is_eof_container(container) && msg->depth == 0)
{
const auto container_kind =
(msg->depth == 0 ? ContainerKind::initcode : ContainerKind::runtime);
(msg->kind == EVMC_EOFCREATE ? ContainerKind::initcode : ContainerKind::runtime);
if (validate_eof(rev, container_kind, container) != EOFValidationError::success)
return evmc_make_result(EVMC_CONTRACT_VALIDATION_FAILURE, 0, 0, nullptr, 0);
}
Expand Down
17 changes: 16 additions & 1 deletion test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,22 @@ DUP1,4
set_tests_properties(
${PREFIX}/validate_eof PROPERTIES PASS_REGULAR_EXPRESSION
"contract validation failure")


add_test(NAME ${PREFIX}/validate_eof_success COMMAND evmc::tool --vm $<TARGET_FILE:evmone>,validate_eof run --rev 13 EF00010100040200010001040000000080000000)
set_tests_properties(
${PREFIX}/validate_eof_success PROPERTIES PASS_REGULAR_EXPRESSION
"Result: success")

add_test(NAME ${PREFIX}/validate_eof_create COMMAND evmc::tool --vm $<TARGET_FILE:evmone>,validate_eof run --rev 13 --create EF00010100040200010001040000000080000000)
set_tests_properties(
${PREFIX}/validate_eof_create PROPERTIES PASS_REGULAR_EXPRESSION
"contract validation failure")

add_test(NAME ${PREFIX}/validate_eof_create_success COMMAND evmc::tool --vm $<TARGET_FILE:evmone>,validate_eof run --rev 13 --create EF00010100040200010004030001001404000000008000025F5FEE00EF00010100040200010001040000000080000000)
set_tests_properties(
${PREFIX}/validate_eof_create_success PROPERTIES PASS_REGULAR_EXPRESSION
"Result: success")

endif()

add_subdirectory(eofparse)
Expand Down