From 5ef3b4ac752f7d32e0d8f9c7a10cd6c2557a50bb Mon Sep 17 00:00:00 2001 From: LouisTsai Date: Tue, 17 Jun 2025 14:39:06 +0200 Subject: [PATCH 1/2] feat(tests): add worst-case block test for 7702 set code --- tests/zkevm/test_worst_blocks.py | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/zkevm/test_worst_blocks.py b/tests/zkevm/test_worst_blocks.py index 7a2944e2bb9..85ba8ea52f4 100644 --- a/tests/zkevm/test_worst_blocks.py +++ b/tests/zkevm/test_worst_blocks.py @@ -12,6 +12,7 @@ Account, Address, Alloc, + AuthorizationTuple, Block, BlockchainTestFiller, Environment, @@ -156,3 +157,43 @@ def test_block_full_of_ether_transfers( blocks=[Block(txs=txs)], exclude_full_post_state_in_output=True, ) + + +@pytest.mark.valid_from("Prague") +def test_block_full_of_7702_set_code( + blockchain_test: BlockchainTestFiller, + pre: Alloc, + env: Environment, + iteration_count: int, +): + """ + Test worst-case block scenario with 7702 set code. + + This test is designed to test the worst-case block scenario with 7702 set code. + """ + attack_gas_limit = env.gas_limit + sender = pre.fund_eoa() + + txs = [] + for i in range(iteration_count): + txs.append( + Transaction( + gas_limit=attack_gas_limit, + to=sender, + authorization_list=[ + AuthorizationTuple( + address=Address(0x0), + nonce=i + 1, + signer=sender, + ), + ], + sender=sender, + ) + ) + + blockchain_test( + genesis_environment=env, + pre=pre, + blocks=[Block(txs=txs)], + exclude_full_post_state_in_output=True, + ) From 63c75b7b79b438f28d7b5ab22679dd03bcae1720 Mon Sep 17 00:00:00 2001 From: LouisTsai Date: Wed, 18 Jun 2025 11:45:15 +0200 Subject: [PATCH 2/2] fix(tests):add empty post state and update env --- tests/zkevm/test_worst_blocks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/zkevm/test_worst_blocks.py b/tests/zkevm/test_worst_blocks.py index 85ba8ea52f4..74da445e11e 100644 --- a/tests/zkevm/test_worst_blocks.py +++ b/tests/zkevm/test_worst_blocks.py @@ -163,7 +163,6 @@ def test_block_full_of_ether_transfers( def test_block_full_of_7702_set_code( blockchain_test: BlockchainTestFiller, pre: Alloc, - env: Environment, iteration_count: int, ): """ @@ -171,6 +170,7 @@ def test_block_full_of_7702_set_code( This test is designed to test the worst-case block scenario with 7702 set code. """ + env = Environment() attack_gas_limit = env.gas_limit sender = pre.fund_eoa() @@ -194,6 +194,7 @@ def test_block_full_of_7702_set_code( blockchain_test( genesis_environment=env, pre=pre, + post={}, blocks=[Block(txs=txs)], exclude_full_post_state_in_output=True, )