Skip to content

Commit d65e6fb

Browse files
authored
fix(tests): EIP-7702: Remove delegation behavior of EXTCODE* (#984)
* fix(tests): EIP-7702: Update behavior on ext*code * fix(tests): EIP-7702: Update behavior on ext*code gas tests (use CALL) * docs: Changelog
1 parent c1eeddb commit d65e6fb

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Test fixtures for use by clients are available for each release on the [Github r
1717
- ✨ Update [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110), [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002), [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251), [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685), and [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) tests for Devnet-4 ([#832](https://github.com/ethereum/execution-spec-tests/pull/832))
1818
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) many delegations test ([#923](https://github.com/ethereum/execution-spec-tests/pull/923))
1919
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) set code of non-empty-storage account test ([#948](https://github.com/ethereum/execution-spec-tests/pull/948))
20+
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Remove delegation behavior of EXTCODE* ([#984](https://github.com/ethereum/execution-spec-tests/pull/984))
2021

2122
### 🛠️ Framework
2223

tests/prague/eip7702_set_code_tx/spec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Spec:
3030
MAGIC = 0x05
3131
PER_AUTH_BASE_COST = 12_500
3232
PER_EMPTY_ACCOUNT_COST = 25_000
33-
DELEGATION_DESIGNATION = bytes.fromhex("ef0100")
33+
DELEGATION_DESIGNATION = Bytes("ef0100")
34+
DELEGATION_DESIGNATION_READING = Bytes("ef01")
3435
RESET_DELEGATION_ADDRESS = Address(0)
3536

3637
@staticmethod

tests/prague/eip7702_set_code_tx/test_gas.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def test_account_warming(
796796
Test warming of the authority and authorized accounts for set-code transactions.
797797
"""
798798
# Overhead cost is the single push operation required for the address to check.
799-
OVERHEAD_COST = 3
799+
OVERHEAD_COST = 3 * len(Op.CALL.kwargs) # type: ignore
800800

801801
COLD_ACCOUNT_COST = 2600
802802
WARM_ACCOUNT_COST = 100
@@ -891,7 +891,7 @@ def test_account_warming(
891891
callee_code: Bytecode = sum( # type: ignore
892892
(
893893
CodeGasMeasure(
894-
code=Op.EXTCODESIZE(check_address),
894+
code=Op.CALL(gas=0, address=check_address),
895895
overhead_cost=OVERHEAD_COST,
896896
extra_stack_items=1,
897897
sstore_key=callee_storage.store_next(access_cost),
@@ -994,10 +994,10 @@ def test_self_set_code_cost(
994994

995995
slot_call_cost = 1
996996

997-
OVERHEAD_COST = 3
997+
OVERHEAD_COST = 3 * len(Op.CALL.kwargs) # type: ignore
998998

999999
callee_code = CodeGasMeasure(
1000-
code=Op.EXTCODESIZE(address=auth_signer),
1000+
code=Op.CALL(gas=0, address=auth_signer),
10011001
overhead_cost=OVERHEAD_COST,
10021002
extra_stack_items=1,
10031003
sstore_key=slot_call_cost,

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
add_kzg_version,
4141
call_return_code,
4242
compute_create_address,
43-
keccak256,
4443
)
4544
from ethereum_test_tools.eof.v1 import Container, Section
4645

@@ -1106,11 +1105,11 @@ def test_ext_code_on_set_code(
11061105
raise ValueError(f"Unsupported set code type: {set_code_type}")
11071106

11081107
callee_storage = Storage()
1109-
callee_storage[slot_ext_code_size_result] = len(set_code)
1110-
callee_storage[slot_ext_code_hash_result] = (
1111-
set_code.keccak256() if set_code_type != AddressType.EMPTY_ACCOUNT else 0
1112-
)
1113-
callee_storage[slot_ext_code_copy_result] = bytes(set_code).ljust(32, b"\x00")[:32]
1108+
callee_storage[slot_ext_code_size_result] = len(Spec.DELEGATION_DESIGNATION_READING)
1109+
callee_storage[slot_ext_code_hash_result] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
1110+
callee_storage[slot_ext_code_copy_result] = Spec.DELEGATION_DESIGNATION_READING.ljust(
1111+
32, b"\x00"
1112+
)[:32]
11141113
callee_storage[slot_ext_balance_result] = balance
11151114

11161115
tx = Transaction(
@@ -1177,9 +1176,11 @@ def test_ext_code_on_self_set_code(
11771176
set_code_address = pre.deploy_contract(set_code)
11781177

11791178
set_code_storage = Storage()
1180-
set_code_storage[slot_ext_code_size_result] = len(set_code)
1181-
set_code_storage[slot_ext_code_hash_result] = set_code.keccak256()
1182-
set_code_storage[slot_ext_code_copy_result] = bytes(set_code).ljust(32, b"\x00")[:32]
1179+
set_code_storage[slot_ext_code_size_result] = len(Spec.DELEGATION_DESIGNATION_READING)
1180+
set_code_storage[slot_ext_code_hash_result] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
1181+
set_code_storage[slot_ext_code_copy_result] = Spec.DELEGATION_DESIGNATION_READING.ljust(
1182+
32, b"\x00"
1183+
)[:32]
11831184
set_code_storage[slot_ext_balance_result] = balance
11841185

11851186
tx = Transaction(
@@ -1397,10 +1398,11 @@ def test_ext_code_on_self_delegating_set_code(
13971398
callee_address = pre.deploy_contract(callee_code)
13981399
callee_storage = Storage()
13991400

1400-
set_code = b"\xef\x01\x00" + bytes(auth_signer)
1401-
callee_storage[slot_ext_code_size_result] = len(set_code)
1402-
callee_storage[slot_ext_code_hash_result] = keccak256(set_code)
1403-
callee_storage[slot_ext_code_copy_result] = bytes(set_code).ljust(32, b"\x00")[:32]
1401+
callee_storage[slot_ext_code_size_result] = len(Spec.DELEGATION_DESIGNATION_READING)
1402+
callee_storage[slot_ext_code_hash_result] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
1403+
callee_storage[slot_ext_code_copy_result] = Spec.DELEGATION_DESIGNATION_READING.ljust(
1404+
32, b"\x00"
1405+
)[:32]
14041406
callee_storage[slot_ext_balance_result] = balance
14051407

14061408
tx = Transaction(
@@ -1475,17 +1477,18 @@ def test_ext_code_on_chain_delegating_set_code(
14751477
callee_address = pre.deploy_contract(callee_code)
14761478
callee_storage = Storage()
14771479

1478-
set_code_1 = Spec.delegation_designation(auth_signer_2)
1479-
set_code_2 = Spec.delegation_designation(auth_signer_1)
1480-
1481-
callee_storage[slot_ext_code_size_result_1] = len(set_code_2)
1482-
callee_storage[slot_ext_code_hash_result_1] = set_code_2.keccak256()
1483-
callee_storage[slot_ext_code_copy_result_1] = bytes(set_code_2).ljust(32, b"\x00")[:32]
1480+
callee_storage[slot_ext_code_size_result_1] = len(Spec.DELEGATION_DESIGNATION_READING)
1481+
callee_storage[slot_ext_code_hash_result_1] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
1482+
callee_storage[slot_ext_code_copy_result_1] = Spec.DELEGATION_DESIGNATION_READING.ljust(
1483+
32, b"\x00"
1484+
)[:32]
14841485
callee_storage[slot_ext_balance_result_1] = auth_signer_1_balance
14851486

1486-
callee_storage[slot_ext_code_size_result_2] = len(set_code_1)
1487-
callee_storage[slot_ext_code_hash_result_2] = set_code_1.keccak256()
1488-
callee_storage[slot_ext_code_copy_result_2] = bytes(set_code_1).ljust(32, b"\x00")[:32]
1487+
callee_storage[slot_ext_code_size_result_2] = len(Spec.DELEGATION_DESIGNATION_READING)
1488+
callee_storage[slot_ext_code_hash_result_2] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
1489+
callee_storage[slot_ext_code_copy_result_2] = Spec.DELEGATION_DESIGNATION_READING.ljust(
1490+
32, b"\x00"
1491+
)[:32]
14891492
callee_storage[slot_ext_balance_result_2] = auth_signer_2_balance
14901493

14911494
tx = Transaction(

0 commit comments

Comments
 (0)