49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 | @pytest.mark.parametrize(
"requests_list",
[
pytest.param(
[],
id="empty_request_list",
),
pytest.param(
[
*withdrawal_list_with_custom_fee(1),
],
id="1_withdrawal_request",
),
pytest.param(
[
*withdrawal_list_with_custom_fee(15),
],
id="15_withdrawal_requests",
),
pytest.param(
[
*withdrawal_list_with_custom_fee(16),
],
id="16_withdrawal_requests",
),
pytest.param(
[
*withdrawal_list_with_custom_fee(17),
],
id="17_withdrawal_requests",
),
pytest.param(
[
*withdrawal_list_with_custom_fee(18),
],
id="18_withdrawal_requests",
),
],
)
def test_extra_withdrawals(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
requests_list: List[WithdrawalRequest],
) -> None:
"""
Test how clients were to behave when more than 16 withdrawals would be
allowed per block.
"""
modified_code: Bytecode = Bytecode()
memory_offset: int = 0
amount_of_requests: int = 0
for withdrawal_request in requests_list:
# update memory_offset with the correct value
withdrawal_request_bytes_amount: int = len(bytes(withdrawal_request))
assert withdrawal_request_bytes_amount == 76, (
"Expected withdrawal request to be of size 76 but got size "
f"{withdrawal_request_bytes_amount}"
)
memory_offset += withdrawal_request_bytes_amount
modified_code += Om.MSTORE(bytes(withdrawal_request), memory_offset)
amount_of_requests += 1
modified_code += Op.RETURN(0, Op.MSIZE())
pre[Spec_EIP7002.WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS] = Account(
code=modified_code,
nonce=1,
balance=0,
)
# given a list of withdrawal requests construct a withdrawal request
# transaction
withdrawal_request_transaction = WithdrawalRequestTransaction(
requests=requests_list
)
# prepare withdrawal senders
prepared = withdrawal_request_transaction.update_pre(pre=pre)
# get transaction list
txs: List[Transaction] = prepared.transactions()
blockchain_test(
pre=pre,
blocks=[
Block(
txs=txs,
requests_hash=Requests(*requests_list),
),
],
post={},
)
|