|
| 1 | +""" |
| 2 | +abstract: Tests [EIP-7685: General purpose execution layer requests](https://eips.ethereum.org/EIPS/eip-7685) |
| 3 | + Cross testing for withdrawal and deposit request for [EIP-7685: General purpose execution layer requests](https://eips.ethereum.org/EIPS/eip-7685). |
| 4 | +
|
| 5 | +""" # noqa: E501 |
| 6 | + |
| 7 | +import pytest |
| 8 | + |
| 9 | +from ethereum_test_tools import ( |
| 10 | + Account, |
| 11 | + Alloc, |
| 12 | + Block, |
| 13 | + BlockchainTestFiller, |
| 14 | + Header, |
| 15 | + Transaction, |
| 16 | +) |
| 17 | +from ethereum_test_types import Requests |
| 18 | +from ethereum_test_types.types import EOA |
| 19 | +from tests.prague.eip7685_general_purpose_el_requests.test_multi_type_requests import ( |
| 20 | + single_withdrawal_from_contract, |
| 21 | + single_withdrawal_from_eoa, |
| 22 | +) |
| 23 | + |
| 24 | +from ..eip7002_el_triggerable_withdrawals.helpers import ( |
| 25 | + WithdrawalRequestContract, |
| 26 | +) |
| 27 | +from ..eip7002_el_triggerable_withdrawals.spec import Spec as Spec_EIP7002 |
| 28 | +from .spec import ref_spec_7685 |
| 29 | + |
| 30 | +REFERENCE_SPEC_GIT_PATH: str = ref_spec_7685.git_path |
| 31 | +REFERENCE_SPEC_VERSION: str = ref_spec_7685.version |
| 32 | + |
| 33 | + |
| 34 | +@pytest.mark.parametrize( |
| 35 | + "requests", |
| 36 | + [ |
| 37 | + # create 18 withdrawal contract requests (usually 16 is max, but modified_code dequeues 18) |
| 38 | + [ |
| 39 | + single_withdrawal_from_contract(i) |
| 40 | + for i in range( |
| 41 | + 0, |
| 42 | + 18, |
| 43 | + ) |
| 44 | + ], |
| 45 | + # create 18 withdrawal requests |
| 46 | + [ |
| 47 | + single_withdrawal_from_eoa(i) |
| 48 | + for i in range( |
| 49 | + 0, |
| 50 | + 18, |
| 51 | + ) |
| 52 | + ], |
| 53 | + ], |
| 54 | +) |
| 55 | +def test_extra_withdrawals( |
| 56 | + blockchain_test: BlockchainTestFiller, |
| 57 | + pre: Alloc, |
| 58 | + requests: WithdrawalRequestContract, |
| 59 | +): |
| 60 | + """Test how clients were to behave when more than 16 withdrawals would be allowed per block.""" |
| 61 | + modified_code: bytes = b"3373fffffffffffffffffffffffffffffffffffffffe1460cb5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f457600182026001905f5b5f82111560685781019083028483029004916001019190604d565b909390049250505036603814608857366101f457346101f4575f5260205ff35b34106101f457600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060121160df575060125b5f5b8181146101835782810160030260040181604c02815460601b8152601401816001015481526020019060020154807fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252906010019060401c908160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160e1565b910180921461019557906002556101a0565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101cd57505f5b6001546002828201116101e25750505f6101e8565b01600290035b5f555f600155604c025ff35b5f5ffd" # noqa: E501 |
| 62 | + pre[Spec_EIP7002.WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS] = Account( |
| 63 | + code=modified_code, |
| 64 | + nonce=1, |
| 65 | + balance=0, |
| 66 | + ) |
| 67 | + |
| 68 | + sender: EOA = pre.fund_eoa() |
| 69 | + tx: Transaction = Transaction( |
| 70 | + to=Spec_EIP7002.WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, |
| 71 | + sender=sender, |
| 72 | + gas_limit=100_000, |
| 73 | + ) |
| 74 | + |
| 75 | + blockchain_test( |
| 76 | + pre=pre, |
| 77 | + blocks=[ |
| 78 | + Block( |
| 79 | + txs=[tx], |
| 80 | + # header_verify=Header( |
| 81 | + # requests_hash=Requests( |
| 82 | + # *[ |
| 83 | + # request.with_source_address( |
| 84 | + # Spec_EIP7002.WITHDRAWAL_REQUEST_PREDEPLOY_SENDER |
| 85 | + # ) |
| 86 | + # for request in sorted(requests, key=lambda r: r.type) |
| 87 | + # ], |
| 88 | + # ) |
| 89 | + # |
| 90 | + # requests_hash=requests, |
| 91 | + # |
| 92 | + # withdrawals_root=requests, |
| 93 | + # ), |
| 94 | + ), |
| 95 | + ], |
| 96 | + post={}, |
| 97 | + ) |
0 commit comments