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

add EIP 6780: only SELFDESTRUCT in same transaction #819

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

gballet
Copy link
Member

@gballet gballet commented Jul 28, 2023

This is my first shot at implementing EIP 6780 in EELS. I'm no Python expert, so this will probably require an extra cautious look-over.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2023

Codecov Report

Attention: 2214 lines in your changes are missing coverage. Please review.

Comparison is base (bf47143) 69.96% compared to head (85cc3e5) 69.64%.
Report is 33 commits behind head on forks/cancun.

Files Patch % Lines
src/ethereum/cancun/fork.py 0.00% 259 Missing ⚠️
src/ethereum/cancun/vm/instructions/system.py 0.00% 207 Missing ⚠️
src/ethereum/cancun/vm/instructions/environment.py 0.00% 167 Missing ⚠️
src/ethereum/cancun/vm/instructions/__init__.py 0.00% 164 Missing ⚠️
src/ethereum/cancun/state.py 0.00% 149 Missing ⚠️
src/ethereum/cancun/vm/gas.py 0.00% 117 Missing ⚠️
src/ethereum/cancun/vm/interpreter.py 0.00% 112 Missing ⚠️
src/ethereum/cancun/vm/instructions/arithmetic.py 0.00% 109 Missing ⚠️
src/ethereum/cancun/vm/instructions/stack.py 0.00% 98 Missing ⚠️
src/ethereum/cancun/vm/__init__.py 0.00% 79 Missing ⚠️
... and 37 more
Additional details and impacted files
@@               Coverage Diff                @@
##           forks/cancun     #819      +/-   ##
================================================
- Coverage         69.96%   69.64%   -0.32%     
================================================
  Files               610      611       +1     
  Lines             34295    34898     +603     
================================================
+ Hits              23993    24306     +313     
- Misses            10302    10592     +290     
Flag Coverage Δ
unittests 69.64% <12.97%> (-0.32%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 529 to 534
# mark beneficiary as touched
if account_exists_and_is_empty(evm.env.state, beneficiary):
evm.touched_accounts.add(beneficiary)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the beneficiary account be touched (in the EIP-158 sense) in both cases? (poking @petertdavies since he knows more about that topic.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, this should be outside the if block.

evm.touched_accounts.add(beneficiary)

# HALT the execution
evm.running = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I think this'll also lead to an issue. If evm.running is not set to False, then you need to increment the program counter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Execution of the stack frame should end and return regardless of whether the contract was marked for deletion. So this should also be outside the if block.

@@ -522,15 +523,18 @@ def selfdestruct(evm: Evm) -> None:
# beneficiary).
set_account_balance(evm.env.state, originator, U256(0))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Balance transfer also has to only happen under certain conditions i.e. if the contract was created in the same transaction or if the beneficiary and originator are different.

@gurukamath
Copy link
Collaborator

@SamWilsn @petertdavies Have updated the implementation

@gurukamath gurukamath force-pushed the selfdestruct-removal branch from d84a075 to 972fa5c Compare February 8, 2024 16:53
# register account for deletion only if it was created
# in the same transaction
if originator in evm.env.state.created_accounts:
evm.accounts_to_delete.add(originator)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need to zero the balance to support selfdestruct(this) in the same transaction?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Updated

@SamWilsn SamWilsn merged commit f35dd3d into ethereum:forks/cancun Feb 15, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants