diff --git a/evmc b/evmc index 613889ba0b..7c0de9d32f 160000 --- a/evmc +++ b/evmc @@ -1 +1 @@ -Subproject commit 613889ba0b92abec2fbca861eb3958cb6af68ca4 +Subproject commit 7c0de9d32f43bc4078d698b66345f7fdecb504e3 diff --git a/lib/evmone/baseline_execution.cpp b/lib/evmone/baseline_execution.cpp index 4f9a4b5828..c625c15d0a 100644 --- a/lib/evmone/baseline_execution.cpp +++ b/lib/evmone/baseline_execution.cpp @@ -336,10 +336,13 @@ evmc_result execute(evmc_vm* c_vm, const evmc_host_interface* host, evmc_host_co auto vm = static_cast(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); } diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 34d164d3e3..dc1ebc2b15 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -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 $,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 $,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 $,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)