diff --git a/src/ethereum_test_fixtures/tests/test_blockchain.py b/src/ethereum_test_fixtures/tests/test_blockchain.py index b861ed554a..b121a1bfed 100644 --- a/src/ethereum_test_fixtures/tests/test_blockchain.py +++ b/src/ethereum_test_fixtures/tests/test_blockchain.py @@ -704,7 +704,6 @@ source_pubkey=BLSPublicKey(1), target_pubkey=BLSPublicKey(2), ), - max_request_type=2, ).requests_list, validation_error=[ BlockException.INCORRECT_BLOCK_FORMAT, @@ -786,7 +785,6 @@ source_pubkey=BLSPublicKey(1), target_pubkey=BLSPublicKey(2), ), - max_request_type=2, ).requests_list ], ], @@ -861,7 +859,6 @@ source_pubkey=BLSPublicKey(1), target_pubkey=BLSPublicKey(2), ), - max_request_type=2, ).requests_list, validation_error=[ BlockException.INCORRECT_BLOCK_FORMAT, @@ -942,7 +939,6 @@ source_pubkey=BLSPublicKey(1), target_pubkey=BLSPublicKey(2), ), - max_request_type=2, ).requests_list ], ], @@ -1230,7 +1226,6 @@ def test_json_deserialization( source_pubkey=BLSPublicKey(1), target_pubkey=BLSPublicKey(2), ), - max_request_type=2, ).requests_list, ), [ @@ -1295,7 +1290,6 @@ def test_json_deserialization( source_pubkey=BLSPublicKey(1), target_pubkey=BLSPublicKey(2), ), - max_request_type=2, ).requests_list ], ], diff --git a/src/ethereum_test_forks/forks/contracts/consolidation_request.bin b/src/ethereum_test_forks/forks/contracts/consolidation_request.bin index d777e1c4a6..2256bbf9c6 100644 Binary files a/src/ethereum_test_forks/forks/contracts/consolidation_request.bin and b/src/ethereum_test_forks/forks/contracts/consolidation_request.bin differ diff --git a/src/ethereum_test_forks/forks/contracts/withdrawal_request.bin b/src/ethereum_test_forks/forks/contracts/withdrawal_request.bin index 200950fa01..b673917ae5 100644 Binary files a/src/ethereum_test_forks/forks/contracts/withdrawal_request.bin and b/src/ethereum_test_forks/forks/contracts/withdrawal_request.bin differ diff --git a/src/ethereum_test_specs/blockchain.py b/src/ethereum_test_specs/blockchain.py index 64a0ccde74..ca81a2ad78 100644 --- a/src/ethereum_test_specs/blockchain.py +++ b/src/ethereum_test_specs/blockchain.py @@ -356,9 +356,7 @@ def make_genesis( Withdrawal.list_root(env.withdrawals) if env.withdrawals is not None else None ), parent_beacon_block_root=env.parent_beacon_block_root, - requests_hash=Requests(max_request_type=fork.max_request_type(0, 0)) - if fork.header_requests_required(0, 0) - else None, + requests_hash=Requests() if fork.header_requests_required(0, 0) else None, fork=fork, ) diff --git a/src/ethereum_test_types/types.py b/src/ethereum_test_types/types.py index f9c32c4a29..95c9387fa2 100644 --- a/src/ethereum_test_types/types.py +++ b/src/ethereum_test_types/types.py @@ -3,6 +3,7 @@ """ from abc import abstractmethod +from collections import defaultdict from dataclasses import dataclass from functools import cached_property from typing import Any, ClassVar, Dict, Generic, List, Literal, Sequence, SupportsBytes, Tuple @@ -1204,7 +1205,6 @@ class Requests: def __init__( self, *requests: RequestBase, - max_request_type: int | None = None, requests_lists: List[List[RequestBase] | Bytes] | None = None, ): """ @@ -1217,21 +1217,21 @@ def __init__( self.requests_list.append(requests_list_to_bytes(requests_list)) return else: - - assert max_request_type is not None, "max_request_type must be provided" - - lists: List[List[RequestBase]] = [[] for _ in range(max_request_type + 1)] + lists: Dict[int, List[RequestBase]] = defaultdict(list) for r in requests: lists[r.type].append(r) - self.requests_list = [requests_list_to_bytes(requests_list) for requests_list in lists] + self.requests_list = [ + Bytes(bytes([request_type]) + requests_list_to_bytes(lists[request_type])) + for request_type in sorted(lists.keys()) + ] def __bytes__(self) -> bytes: """ Returns the requests hash. """ s: bytes = b"" - for i, r in enumerate(self.requests_list): + for r in self.requests_list: # Append the index of the request type to the request data before hashing - s = s + Bytes(bytes([i]) + r).sha256() + s = s + r.sha256() return Bytes(s).sha256() diff --git a/src/pytest_plugins/execute/rpc/hive.py b/src/pytest_plugins/execute/rpc/hive.py index 45251d6d03..2911ab1938 100644 --- a/src/pytest_plugins/execute/rpc/hive.py +++ b/src/pytest_plugins/execute/rpc/hive.py @@ -254,12 +254,7 @@ def base_pre_genesis( if env.withdrawals is not None else None, parent_beacon_block_root=env.parent_beacon_block_root, - requests_hash=Requests( - max_request_type=base_fork.max_request_type( - block_number=block_number, - timestamp=timestamp, - ), - ) + requests_hash=Requests() if base_fork.header_requests_required(block_number=block_number, timestamp=timestamp) else None, ) diff --git a/tests/prague/eip6110_deposits/conftest.py b/tests/prague/eip6110_deposits/conftest.py index b099b079ff..90625d1b6b 100644 --- a/tests/prague/eip6110_deposits/conftest.py +++ b/tests/prague/eip6110_deposits/conftest.py @@ -75,12 +75,10 @@ def blocks( header_verify=Header( requests_hash=Requests( *included_requests, - max_request_type=fork.max_request_type(block_number=1, timestamp=1), ), ), requests=Requests( *block_body_override_requests, - max_request_type=fork.max_request_type(block_number=1, timestamp=1), ).requests_list if block_body_override_requests is not None else None, diff --git a/tests/prague/eip7002_el_triggerable_withdrawals/conftest.py b/tests/prague/eip7002_el_triggerable_withdrawals/conftest.py index 41f0b59436..7862b8dbe7 100644 --- a/tests/prague/eip7002_el_triggerable_withdrawals/conftest.py +++ b/tests/prague/eip7002_el_triggerable_withdrawals/conftest.py @@ -95,16 +95,14 @@ def blocks( included_requests, fillvalue=[], ): - max_request_type = fork.max_request_type( + header_verify: Header | None = None + if fork.header_requests_required( block_number=len(blocks) + 1, timestamp=timestamp, - ) - header_verify: Header | None = None - if max_request_type > -1: + ): header_verify = Header( requests_hash=Requests( *block_included_requests, - max_request_type=max_request_type, ) ) else: @@ -120,14 +118,7 @@ def blocks( return blocks + [ Block( - header_verify=Header( - requests_hash=Requests( - max_request_type=fork.max_request_type( - block_number=len(blocks) + 1, - timestamp=timestamp, - ) - ) - ), + header_verify=Header(requests_hash=Requests()), timestamp=timestamp, ) ] # Add an empty block at the end to verify that no more withdrawal requests are included diff --git a/tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests.py b/tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests.py index ce3c535a58..a8e6b1f778 100644 --- a/tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests.py +++ b/tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests.py @@ -711,13 +711,11 @@ def test_withdrawal_requests_negative( header_verify=Header( requests_hash=Requests( *included_requests, - max_request_type=fork.max_request_type(block_number=1, timestamp=1), ), ), requests=( Requests( *block_body_override_requests, - max_request_type=fork.max_request_type(block_number=1, timestamp=1), ).requests_list if block_body_override_requests is not None else None diff --git a/tests/prague/eip7251_consolidations/conftest.py b/tests/prague/eip7251_consolidations/conftest.py index 8f57088f7b..bee44f1e25 100644 --- a/tests/prague/eip7251_consolidations/conftest.py +++ b/tests/prague/eip7251_consolidations/conftest.py @@ -96,18 +96,12 @@ def blocks( included_requests, fillvalue=[], ): - max_request_type = fork.max_request_type( + header_verify: Header | None = None + if fork.header_requests_required( block_number=len(blocks) + 1, timestamp=timestamp, - ) - header_verify: Header | None = None - if max_request_type > -1: - header_verify = Header( - requests_hash=Requests( - *block_included_requests, - max_request_type=max_request_type, - ) - ) + ): + header_verify = Header(requests_hash=Requests(*block_included_requests)) else: assert not block_included_requests blocks.append( @@ -121,14 +115,7 @@ def blocks( return blocks + [ Block( - header_verify=Header( - requests_hash=Requests( - max_request_type=fork.max_request_type( - block_number=len(blocks) + 1, - timestamp=timestamp, - ) - ) - ), + header_verify=Header(requests_hash=Requests()), timestamp=timestamp, ) ] # Add an empty block at the end to verify that no more consolidation requests are included diff --git a/tests/prague/eip7251_consolidations/test_consolidations.py b/tests/prague/eip7251_consolidations/test_consolidations.py index ca2d18f87a..398f6f04f8 100644 --- a/tests/prague/eip7251_consolidations/test_consolidations.py +++ b/tests/prague/eip7251_consolidations/test_consolidations.py @@ -760,16 +760,10 @@ def test_consolidation_requests_negative( Block( txs=sum((r.transactions() for r in requests), []), header_verify=Header( - requests_hash=Requests( - *included_requests, - max_request_type=fork.max_request_type(block_number=1, timestamp=1), - ), + requests_hash=Requests(*included_requests), ), requests=( - Requests( - *block_body_override_requests, - max_request_type=fork.max_request_type(block_number=1, timestamp=1), - ).requests_list + Requests(*block_body_override_requests).requests_list if block_body_override_requests is not None else None ), diff --git a/tests/prague/eip7685_general_purpose_el_requests/conftest.py b/tests/prague/eip7685_general_purpose_el_requests/conftest.py index 34a1cd70d7..0c8be0dc9f 100644 --- a/tests/prague/eip7685_general_purpose_el_requests/conftest.py +++ b/tests/prague/eip7685_general_purpose_el_requests/conftest.py @@ -80,10 +80,7 @@ def blocks( elif isinstance(r, ConsolidationRequestInteractionBase): valid_requests_list += r.valid_requests(consolidation_request_fee) - valid_requests = Requests( - *valid_requests_list, - max_request_type=fork.max_request_type(block_number=1, timestamp=1), - ) + valid_requests = Requests(*valid_requests_list) if block_body_override_requests is None and block_body_extra_requests is not None: block_body_override_requests = valid_requests.requests_list + block_body_extra_requests @@ -96,9 +93,7 @@ def blocks( return [ Block( txs=sum((r.transactions() for r in requests), []), - header_verify=Header( - requests_hash=valid_requests, - ), + header_verify=Header(requests_hash=valid_requests), requests=block_body_override_requests, exception=exception, rlp_modifier=rlp_modifier, diff --git a/tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py b/tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py index 92329cd05c..c84ab7d39a 100644 --- a/tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py +++ b/tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py @@ -314,7 +314,6 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx( request.with_source_address(contract_address) for request in sorted(requests, key=lambda r: r.type) ], - max_request_type=fork.max_request_type(block_number=1, timestamp=1), ) ), ) diff --git a/tests/prague/eip7702_set_code_tx/test_set_code_txs.py b/tests/prague/eip7702_set_code_tx/test_set_code_txs.py index a423627279..485bb7cf04 100644 --- a/tests/prague/eip7702_set_code_tx/test_set_code_txs.py +++ b/tests/prague/eip7702_set_code_tx/test_set_code_txs.py @@ -2884,9 +2884,7 @@ def test_set_code_to_system_contract( blocks=[ Block( txs=txs, - requests_hash=Requests( - max_request_type=fork.max_request_type(block_number=1) - ), # Verify nothing slipped into the requests trie + requests_hash=Requests(), # Verify nothing slipped into the requests trie ) ], post={