Skip to content

test(zkevm): add coverage for CALLDATACOPY, CODECOPY, RETURNDATACOPY and MCOPY #1800

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented Jun 24, 2025

🗒️ Description

This PR adds benchmark coverage for CALLDATACOPY, CODECOPY, RETURNDATACOPY and MCOPY.

Cycles:

tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-1MiB-transaction]-1        125092548
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-1MiB-transaction]-1       126159065
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-100KiB-transaction]-1      134499078
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-100KiB-transaction]-1     137217303
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-1MiB-call]-1        140491870
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-10KiB-transaction]-1       150131958
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-1MiB-transaction]-1 158964435
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-1MiB-transaction]-1        159926649
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-10KiB-transaction]-1      175553835
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-1MiB-call]-1       250364532
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_True-1MiB]-1  255470228
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-1MiB-call]-1       256252199
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-100KiB-call]-1      274666727
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-100KiB-transaction]-1       279043357
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-100KiB-call]-1     285408182
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-1KiB-transaction]-1        288423058
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_True-100KiB]-1        289997797
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-max code size]-1   295109348
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-0.75x max code size]-1     297259608
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-10KiB-call]-1       298718943
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-10KiB-call]-1      298940375
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-0.50x max code size]-1     301460118
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-10KiB-transaction]-1        303028063
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_True-10KiB]-1 303997756
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-0.25x max code size]-1     313942765
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-1MiB-call]-1      392174602
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-1KiB-call]-1       429529132
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_False-1MiB]-1 434913651
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-1KiB-call]-1        438984582
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-100KiB-call]-1    449030956
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-max code size]-1  468315261
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-100KiB-transaction]-1      470248705
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-0.75x max code size]-1    473178700
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-1KiB-transaction]-1       477810980
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-10KiB-call]-1      480022603
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-10KiB-call]-1     480925492
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-0.50x max code size]-1    482887507
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-10KiB-transaction]-1       487246263
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_False-100KiB]-1       495723508
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-0.25x max code size]-1    512144671
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_False-10KiB]-1        518387302
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-1MiB]-1       541304303
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-100KiB-call]-1     546194847
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-100KiB]-1     577292038
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-10KiB]-1      587724282
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-1KiB]-1       684513499
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-1KiB-transaction]-1 696306261
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-1MiB]-1      696523057
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_True-1KiB]-1  697928414
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-1KiB-call]-1      728230622
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_False-1KiB]-1 738653325
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-1KiB-call]-1       738950780
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-100KiB]-1    743235890
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-10KiB]-1     767542764
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-100 bytes-transaction]-1   816395697
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-1KiB-transaction]-1        846794662
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-100 bytes-call]-1  903973263
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-1KiB]-1      956820255
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-100 bytes-call]-1   969365781
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-100 bytes]-1  994860035
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-100 bytes-transaction]-1    1050445283
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_True-100 bytes]-1     1072272349
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-0 bytes]-1    1167061696
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-0 bytes]-1 1173093333
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-10 bytes-transaction]-1    1202497630
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-100 bytes-transaction]-1  1229823144
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_False-100 bytes]-1    1265486319
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_True-10 bytes]-1   1288792240
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-10 bytes-call]-1   1301693268
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-0 bytes-call]-1    1314321612
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_True-0 bytes-transaction]-1     1318847738
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-100 bytes-call]-1 1321986838
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-10 bytes-transaction]-1     1370503008
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-100 bytes-call]-1  1373916005
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-100 bytes]-1 1379633636
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-100 bytes-transaction]-1   1421850691
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_True-10 bytes]-1      1431026421
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_True-0 bytes]-1       1432705603
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_True-10 bytes-call]-1    1437577686
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-10 bytes-transaction]-1   1557798027
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-0 bytes]-1   1582416203
tests/zkevm/test_worst_memory.py::test_worst_codecopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-0 bytes]-1        1585211480
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-10 bytes-call]-1  1590621573
tests/zkevm/test_worst_memory.py::test_worst_mcopy[fork_Cancun-blockchain_test_from_state_test-fixed_src_dst_False-10 bytes]-1  1599488993
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_False-10 bytes]-1     1604711952
tests/zkevm/test_worst_memory.py::test_worst_returndatacopy[fork_Cancun-blockchain_test_from_state_test-fixed_dst_False-0 bytes]-1      1640962382
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-0 bytes-call]-1   1646835084
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_False-fixed_src_dst_False-0 bytes-transaction]-1    1665837321
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-10 bytes-call]-1   1668885796
tests/zkevm/test_worst_memory.py::test_worst_calldatacopy[fork_Cancun-blockchain_test_from_state_test-non_zero_data_True-fixed_src_dst_False-10 bytes-transaction]-1    1684366602

🔗 Related Issues

#1690

✅ Checklist

  • All: Set appropriate labels for the changes.

jsign added 5 commits June 24, 2025 12:46
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
@jsign jsign added feature:zkevm type:feat type: Feature type:test Type: Add/refactor fw unit tests; no fw or el client test case changes and removed type:feat type: Feature labels Jun 24, 2025
@jsign jsign changed the title Jsign mem opcodes benchmark: memory opcodes Jun 24, 2025
@jsign jsign changed the title benchmark: memory opcodes benchmark: add coverage for CALLDATACOPY, CODECOPY, RETURNDATACOPY and MCOPY Jun 24, 2025
@jsign jsign changed the title benchmark: add coverage for CALLDATACOPY, CODECOPY, RETURNDATACOPY and MCOPY test(zkevm): add coverage for CALLDATACOPY, CODECOPY, RETURNDATACOPY and MCOPY Jun 24, 2025
jsign added 2 commits June 24, 2025 17:34
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
@jsign jsign marked this pull request as ready for review June 24, 2025 22:01
Signed-off-by: Ignacio Hagopian <[email protected]>
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.

These tests are fun, left some background notes and some suggestions because I think some tests are doing things they are not intended to.

In general, Op.MOD(Op.GAS, 7) works only iff the difference of gas between each of these MOD calls is not a multiple of 7. Otherwist the dst is not dynamic and will be static. But not sure how to test/verify this, have to think about this. A solution for the attack loop could be to use both Op.MOD(Op.GAS, 7) and Op.MOD(Op.GAS, 11) (but this has the problem it still has a shorter cycle problem than we intend)

Signed-off-by: Ignacio Hagopian <[email protected]>
jsign and others added 8 commits June 26, 2025 12:48
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
@jsign jsign force-pushed the jsign-mem-opcodes branch from 73b2e18 to 815d7d9 Compare June 26, 2025 22:21
@jsign
Copy link
Collaborator Author

jsign commented Jun 26, 2025

@jochem-brouwer, I think we're ready for another review with many of the suggestions!

To simplify your life re-reviewing, I added a comment on all new changes and resolved the old ones, so hopefully that helps.

These opcodes are extremely tricky to get perfectly right (if we even know what that means 😄) , but I think we're in a good-ish place.

@jsign jsign requested a review from jochem-brouwer June 26, 2025 22:45
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.

I went through all comments and (quickly) went over the file again - LGTM! Exciting tests juggling around with memory bytes 🤩

jsign added 2 commits June 26, 2025 21:41
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
@jsign
Copy link
Collaborator Author

jsign commented Jun 27, 2025

@marioevz, I think due to new branch protection rules I can't merge PRs anymore even with approvals (I'm fine with it!) -- so please take a look if all looks fine here for potential merging 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:benchmark feature:zkevm type:test Type: Add/refactor fw unit tests; no fw or el client test case changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants