-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
host: Make EOF opaque for EXTCODE* instructions #587
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d39ad7d
host: Make EOF opaque for EXTCODE* instructions
axic 9aebfe3
Add test for new EXTCODE* behavior
pdobacz 1012ec1
Assume all existing EOF code is valid
pdobacz 5afe42b
Merge remote-tracking branch 'origin/master' into eof2-extcode
pdobacz b67c8bb
Switched to a branch of `tests`
pdobacz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patching
EXTCODEHASH
will be a headache for real implementations. The code hash is available directly in the account node. Now you need to additionally load the code to obtain a possibly different hash.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was always the case with this approach. Need to figure out if it is an EOF account or not (by loading the account).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keccak256("ef00")
should better be memoized or hard-codedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is generally fine for now although it conflicts with the TODO comment above.