Skip to content

zkevm: add SELFDESTRUCT coverage #1678

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

Merged
merged 12 commits into from
Jun 6, 2025
Merged

zkevm: add SELFDESTRUCT coverage #1678

merged 12 commits into from
Jun 6, 2025

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented May 29, 2025

This PR adds coverage for SELFDESTRUCT covering two main scenarios:

  • SELFDESTRUCTing contracts that already exist.
  • SELFDESTRUCTing contracts that were created in the same tx (both deployed and in initcode).
    since both cases are relevant for the current way SELFDESTRUCT works.

Each case covers both value-bearing and non-value-bearing destructions.

Cycles:

tests/zkevm/test_worst_stateful_opcodes.py::test_worst_selfdestruct_initcode[fork_Cancun-blockchain_test_from_state_test-value_bearing_True]-1  31822708
tests/zkevm/test_worst_stateful_opcodes.py::test_worst_selfdestruct_initcode[fork_Cancun-blockchain_test_from_state_test-value_bearing_False]-1 32032830
tests/zkevm/test_worst_stateful_opcodes.py::test_worst_selfdestruct_created[fork_Cancun-blockchain_test_from_state_test-value_bearing_True]-1   35854736
tests/zkevm/test_worst_stateful_opcodes.py::test_worst_selfdestruct_created[fork_Cancun-blockchain_test_from_state_test-value_bearing_False]-1  36062553
tests/zkevm/test_worst_stateful_opcodes.py::test_worst_selfdestruct_existing[fork_Cancun-blockchain_test-value_bearing_False]-2 251368019
tests/zkevm/test_worst_stateful_opcodes.py::test_worst_selfdestruct_existing[fork_Cancun-blockchain_test-value_bearing_True]-2  358821448

Note that *created scenarios are very costly to execute since they involve deploying the transactions we want to SELFDESTRUCT. This means that each attempt requires a lot of gas, and most of it isn't coming from SELFDESTRUCT. While this was known before doing it, I decided, for completeness, to cover the scenario anyway.

Targets #1657

@jsign jsign added scope:tests Scope: Changes EL client test cases in `./tests` type:feat type: Feature feature:zkevm labels May 29, 2025
@jsign
Copy link
Collaborator Author

jsign commented May 29, 2025

@jochem-brouwer, do you want to do a review of this draft PR (which should be ready) before I open up for other reviewers?

@jochem-brouwer
Copy link
Member

On it 😄 👍

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

This was a fun one 😄 👍

I am sure I missed some things though. I would also suggest to run these tests inside some EVM with traces on, because upon reading these tests I think these might not behave as we might expect 😄 👍

I think when looking over this again, I might find some other optimizations for the gas here 😄

@jsign
Copy link
Collaborator Author

jsign commented May 29, 2025

@jochem-brouwer, thanks a lot for your fantastic review. I'm now opening for formal review!

@jsign jsign marked this pull request as ready for review May 29, 2025 20:30
@jsign jsign requested review from chfast and marioevz May 29, 2025 20:30
@jsign
Copy link
Collaborator Author

jsign commented Jun 2, 2025

Is this blocked by #1649? I don't see it as a dependency, but I'm fine waiting for it. (Rebased now that #1649 is merged)
In any case, it is ready for a formal review.

jsign and others added 11 commits June 4, 2025 08:41
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
@jsign jsign force-pushed the jsign-zkevm-selfdestruct branch from b152eca to 364aad1 Compare June 4, 2025 11:45
@jsign
Copy link
Collaborator Author

jsign commented Jun 4, 2025

Rebased.

@jsign jsign requested review from jochem-brouwer and chfast June 4, 2025 12:00
Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

Some style comments and I believe one of the tests is doing unnecessary extra behavior 😄 👍

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
@jsign jsign requested a review from jochem-brouwer June 4, 2025 18:43
@jsign
Copy link
Collaborator Author

jsign commented Jun 4, 2025

Done changes after the last review, ready for a final round @jochem-brouwer!

@jsign
Copy link
Collaborator Author

jsign commented Jun 5, 2025

Still not sure why it says it's waiting for changes when I re-asked for review to get the final check. 🤷

@jochem-brouwer
Copy link
Member

Sorry, I forgot to approve, which I wanted to do after my last comment. Will do now!

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

LGTM, great work, beautiful tests!

@jsign jsign merged commit d6252aa into main Jun 6, 2025
26 checks passed
@jsign jsign deleted the jsign-zkevm-selfdestruct branch June 6, 2025 00:21
codeofcarson pushed a commit to codeofcarson/execution-spec-tests that referenced this pull request Jul 1, 2025
* zkevm: add selfdestruct existing contracts bench

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* zkevm: add selfdestruct of contracts deployed in tx

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* improvements

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* Update tests/zkevm/test_worst_stateful_opcodes.py

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>

* improvements

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* adjust gas prices

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* Update tests/zkevm/test_worst_stateful_opcodes.py

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>

* improvements

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* improvement

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* fix bug

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* selfdestruct in initcode

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

* feedback

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>

---------

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:zkevm scope:tests Scope: Changes EL client test cases in `./tests` type:feat type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants