diff --git a/test/state/host.cpp b/test/state/host.cpp index cefc796511..e1fd29d17f 100644 --- a/test/state/host.cpp +++ b/test/state/host.cpp @@ -113,9 +113,18 @@ size_t Host::get_code_size(const address& addr) const noexcept bytes32 Host::get_code_hash(const address& addr) const noexcept { - // TODO: Cache code hash. It will be needed also to compute the MPT hash. + /// The value returned by EXTCODEHASH of an address with EOF code. + /// See EIP-3540: https://eips.ethereum.org/EIPS/eip-3540#changes-to-execution-semantics. + static constexpr auto EOF_CODE_HASH_SENTINEL = + 0x9dbf3648db8210552e9c4f75c6a1c3057c0ca432043bd648be15fe7be05646f5_bytes32; + const auto* const acc = m_state.find(addr); - return (acc != nullptr && !acc->is_empty()) ? keccak256(extcode(acc->code)) : bytes32{}; + if (acc == nullptr || acc->is_empty()) + return bytes32{}; + if (is_eof_container(acc->code)) + return EOF_CODE_HASH_SENTINEL; + // TODO: Cache code hash. It will be needed also to compute the MPT hash. + return keccak256(acc->code); } size_t Host::copy_code(const address& addr, size_t code_offset, uint8_t* buffer_data,