feat(spec-spec, tests): Implement eip-8246 and testing scenario#2842
feat(spec-spec, tests): Implement eip-8246 and testing scenario#2842LouisTsai-Csie wants to merge 6 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## eips/amsterdam/eip-8246 #2842 +/- ##
========================================================
Coverage 90.01% 90.01%
========================================================
Files 539 539
Lines 32618 32623 +5
Branches 3030 3030
========================================================
+ Hits 29361 29366 +5
Misses 2699 2699
Partials 558 558
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
marioevz
left a comment
There was a problem hiding this comment.
Looks good overall. I think we need to take care of failing tests in ./tests/cancun/eip6780_selfdestruct before eventually merging into forks/amsterdam (if this gets included in a devnet).
| for address in tx_output.accounts_to_delete: | ||
| destroy_account(tx_state, address) | ||
| destroy_storage(tx_state, address) | ||
| modify_state(tx_state, address, preserve_account_balance) |
There was a problem hiding this comment.
If modify_state ends up calling destroy_account (zero-balance case), destroy_storage runs twice. Not a huge issue but something to be kept in mind
There was a problem hiding this comment.
I will keep it as is, but let me know if you have any suggestion!
There was a problem hiding this comment.
Why not just call destroy_storage in convert_to_balance_only_account like destroy_account currently does? That way, the diff in fork.py looks cleaner as well. Otherwise, this looks good to me.
There was a problem hiding this comment.
Great idea, i will add a new commit.
|
Checking the list of failing tests for the current fill in Amsterdam, they all look like expected failures because of the behavior change. I recommend we track these in the EIP tracking issue #2821, tackle them in separate PRs to merge to eips/amsterdam/eip-8246, and merge this PR as is after addressing the spec comments. |
f42defc to
36db57d
Compare
36db57d to
7bde788
Compare
|
@marioevz @gurukamath I've updated according to the comment. Now the PR contains spec & test for eip-8246 and refactor the failing legacy tests. Please take a look! I will stop adding new tests here, and wait for the PR to merge first. |
SamWilsn
left a comment
There was a problem hiding this comment.
A quick review of only the spec related changes.
| Invoked by ``modify_state`` (and the coinbase fee-credit path) to | ||
| clean up an account that has become empty (zero nonce, empty | ||
| code, and zero balance) so it does not appear in the post-state. |
There was a problem hiding this comment.
There's something funky about this. I've opened #2908.
| set_account(tx_state, address, None) | ||
|
|
||
|
|
||
| def convert_to_balance_only_account(account: Account) -> None: |
There was a problem hiding this comment.
This function name needs work. The word "convert" implies that something is changing about the kind of account, not about its contents. For example, you "convert a gas-powered car to electric", but you don't "convert a dirty car to clean" when you go through a car wash.
convert_to_balance_only_account implies that the account is changing "kinds" from a regular account to one that can only have a balance. As far as I am aware, there's nothing special about a balance only account. It's equivalent to an account that has received ether but has not sent any transactions.
Some ideas:
reset_account(pairs nicely withdestroy_account, but also might be confusing)make_account_deployable(this is more semantically meaningful I think, but a mouthful)clear_account_nonce_and_code_hash(says what it does, but not what it intends; might make future refactors more difficult)
There was a problem hiding this comment.
I applied Guru's feedback by moving destroy_storage into the convert_to_balance_only_account function, and your suggestion here. Now the refactored function becomes:
def convert_to_balance_only_account(
tx_state: TransactionState, address: Address
) -> None:
def clear_account(account: Account) -> None:
account.nonce = Uint(0)
account.code_hash = EMPTY_CODE_HASH
destroy_storage(tx_state, address)
modify_state(tx_state, address, clear_account)Since it now clears storage, nonce, and code hash, the name clear_account_nonce_and_code_hash no longer fits, while reset_accounts is a bit confusing?
I would support make_account_deployable compared to other two suggestions, i also come up with:
nullify_account_code_storage_noncestrip_to_balance_only
What do you think?
| set_account(tx_state, address, None) | ||
|
|
||
|
|
||
| def convert_to_balance_only_account(account: Account) -> None: |
There was a problem hiding this comment.
The pattern for other functions in this file is to create a function that operates on a frozen account, that defines an nested function to apply the transformation. Is there a reason this function breaks from that pattern?
If not, I'd suggest something like:
def convert_to_balance_only_account(tx_state: TransactionState, address: Address) -> None:
def clear_account(account: Account) -> None:
account.nonce = Uint(0)
account.code_hash = EMPTY_CODE_HASH
modify_state(tx_state, address, clear_account)
Carsons-Eels
left a comment
There was a problem hiding this comment.
I don't see anything wrong with the spec code that hasn't been commented on, will review the tests tomorrow. 🚀
| destroy_storage(tx_state, address) | ||
| modify_state(tx_state, address, convert_to_balance_only_account) |
There was a problem hiding this comment.
Might be worth a comment here noting that the explicit destroy_storage exists for EIP-7928 block-access-list completeness...
There was a problem hiding this comment.
I dont fully understand, could you expand more on this?
I applied Guru and Sam's feedback on the refactor, would this break anything?
🗒️ Description
Implement EIP-8246: https://forkcast.org/eips/8246
🔗 Related Issues or PRs
issue #2821
✅ Checklist
just statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_frommarker.Cute Animal Picture