|
10 | 10 | from ethereum_test_tools import (
|
11 | 11 | Account,
|
12 | 12 | Alloc,
|
| 13 | + AuthorizationTuple, |
13 | 14 | Block,
|
14 | 15 | BlockchainTestFiller,
|
| 16 | + Bytecode, |
15 | 17 | CodeGasMeasure,
|
| 18 | + Environment, |
16 | 19 | StateTestFiller,
|
17 | 20 | Transaction,
|
18 | 21 | )
|
19 | 22 | from ethereum_test_tools.vm.opcode import Opcodes as Op
|
20 | 23 |
|
| 24 | +from ...prague.eip7702_set_code_tx.spec import Spec as Spec7702 |
21 | 25 | from .spec import Spec, ref_spec_7939
|
22 | 26 |
|
23 | 27 | REFERENCE_SPEC_GIT_PATH = ref_spec_7939.git_path
|
@@ -313,6 +317,55 @@ def test_clz_jump_operation(
|
313 | 317 | state_test(pre=pre, post=post, tx=tx)
|
314 | 318 |
|
315 | 319 |
|
| 320 | +auth_account_start_balance = 0 |
| 321 | + |
| 322 | + |
| 323 | +@pytest.mark.valid_from("Osaka") |
| 324 | +def test_clz_from_set_code( |
| 325 | + state_test: StateTestFiller, |
| 326 | + pre: Alloc, |
| 327 | +): |
| 328 | + """Test the address opcode in a set-code transaction.""" |
| 329 | + storage = Storage() |
| 330 | + auth_signer = pre.fund_eoa(auth_account_start_balance) |
| 331 | + |
| 332 | + set_code = Bytecode() |
| 333 | + for bits in [0, 1, 128, 255]: |
| 334 | + expected_clz = 255 - bits |
| 335 | + set_code += Op.SSTORE(storage.store_next(expected_clz), Op.CLZ(1 << bits)) |
| 336 | + set_code += Op.STOP |
| 337 | + |
| 338 | + set_code_to_address = pre.deploy_contract(set_code) |
| 339 | + |
| 340 | + tx = Transaction( |
| 341 | + gas_limit=200_000, |
| 342 | + to=auth_signer, |
| 343 | + value=0, |
| 344 | + authorization_list=[ |
| 345 | + AuthorizationTuple( |
| 346 | + address=set_code_to_address, |
| 347 | + nonce=0, |
| 348 | + signer=auth_signer, |
| 349 | + ), |
| 350 | + ], |
| 351 | + sender=pre.fund_eoa(), |
| 352 | + ) |
| 353 | + |
| 354 | + state_test( |
| 355 | + env=Environment(), |
| 356 | + pre=pre, |
| 357 | + tx=tx, |
| 358 | + post={ |
| 359 | + set_code_to_address: Account(storage={}), |
| 360 | + auth_signer: Account( |
| 361 | + nonce=1, |
| 362 | + code=Spec7702.delegation_designation(set_code_to_address), |
| 363 | + storage=storage, |
| 364 | + ), |
| 365 | + }, |
| 366 | + ) |
| 367 | + |
| 368 | + |
316 | 369 | @pytest.mark.valid_from("Osaka")
|
317 | 370 | @pytest.mark.parametrize("bits", [0, 64, 255])
|
318 | 371 | @pytest.mark.parametrize("opcode", [Op.CODECOPY, Op.EXTCODECOPY])
|
|
0 commit comments