Skip to content

Commit 5a40172

Browse files
marioevzspencer-tb
andauthored
fix(types,tests): EIP-7685 fixes for devnet-5 (#990)
* fix(forks): Update EIP-7002, EIP-7251 contracts * fix(types): Remove empty requests from list * fix(tests): Remove empty requests from lists in all tests * chore: tox black fix. --------- Co-authored-by: spencer-tb <[email protected]>
1 parent 88c1401 commit 5a40172

File tree

14 files changed

+24
-77
lines changed

14 files changed

+24
-77
lines changed

src/ethereum_test_fixtures/tests/test_blockchain.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@
704704
source_pubkey=BLSPublicKey(1),
705705
target_pubkey=BLSPublicKey(2),
706706
),
707-
max_request_type=2,
708707
).requests_list,
709708
validation_error=[
710709
BlockException.INCORRECT_BLOCK_FORMAT,
@@ -786,7 +785,6 @@
786785
source_pubkey=BLSPublicKey(1),
787786
target_pubkey=BLSPublicKey(2),
788787
),
789-
max_request_type=2,
790788
).requests_list
791789
],
792790
],
@@ -861,7 +859,6 @@
861859
source_pubkey=BLSPublicKey(1),
862860
target_pubkey=BLSPublicKey(2),
863861
),
864-
max_request_type=2,
865862
).requests_list,
866863
validation_error=[
867864
BlockException.INCORRECT_BLOCK_FORMAT,
@@ -942,7 +939,6 @@
942939
source_pubkey=BLSPublicKey(1),
943940
target_pubkey=BLSPublicKey(2),
944941
),
945-
max_request_type=2,
946942
).requests_list
947943
],
948944
],
@@ -1230,7 +1226,6 @@ def test_json_deserialization(
12301226
source_pubkey=BLSPublicKey(1),
12311227
target_pubkey=BLSPublicKey(2),
12321228
),
1233-
max_request_type=2,
12341229
).requests_list,
12351230
),
12361231
[
@@ -1295,7 +1290,6 @@ def test_json_deserialization(
12951290
source_pubkey=BLSPublicKey(1),
12961291
target_pubkey=BLSPublicKey(2),
12971292
),
1298-
max_request_type=2,
12991293
).requests_list
13001294
],
13011295
],
Binary file not shown.
4 Bytes
Binary file not shown.

src/ethereum_test_specs/blockchain.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ def make_genesis(
356356
Withdrawal.list_root(env.withdrawals) if env.withdrawals is not None else None
357357
),
358358
parent_beacon_block_root=env.parent_beacon_block_root,
359-
requests_hash=Requests(max_request_type=fork.max_request_type(0, 0))
360-
if fork.header_requests_required(0, 0)
361-
else None,
359+
requests_hash=Requests() if fork.header_requests_required(0, 0) else None,
362360
fork=fork,
363361
)
364362

src/ethereum_test_types/types.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
from abc import abstractmethod
6+
from collections import defaultdict
67
from dataclasses import dataclass
78
from functools import cached_property
89
from typing import Any, ClassVar, Dict, Generic, List, Literal, Sequence, SupportsBytes, Tuple
@@ -1204,7 +1205,6 @@ class Requests:
12041205
def __init__(
12051206
self,
12061207
*requests: RequestBase,
1207-
max_request_type: int | None = None,
12081208
requests_lists: List[List[RequestBase] | Bytes] | None = None,
12091209
):
12101210
"""
@@ -1217,21 +1217,21 @@ def __init__(
12171217
self.requests_list.append(requests_list_to_bytes(requests_list))
12181218
return
12191219
else:
1220-
1221-
assert max_request_type is not None, "max_request_type must be provided"
1222-
1223-
lists: List[List[RequestBase]] = [[] for _ in range(max_request_type + 1)]
1220+
lists: Dict[int, List[RequestBase]] = defaultdict(list)
12241221
for r in requests:
12251222
lists[r.type].append(r)
12261223

1227-
self.requests_list = [requests_list_to_bytes(requests_list) for requests_list in lists]
1224+
self.requests_list = [
1225+
Bytes(bytes([request_type]) + requests_list_to_bytes(lists[request_type]))
1226+
for request_type in sorted(lists.keys())
1227+
]
12281228

12291229
def __bytes__(self) -> bytes:
12301230
"""
12311231
Returns the requests hash.
12321232
"""
12331233
s: bytes = b""
1234-
for i, r in enumerate(self.requests_list):
1234+
for r in self.requests_list:
12351235
# Append the index of the request type to the request data before hashing
1236-
s = s + Bytes(bytes([i]) + r).sha256()
1236+
s = s + r.sha256()
12371237
return Bytes(s).sha256()

src/pytest_plugins/execute/rpc/hive.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,7 @@ def base_pre_genesis(
254254
if env.withdrawals is not None
255255
else None,
256256
parent_beacon_block_root=env.parent_beacon_block_root,
257-
requests_hash=Requests(
258-
max_request_type=base_fork.max_request_type(
259-
block_number=block_number,
260-
timestamp=timestamp,
261-
),
262-
)
257+
requests_hash=Requests()
263258
if base_fork.header_requests_required(block_number=block_number, timestamp=timestamp)
264259
else None,
265260
)

tests/prague/eip6110_deposits/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ def blocks(
7575
header_verify=Header(
7676
requests_hash=Requests(
7777
*included_requests,
78-
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
7978
),
8079
),
8180
requests=Requests(
8281
*block_body_override_requests,
83-
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
8482
).requests_list
8583
if block_body_override_requests is not None
8684
else None,

tests/prague/eip7002_el_triggerable_withdrawals/conftest.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,14 @@ def blocks(
9595
included_requests,
9696
fillvalue=[],
9797
):
98-
max_request_type = fork.max_request_type(
98+
header_verify: Header | None = None
99+
if fork.header_requests_required(
99100
block_number=len(blocks) + 1,
100101
timestamp=timestamp,
101-
)
102-
header_verify: Header | None = None
103-
if max_request_type > -1:
102+
):
104103
header_verify = Header(
105104
requests_hash=Requests(
106105
*block_included_requests,
107-
max_request_type=max_request_type,
108106
)
109107
)
110108
else:
@@ -120,14 +118,7 @@ def blocks(
120118

121119
return blocks + [
122120
Block(
123-
header_verify=Header(
124-
requests_hash=Requests(
125-
max_request_type=fork.max_request_type(
126-
block_number=len(blocks) + 1,
127-
timestamp=timestamp,
128-
)
129-
)
130-
),
121+
header_verify=Header(requests_hash=Requests()),
131122
timestamp=timestamp,
132123
)
133124
] # 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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,11 @@ def test_withdrawal_requests_negative(
711711
header_verify=Header(
712712
requests_hash=Requests(
713713
*included_requests,
714-
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
715714
),
716715
),
717716
requests=(
718717
Requests(
719718
*block_body_override_requests,
720-
max_request_type=fork.max_request_type(block_number=1, timestamp=1),
721719
).requests_list
722720
if block_body_override_requests is not None
723721
else None

tests/prague/eip7251_consolidations/conftest.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,12 @@ def blocks(
9696
included_requests,
9797
fillvalue=[],
9898
):
99-
max_request_type = fork.max_request_type(
99+
header_verify: Header | None = None
100+
if fork.header_requests_required(
100101
block_number=len(blocks) + 1,
101102
timestamp=timestamp,
102-
)
103-
header_verify: Header | None = None
104-
if max_request_type > -1:
105-
header_verify = Header(
106-
requests_hash=Requests(
107-
*block_included_requests,
108-
max_request_type=max_request_type,
109-
)
110-
)
103+
):
104+
header_verify = Header(requests_hash=Requests(*block_included_requests))
111105
else:
112106
assert not block_included_requests
113107
blocks.append(
@@ -121,14 +115,7 @@ def blocks(
121115

122116
return blocks + [
123117
Block(
124-
header_verify=Header(
125-
requests_hash=Requests(
126-
max_request_type=fork.max_request_type(
127-
block_number=len(blocks) + 1,
128-
timestamp=timestamp,
129-
)
130-
)
131-
),
118+
header_verify=Header(requests_hash=Requests()),
132119
timestamp=timestamp,
133120
)
134121
] # Add an empty block at the end to verify that no more consolidation requests are included

0 commit comments

Comments
 (0)