Skip to content
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

Implement EIP-7610 (non-empty storage create collision) and upgrade execution-tests #816

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,7 @@ jobs:
steps:
- build
- download_execution_tests:
# v13.2 + fix
rev: develop
commit: 52ddcbcef0d58ec7de6b768b564725391a30b934
rev: v13.3
- run:
name: "State tests"
working_directory: ~/build
Expand All @@ -432,7 +430,7 @@ jobs:
working_directory: ~/build
command: >
bin/evmone-blockchaintest
--gtest_filter='-*StateTests/stEOF/*.*'
--gtest_filter='-*StateTests/stEOF/*.*:*StateTests/stEIP2537.*'
~/tests/EIPTests/BlockchainTests/
- download_execution_tests:
repo: ipsilon/tests
Expand Down Expand Up @@ -463,7 +461,7 @@ jobs:
command: sudo apt-get -q update && sudo apt-get -qy install libgmp-dev
- build
- download_execution_tests:
rev: v12.4
rev: v13.3
- run:
name: "State tests"
working_directory: ~/build
Expand Down
21 changes: 11 additions & 10 deletions test/state/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,19 @@ bytes_view extcode(bytes_view code) noexcept
}

/// Check if an existing account is the "create collision"
/// as defined in the [EIP-684](https://eips.ethereum.org/EIPS/eip-684).
/// as defined in the [EIP-7610](https://eips.ethereum.org/EIPS/eip-7610).
[[nodiscard]] bool is_create_collision(const Account& acc) noexcept
{
return acc.nonce != 0 || !acc.code.empty();
if (acc.nonce != 0 || !acc.code.empty())
return true;

// acc.storage may have entries from access list, even if account storage is empty.
// Check for non-zero current values.
if (std::ranges::any_of(
acc.storage, [](auto& e) noexcept { return !is_zero(e.second.current); }))
return true;

return false;
}
} // namespace

Expand Down Expand Up @@ -268,14 +277,6 @@ evmc::Result Host::create(const evmc_message& msg) noexcept

new_acc->just_created = true;

// Clear the new account storage, but keep the access status (from tx access list).
// This is only needed for tests and cannot happen in real networks.
for (auto& [k, v] : new_acc->storage) [[unlikely]]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the storage is empty now we don't have to do anything with it. This is really nice because this eliminates the only case for storage traversal in EVM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could replace with assertion, but not very important

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not easy check because of the access list... so I'll pass.

{
m_state.journal_storage_change(msg.recipient, k, v);
v = StorageValue{.access_status = v.access_status};
}

auto& sender_acc = m_state.get(msg.sender); // TODO: Duplicated account lookup.
const auto value = intx::be::load<intx::uint256>(msg.value);
assert(sender_acc.balance >= value && "EVM must guarantee balance");
Expand Down