Skip to content

Commit 48a9fcd

Browse files
committed
Merge branch 'eip-7251' into devnet-1
2 parents 789bd39 + cf2ba90 commit 48a9fcd

File tree

9 files changed

+96
-51
lines changed

9 files changed

+96
-51
lines changed

src/ethereum_test_tools/common/conversions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def to_fixed_size_bytes(input: FixedSizeBytesConvertible, size: int) -> bytes:
5959
Converts multiple types into fixed-size bytes.
6060
"""
6161
if isinstance(input, int):
62-
if input < 0:
63-
return int.to_bytes(input, length=size, byteorder="big", signed=True)
64-
return int.to_bytes(input, length=size, byteorder="big")
62+
return int.to_bytes(input, length=size, byteorder="big", signed=input < 0)
6563
input = to_bytes(input)
6664
if len(input) > size:
6765
raise Exception(f"input is too large for fixed size bytes: {len(input)} > {size}")

tests/prague/eip7002_el_triggerable_withdrawals/conftest.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Fixtures for the EIP-7002 deposit tests.
33
"""
4+
from itertools import zip_longest
45
from typing import List
56

67
import pytest
@@ -57,6 +58,13 @@ def included_requests(
5758
excess_withdrawal_requests,
5859
len(current_block_requests),
5960
)
61+
while carry_over_requests:
62+
# Keep adding blocks until all withdrawal requests are included
63+
per_block_included_requests.append(
64+
carry_over_requests[: Spec.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK]
65+
)
66+
carry_over_requests = carry_over_requests[Spec.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK :]
67+
6068
return per_block_included_requests
6169

6270

@@ -69,10 +77,16 @@ def blocks(
6977
"""
7078
Return the list of blocks that should be included in the test.
7179
"""
72-
return [
80+
return [ # type: ignore
7381
Block(
7482
txs=sum((r.transactions() for r in block_requests), []),
75-
header_verify=Header(requests_root=included_requests[i]),
83+
header_verify=Header(requests_root=block_included_requests),
84+
)
85+
for block_requests, block_included_requests in zip_longest(
86+
blocks_withdrawal_requests,
87+
included_requests,
88+
fillvalue=[],
7689
)
77-
for i, block_requests in enumerate(blocks_withdrawal_requests)
78-
]
90+
] + [
91+
Block(header_verify=Header(requests_root=[]))
92+
] # Add an empty block at the end to verify that no more withdrawal requests are included

tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
validator_pubkey=0x01,
6565
amount=0,
6666
fee=0,
67+
valid=False,
6768
)
6869
],
6970
),
@@ -262,7 +263,6 @@
262263
),
263264
pytest.param(
264265
[
265-
# Block 1
266266
[
267267
WithdrawalRequestTransaction(
268268
requests=[
@@ -275,10 +275,6 @@
275275
]
276276
)
277277
],
278-
# Block 2, no new withdrawal requests, but queued requests from previous block
279-
[],
280-
# Block 3, no new nor queued withdrawal requests
281-
[],
282278
],
283279
id="multiple_block_above_max_withdrawal_requests_from_eoa",
284280
),

tests/prague/eip7251_consolidations/conftest.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Fixtures for the EIP-7251 consolidations tests.
33
"""
4+
from itertools import zip_longest
45
from typing import List
56

67
import pytest
@@ -57,6 +58,14 @@ def included_requests(
5758
excess_consolidation_requests,
5859
len(current_block_requests),
5960
)
61+
62+
while carry_over_requests:
63+
# Keep adding blocks until all consolidation requests are included
64+
per_block_included_requests.append(
65+
carry_over_requests[: Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK]
66+
)
67+
carry_over_requests = carry_over_requests[Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK :]
68+
6069
return per_block_included_requests
6170

6271

@@ -69,10 +78,16 @@ def blocks(
6978
"""
7079
Return the list of blocks that should be included in the test.
7180
"""
72-
return [
81+
return [ # type: ignore
7382
Block(
7483
txs=sum((r.transactions() for r in block_requests), []),
75-
header_verify=Header(requests_root=included_requests[i]),
84+
header_verify=Header(requests_root=block_included_requests),
85+
)
86+
for block_requests, block_included_requests in zip_longest(
87+
blocks_consolidation_requests,
88+
included_requests,
89+
fillvalue=[],
7690
)
77-
for i, block_requests in enumerate(blocks_consolidation_requests)
78-
]
91+
] + [
92+
Block(header_verify=Header(requests_root=[]))
93+
] # Add an empty block at the end to verify that no more consolidation requests are included

tests/prague/eip7251_consolidations/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ConsolidationRequestInteractionBase:
7878
"""
7979
requests: List[ConsolidationRequest]
8080
"""
81-
Withdrawal request to be included in the block.
81+
Consolidation requests to be included in the block.
8282
"""
8383

8484
def transactions(self) -> List[Transaction]:

tests/prague/eip7251_consolidations/spec.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
2-
Common procedures to test
3-
[EIP-7251: Increase the MAX_EFFECTIVE_BALANCE](https://eips.ethereum.org/EIPS/eip-7251)
4-
""" # noqa: E501
2+
Defines EIP-7251 specification constants and functions.
3+
"""
54

65
from dataclasses import dataclass
76

@@ -49,8 +48,6 @@ class Spec:
4948
CONSOLIDATION_REQUEST_FEE_UPDATE_FRACTION = 17
5049
EXCESS_INHIBITOR = 1181
5150

52-
MAX_AMOUNT = 2**64 - 1
53-
5451
@staticmethod
5552
def fake_exponential(factor: int, numerator: int, denominator: int) -> int:
5653
"""

tests/prague/eip7251_consolidations/test_consolidations.py

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,38 @@
5555
],
5656
id="single_block_single_consolidation_request_from_eoa",
5757
),
58+
pytest.param(
59+
[
60+
[
61+
ConsolidationRequestTransaction(
62+
requests=[
63+
ConsolidationRequest(
64+
source_pubkey=0x01,
65+
target_pubkey=0x01,
66+
fee=Spec.get_fee(0),
67+
)
68+
],
69+
),
70+
],
71+
],
72+
id="single_block_single_consolidation_request_from_eoa_equal_pubkeys",
73+
),
74+
pytest.param(
75+
[
76+
[
77+
ConsolidationRequestTransaction(
78+
requests=[
79+
ConsolidationRequest(
80+
source_pubkey=-1,
81+
target_pubkey=-2,
82+
fee=Spec.get_fee(0),
83+
)
84+
],
85+
),
86+
],
87+
],
88+
id="single_block_single_consolidation_request_from_eoa_max_pubkeys",
89+
),
5890
pytest.param(
5991
[
6092
[
@@ -64,6 +96,7 @@
6496
source_pubkey=0x01,
6597
target_pubkey=0x02,
6698
fee=0,
99+
valid=False,
67100
)
68101
],
69102
),
@@ -168,6 +201,9 @@
168201
)
169202
],
170203
],
204+
marks=pytest.mark.skip(
205+
reason="duplicate test due to MAX_CONSOLIDATION_REQUESTS_PER_BLOCK==1"
206+
),
171207
id="single_block_max_consolidation_requests_from_eoa",
172208
),
173209
pytest.param(
@@ -262,7 +298,6 @@
262298
),
263299
pytest.param(
264300
[
265-
# Block 1
266301
[
267302
ConsolidationRequestTransaction(
268303
requests=[
@@ -271,14 +306,10 @@
271306
target_pubkey=i * 2 + 1,
272307
fee=Spec.get_fee(0),
273308
)
274-
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 2)
309+
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
275310
]
276311
)
277312
],
278-
# Block 2, no new consolidation requests, but queued requests from previous block
279-
[],
280-
# Block 3, no new nor queued consolidation requests
281-
[],
282313
],
283314
id="multiple_block_above_max_consolidation_requests_from_eoa",
284315
),
@@ -308,9 +339,7 @@
308339
target_pubkey=i * 2 + 1,
309340
fee=Spec.get_fee(0),
310341
)
311-
for i in range(
312-
Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK
313-
) # TODO: MAX_CONSOLIDATION_REQUESTS_PER_BLOCK not ideal
342+
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
314343
],
315344
),
316345
],
@@ -334,9 +363,7 @@
334363
target_pubkey=i * 2 + 1,
335364
fee=Spec.get_fee(0),
336365
)
337-
for i in range(
338-
1, Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK
339-
) # TODO: MAX_CONSOLIDATION_REQUESTS_PER_BLOCK not ideal
366+
for i in range(1, Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
340367
],
341368
),
342369
],
@@ -353,15 +380,15 @@
353380
target_pubkey=i * 2 + 1,
354381
fee=Spec.get_fee(0),
355382
)
356-
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK - 1)
383+
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
357384
]
358385
+ [
359386
ConsolidationRequest(
360387
source_pubkey=-1,
361388
target_pubkey=-2,
362389
fee=0,
363390
)
364-
], # TODO: MAX_CONSOLIDATION_REQUESTS_PER_BLOCK not ideal
391+
],
365392
),
366393
],
367394
],
@@ -388,9 +415,9 @@
388415
fee=Spec.get_fee(0),
389416
valid=True,
390417
)
391-
for i in range(1, Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK)
418+
for i in range(1, Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
392419
],
393-
), # TODO: MAX_CONSOLIDATION_REQUESTS_PER_BLOCK not ideal
420+
),
394421
],
395422
],
396423
id="single_block_multiple_consolidation_requests_from_contract_first_oog",
@@ -407,7 +434,7 @@
407434
gas_limit=1_000_000,
408435
valid=True,
409436
)
410-
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK)
437+
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
411438
]
412439
+ [
413440
ConsolidationRequest(
@@ -418,7 +445,7 @@
418445
valid=False,
419446
)
420447
],
421-
), # TODO: MAX_CONSOLIDATION_REQUESTS_PER_BLOCK not ideal
448+
),
422449
],
423450
],
424451
id="single_block_multiple_consolidation_requests_from_contract_last_oog",
@@ -434,11 +461,11 @@
434461
fee=Spec.get_fee(0),
435462
valid=False,
436463
)
437-
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK)
464+
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
438465
],
439466
extra_code=Op.REVERT(0, 0),
440467
),
441-
], # TODO: MAX_CONSOLIDATION_REQUESTS_PER_BLOCK not ideal
468+
],
442469
],
443470
id="single_block_multiple_consolidation_requests_from_contract_caller_reverts",
444471
),
@@ -453,10 +480,10 @@
453480
fee=Spec.get_fee(0),
454481
valid=False,
455482
)
456-
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK)
483+
for i in range(Spec.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK * 5)
457484
],
458485
extra_code=Macros.OOG(),
459-
), # TODO: MAX_CONSOLIDATION_REQUESTS_PER_BLOCK not ideal
486+
),
460487
],
461488
],
462489
id="single_block_multiple_consolidation_requests_from_contract_caller_oog",

tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,10 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
274274
contract_code += Op.SSTORE(
275275
storage.store_next(1),
276276
Op.CALL(
277-
Op.GAS,
278-
call_contract_address,
279-
value,
280-
0,
281-
len(current_calldata),
282-
0,
283-
0,
277+
address=call_contract_address,
278+
value=value,
279+
args_offset=0,
280+
args_size=len(current_calldata),
284281
),
285282
)
286283

whitelist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ extcodehash
134134
extcodesize
135135
F00
136136
filesystem
137+
fillvalue
137138
firstlineno
138139
fn
139140
fname

0 commit comments

Comments
 (0)