-
Notifications
You must be signed in to change notification settings - Fork 293
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
state: Refactor compute_new_account_address()
#575
Conversation
a9f62c4
to
01a1671
Compare
Refactor `compute_new_account_address()` to match Yellow Paper 𝐀𝐃𝐃𝐑. This makes it a separate utility independent of `evmc_message`.
01a1671
to
bd35f8f
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #575 +/- ##
==========================================
+ Coverage 97.06% 97.13% +0.07%
==========================================
Files 71 72 +1
Lines 6545 6571 +26
==========================================
+ Hits 6353 6383 +30
+ Misses 192 188 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/// @param salt The salt for CREATE2. If null, CREATE address is computed. YP: ζ. | ||
/// @param init_code The contract creation init code. Value only affects CREATE2. YP: 𝐢. | ||
/// @return The computed address for CREATE or CREATE2 scheme. | ||
address compute_new_account_address(const address& sender, uint64_t sender_nonce, |
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.
Why not have two overloads:
address compute_new_account_address(const evmc_message& msg, uint64_t sender_nonce) noexcept;
address compute_new_account_address(const address& sender, bytes32& salt, bytes_view init_code) noexcept;
The sender_nonce
is irrelevant for create2 and this separation makes it clear which values are used in which.
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.
Mostly so that a user don't need to know which overload to select. Now it only needs to provide arguments (sometimes redundantly) and will get the right answer. Non-functional change from what we had.
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.
I think it still makes sense to separate and I'd aim for that later, but it is debatable.
Refactor
compute_new_account_address()
to match 𝐀𝐃𝐃𝐑 from Yellow Paper.This makes it a separate utility independent of
evmc_message
.