Skip to content

zkevm: add SELFDESTRUCT coverage#1678

Merged
jsign merged 12 commits into
mainfrom
jsign-zkevm-selfdestruct
Jun 6, 2025
Merged

zkevm: add SELFDESTRUCT coverage#1678
jsign merged 12 commits into
mainfrom
jsign-zkevm-selfdestruct

Conversation

@jsign

@jsign jsign commented May 29, 2025

Copy link
Copy Markdown
Collaborator

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
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
@jsign

jsign commented May 29, 2025

Copy link
Copy Markdown
Collaborator Author

@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
Copy Markdown
Member

On it 😄 👍

@jochem-brouwer jochem-brouwer left a comment

Copy link
Copy Markdown
Member

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 😄

Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
@jsign

jsign commented May 29, 2025

Copy link
Copy Markdown
Collaborator Author

@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
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
@jsign

jsign commented Jun 2, 2025

Copy link
Copy Markdown
Collaborator Author

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

jsign commented Jun 4, 2025

Copy link
Copy Markdown
Collaborator Author

Rebased.

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

@jochem-brouwer jochem-brouwer left a comment

Copy link
Copy Markdown
Member

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 😄 👍

Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Comment thread tests/zkevm/test_worst_stateful_opcodes.py Outdated
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
@jsign jsign requested a review from jochem-brouwer June 4, 2025 18:43
Comment thread tests/zkevm/test_worst_stateful_opcodes.py
@jsign

jsign commented Jun 4, 2025

Copy link
Copy Markdown
Collaborator Author

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

@jsign

jsign commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
Member

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

@jochem-brouwer jochem-brouwer left a comment

Copy link
Copy Markdown
Member

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
kclowes pushed a commit to kclowes/execution-spec-tests that referenced this pull request Oct 20, 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