-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
host: Make EOF opaque for EXTCODE* instructions (#587)
* host: Make EOF opaque for EXTCODE* instructions * Add test for new EXTCODE* behavior * Assume all existing EOF code is valid * Switched to a branch of `tests` --------- Co-authored-by: pdobacz <5735525+pdobacz@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// evmone: Fast Ethereum Virtual Machine implementation | ||
// Copyright 2023 The evmone Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "../utils/bytecode.hpp" | ||
#include "state_transition.hpp" | ||
|
||
using namespace evmc::literals; | ||
using namespace evmone::test; | ||
|
||
constexpr auto target = 0xfffffffffffffffffffffffffffffffffffffffe_address; | ||
|
||
TEST_F(state_transition, legacy_extcodesize_eof) | ||
{ | ||
pre.insert(target, {.code = eof_bytecode("FE")}); | ||
|
||
rev = EVMC_PRAGUE; | ||
tx.to = To; | ||
pre.insert(*tx.to, { | ||
.code = bytecode(push(target) + sstore(1, OP_EXTCODESIZE)), | ||
}); | ||
expect.post[*tx.to].storage[0x01_bytes32] = 0x02_bytes32; | ||
expect.post[target].exists = true; | ||
} | ||
|
||
TEST_F(state_transition, legacy_extcodehash_eof) | ||
{ | ||
pre.insert(target, {.code = eof_bytecode("FE")}); | ||
|
||
rev = EVMC_PRAGUE; | ||
tx.to = To; | ||
pre.insert(*tx.to, { | ||
.code = bytecode(push(target) + sstore(1, OP_EXTCODEHASH)), | ||
}); | ||
expect.post[*tx.to].storage[0x01_bytes32] = keccak256(bytecode("EF00")); | ||
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; | ||
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] = | ||
0xef00000000000000000000000000000000000000111111111111111111111111_bytes32; | ||
expect.post[target].exists = true; | ||
} |