Skip to content

Commit

Permalink
Fix validate_eof flag for EOF creation txs (#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdobacz authored Jul 29, 2024
1 parent 4542e8c commit 9696fcf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
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

0 comments on commit 9696fcf

Please sign in to comment.