diff --git a/test/state/host.cpp b/test/state/host.cpp index 82c36657f6..cb7588cad6 100644 --- a/test/state/host.cpp +++ b/test/state/host.cpp @@ -82,30 +82,30 @@ namespace /// For EXTCODE* instructions if the target is an EOF account, then only return EF00. /// While we only do this if the caller is legacy, it is not a problem doing this /// unconditionally, because EOF contracts dot no have EXTCODE* instructions. -bytes_view extcode(bytes_view code, evmc_revision rev) noexcept +bytes_view extcode(bytes_view code) noexcept { - return (rev >= EVMC_PRAGUE && is_eof_container(code)) ? code.substr(0, 2) : code; + return is_eof_container(code) ? code.substr(0, 2) : code; } } // namespace size_t Host::get_code_size(const address& addr) const noexcept { const auto* const acc = m_state.find(addr); - return (acc != nullptr) ? extcode(acc->code, m_rev).size() : 0; + return (acc != nullptr) ? extcode(acc->code).size() : 0; } bytes32 Host::get_code_hash(const address& addr) const noexcept { // TODO: Cache code hash. It will be needed also to compute the MPT hash. const auto* const acc = m_state.find(addr); - return (acc != nullptr && !acc->is_empty()) ? keccak256(extcode(acc->code, m_rev)) : bytes32{}; + return (acc != nullptr && !acc->is_empty()) ? keccak256(extcode(acc->code)) : bytes32{}; } size_t Host::copy_code(const address& addr, size_t code_offset, uint8_t* buffer_data, size_t buffer_size) const noexcept { const auto* const acc = m_state.find(addr); - const auto code = (acc != nullptr) ? extcode(acc->code, m_rev) : bytes_view{}; + const auto code = (acc != nullptr) ? extcode(acc->code) : bytes_view{}; const auto code_slice = code.substr(std::min(code_offset, code.size())); const auto num_bytes = std::min(buffer_size, code_slice.size()); std::copy_n(code_slice.begin(), num_bytes, buffer_data); diff --git a/test/statetest/statetest_loader.cpp b/test/statetest/statetest_loader.cpp index 90be1dec50..adcfa4ff4f 100644 --- a/test/statetest/statetest_loader.cpp +++ b/test/statetest/statetest_loader.cpp @@ -442,15 +442,11 @@ void validate_state(const state::State& state, evmc_revision rev) // https://github.com/ethereum/tests/issues/1331 if (is_eof_container(acc.code)) { - if (rev >= EVMC_PRAGUE) + if (const auto result = validate_eof(rev, acc.code); + result != EOFValidationError::success) { - if (const auto result = validate_eof(rev, acc.code); - result != EOFValidationError::success) - { - throw std::invalid_argument( - "EOF container at " + hex0x(addr) + - " is invalid: " + std::string(get_error_message(result))); - } + throw std::invalid_argument("EOF container at " + hex0x(addr) + " is invalid: " + + std::string(get_error_message(result))); } } diff --git a/test/unittests/state_transition_extcode_test.cpp b/test/unittests/state_transition_extcode_test.cpp index feadf6fc66..f97dbced4c 100644 --- a/test/unittests/state_transition_extcode_test.cpp +++ b/test/unittests/state_transition_extcode_test.cpp @@ -9,20 +9,6 @@ using namespace evmc::literals; using namespace evmone::test; constexpr auto target = 0xfffffffffffffffffffffffffffffffffffffffe_address; -constexpr auto ones = 0x1111111111111111111111111111111111111111111111111111111111111111_bytes32; - -TEST_F(state_transition, legacy_extcodesize_eof_cancun) -{ - pre.insert(target, {.code = eof_bytecode("FE")}); - - rev = EVMC_CANCUN; - tx.to = To; - pre.insert(*tx.to, { - .code = bytecode(push(target) + sstore(1, OP_EXTCODESIZE)), - }); - expect.post[*tx.to].storage[0x01_bytes32] = 0x14_bytes32; - expect.post[target].exists = true; -} TEST_F(state_transition, legacy_extcodesize_eof) { @@ -37,19 +23,6 @@ TEST_F(state_transition, legacy_extcodesize_eof) expect.post[target].exists = true; } -TEST_F(state_transition, legacy_extcodehash_eof_cancun) -{ - pre.insert(target, {.code = eof_bytecode("FE")}); - - rev = EVMC_CANCUN; - tx.to = To; - pre.insert(*tx.to, { - .code = bytecode(push(target) + sstore(1, OP_EXTCODEHASH)), - }); - expect.post[*tx.to].storage[0x01_bytes32] = keccak256(bytecode(eof_bytecode("FE"))); - expect.post[target].exists = true; -} - TEST_F(state_transition, legacy_extcodehash_eof) { pre.insert(target, {.code = eof_bytecode("FE")}); @@ -63,23 +36,10 @@ TEST_F(state_transition, legacy_extcodehash_eof) expect.post[target].exists = true; } -TEST_F(state_transition, legacy_extcodecopy_eof_cancun) -{ - pre.insert(target, {.code = eof_bytecode("FE")}); - - rev = EVMC_CANCUN; - tx.to = To; - pre.insert(*tx.to, { - .code = bytecode(mstore(0, ones) + push(20) + push0() + push0() + - push(target) + OP_EXTCODECOPY + sstore(1, mload(0))), - }); - expect.post[*tx.to].storage[0x01_bytes32] = - 0xef000101000402000100010400000000800000fe111111111111111111111111_bytes32; - expect.post[target].exists = true; -} - TEST_F(state_transition, legacy_extcodecopy_eof) { + constexpr auto ones = + 0x1111111111111111111111111111111111111111111111111111111111111111_bytes32; pre.insert(target, {.code = eof_bytecode("FE")}); rev = EVMC_PRAGUE;