Skip to content

Commit

Permalink
fix(tests): EIP-7702: Spec update #9248
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Jan 24, 2025
1 parent 4a77afb commit 8c8e90c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 32 deletions.
1 change: 0 additions & 1 deletion tests/prague/eip7702_set_code_tx/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Spec:
PER_AUTH_BASE_COST = 12_500
PER_EMPTY_ACCOUNT_COST = 25_000
DELEGATION_DESIGNATION = Bytes("ef0100")
DELEGATION_DESIGNATION_READING = Bytes("ef01")
RESET_DELEGATION_ADDRESS = Address(0)

MAX_AUTH_CHAIN_ID = 2**256 - 1
Expand Down
64 changes: 39 additions & 25 deletions tests/prague/eip7702_set_code_tx/test_set_code_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,11 +1075,15 @@ def test_ext_code_on_set_code(
raise ValueError(f"Unsupported set code type: {set_code_type}")

callee_storage = Storage()
callee_storage[slot_ext_code_size_result] = len(Spec.DELEGATION_DESIGNATION_READING)
callee_storage[slot_ext_code_hash_result] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
callee_storage[slot_ext_code_copy_result] = Spec.DELEGATION_DESIGNATION_READING.ljust(
32, b"\x00"
)[:32]
callee_storage[slot_ext_code_size_result] = len(
Spec.delegation_designation(set_code_to_address)
)
callee_storage[slot_ext_code_hash_result] = Spec.delegation_designation(
set_code_to_address
).keccak256()
callee_storage[slot_ext_code_copy_result] = Hash(
Spec.delegation_designation(set_code_to_address), right_padding=True
)
callee_storage[slot_ext_balance_result] = balance

tx = Transaction(
Expand Down Expand Up @@ -1144,11 +1148,15 @@ def test_ext_code_on_self_set_code(
set_code_address = pre.deploy_contract(set_code)

set_code_storage = Storage()
set_code_storage[slot_ext_code_size_result] = len(Spec.DELEGATION_DESIGNATION_READING)
set_code_storage[slot_ext_code_hash_result] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
set_code_storage[slot_ext_code_copy_result] = Spec.DELEGATION_DESIGNATION_READING.ljust(
32, b"\x00"
)[:32]
set_code_storage[slot_ext_code_size_result] = len(
Spec.delegation_designation(set_code_address)
)
set_code_storage[slot_ext_code_hash_result] = Spec.delegation_designation(
set_code_address
).keccak256()
set_code_storage[slot_ext_code_copy_result] = Hash(
Spec.delegation_designation(set_code_address), right_padding=True
)
set_code_storage[slot_ext_balance_result] = balance

tx = Transaction(
Expand Down Expand Up @@ -1364,11 +1372,13 @@ def test_ext_code_on_self_delegating_set_code(
callee_address = pre.deploy_contract(callee_code)
callee_storage = Storage()

callee_storage[slot_ext_code_size_result] = len(Spec.DELEGATION_DESIGNATION_READING)
callee_storage[slot_ext_code_hash_result] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
callee_storage[slot_ext_code_copy_result] = Spec.DELEGATION_DESIGNATION_READING.ljust(
32, b"\x00"
)[:32]
callee_storage[slot_ext_code_size_result] = len(Spec.delegation_designation(auth_signer))
callee_storage[slot_ext_code_hash_result] = Spec.delegation_designation(
auth_signer
).keccak256()
callee_storage[slot_ext_code_copy_result] = Hash(
Spec.delegation_designation(auth_signer), right_padding=True
)
callee_storage[slot_ext_balance_result] = balance

tx = Transaction(
Expand Down Expand Up @@ -1443,18 +1453,22 @@ def test_ext_code_on_chain_delegating_set_code(
callee_address = pre.deploy_contract(callee_code)
callee_storage = Storage()

callee_storage[slot_ext_code_size_result_1] = len(Spec.DELEGATION_DESIGNATION_READING)
callee_storage[slot_ext_code_hash_result_1] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
callee_storage[slot_ext_code_copy_result_1] = Spec.DELEGATION_DESIGNATION_READING.ljust(
32, b"\x00"
)[:32]
callee_storage[slot_ext_code_size_result_1] = len(Spec.delegation_designation(auth_signer_2))
callee_storage[slot_ext_code_hash_result_1] = Spec.delegation_designation(
auth_signer_2
).keccak256()
callee_storage[slot_ext_code_copy_result_1] = Hash(
Spec.delegation_designation(auth_signer_2), right_padding=True
)
callee_storage[slot_ext_balance_result_1] = auth_signer_1_balance

callee_storage[slot_ext_code_size_result_2] = len(Spec.DELEGATION_DESIGNATION_READING)
callee_storage[slot_ext_code_hash_result_2] = Spec.DELEGATION_DESIGNATION_READING.keccak256()
callee_storage[slot_ext_code_copy_result_2] = Spec.DELEGATION_DESIGNATION_READING.ljust(
32, b"\x00"
)[:32]
callee_storage[slot_ext_code_size_result_2] = len(Spec.delegation_designation(auth_signer_1))
callee_storage[slot_ext_code_hash_result_2] = Spec.delegation_designation(
auth_signer_1
).keccak256()
callee_storage[slot_ext_code_copy_result_2] = Hash(
Spec.delegation_designation(auth_signer_1), right_padding=True
)
callee_storage[slot_ext_balance_result_2] = auth_signer_2_balance

tx = Transaction(
Expand Down
10 changes: 4 additions & 6 deletions tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,20 @@ def test_pointer_measurements(blockchain_test: BlockchainTestFiller, pre: Alloc)
+ Op.SSTORE(storage_normal.store_next(100, "balance"), Op.BALANCE(pointer))
+ Op.STOP,
)

delegation_designation = Spec.delegation_designation(pointer_code)
contract_measurements_pointer = pre.deploy_contract(
code=Op.EXTCODECOPY(pointer, 0, 0, 32)
+ Op.SSTORE(
storage_pointer.store_next(
Spec.DELEGATION_DESIGNATION_READING.keccak256(), "extcodehash"
),
storage_pointer.store_next(delegation_designation.keccak256(), "extcodehash"),
Op.EXTCODEHASH(pointer),
)
+ Op.SSTORE(
storage_pointer.store_next(len(Spec.DELEGATION_DESIGNATION_READING), "extcodesize"),
storage_pointer.store_next(len(delegation_designation), "extcodesize"),
Op.EXTCODESIZE(pointer),
)
+ Op.SSTORE(
storage_pointer.store_next(
Hash(Spec.DELEGATION_DESIGNATION_READING, right_padding=True), "extcodecopy"
Hash(delegation_designation, right_padding=True), "extcodecopy"
),
Op.MLOAD(0),
)
Expand Down

0 comments on commit 8c8e90c

Please sign in to comment.