Move the create address computation to lib/evmone#1591
Merged
Conversation
compute_create_address() and compute_create2_address() are defined in
the testing host (test/state/host.{hpp,cpp}) although they are not
Host-specific, and the VM itself will need them once it computes the
create address instead of the Host (#1589).
Move them to the new TU lib/evmone/create_address.{hpp,cpp} in the
evmone namespace. The implementations are unchanged except the
keccak256() host-utils wrapper being replaced by the direct
ethash::keccak256() call. The functions are marked EVMC_EXPORT so the
testing code can still reach them across the libevmone shared-library
boundary (same as get_delegate_address()).
Also rename state_new_account_address_test.cpp (and its test suite) to
create_address_test.cpp to match.
Claude-Session: https://claude.ai/code/session_01R8uyb9z8VwgRrEKRanDPP8
There was a problem hiding this comment.
Pull request overview
This PR relocates compute_create_address() / compute_create2_address() from the testing host implementation into lib/evmone, making them available to the VM (and still usable by tests) as exported symbols in the evmone namespace.
Changes:
- Introduces
lib/evmone/create_address.{hpp,cpp}with the (unchanged) CREATE/CREATE2 address derivation logic, switching hashing toethash::keccak256(). - Removes the duplicated helpers from
test/state/host.{hpp,cpp}and updates host code to use the library implementation. - Updates and renames unit tests to include and call the new
evmone::compute_create_*APIs, and adjusts the unit test source list.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/unittests/create_address_test.cpp | Switches tests from test/state/host.hpp helpers to <evmone/create_address.hpp> and updates test suite naming. |
| test/unittests/CMakeLists.txt | Adds create_address_test.cpp to unit tests and removes the old state_new_account_address_test.cpp entry. |
| test/state/host.hpp | Drops local declarations of create-address helpers and includes the new library header. |
| test/state/host.cpp | Removes the local helper implementations; host now calls the library functions. |
| lib/evmone/create_address.hpp | Adds exported declarations for CREATE/CREATE2 address computation in namespace evmone. |
| lib/evmone/create_address.cpp | Adds the implementations using ethash::keccak256(). |
| lib/evmone/CMakeLists.txt | Registers the new TU (create_address.cpp/.hpp) in the evmone library build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1591 +/- ##
=======================================
Coverage 97.39% 97.39%
=======================================
Files 163 164 +1
Lines 14666 14666
Branches 3390 3390
=======================================
Hits 14284 14284
Misses 282 282
Partials 100 100
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
compute_create_address() and compute_create2_address() are defined in the testing host (test/state/host.{hpp,cpp}) although they are not Host-specific, and the VM itself will need them once it computes the create address instead of the Host (#1589).
Move them to the new TU lib/evmone/create_address.{hpp,cpp} in the evmone namespace. The implementations are unchanged except the keccak256() host-utils wrapper being replaced by the direct ethash::keccak256() call. The functions are marked EVMC_EXPORT so the testing code can still reach them across the libevmone shared-library boundary.