Skip to content

Commit d886a9d

Browse files
committed
Add formatter support for Prague header field requests_hash
1 parent 1d0d0e9 commit d886a9d

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

tests/core/eth-module/test_block_api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def test_get_block_formatters_with_null_values(w3, request_mocker):
4646
"blobGasUsed": None,
4747
"excessBlobGas": None,
4848
"parentBeaconBlockRoot": None,
49+
"requestsHash": None,
4950
}
5051
with request_mocker(w3, mock_results={"eth_getBlockByNumber": null_values_block}):
5152
received_block = w3.eth.get_block("pending")
@@ -109,6 +110,9 @@ def test_get_block_formatters_with_pre_formatted_values(w3, request_mocker):
109110
"parentBeaconBlockRoot": (
110111
"0x6470e77f1b8a55a49a57b3f74c2a10a76185636d65122053752ea5e4bb4dac59"
111112
),
113+
"requestsHash": (
114+
"0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
115+
),
112116
}
113117

114118
with request_mocker(
@@ -170,4 +174,5 @@ def test_get_block_formatters_with_pre_formatted_values(w3, request_mocker):
170174
"parentBeaconBlockRoot": HexBytes(
171175
unformatted_values_block["parentBeaconBlockRoot"]
172176
),
177+
"requestsHash": HexBytes(unformatted_values_block["requestsHash"]),
173178
}

web3/_utils/method_formatters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ def storage_key_to_hexstr(value: Union[bytes, int, str]) -> HexStr:
358358
"transactionsRoot": to_hex_if_bytes,
359359
"withdrawalsRoot": to_hex_if_bytes,
360360
"parentBeaconBlockRoot": to_hex_if_bytes,
361+
"requestsHash": to_hex_if_bytes,
361362
}
362363
block_request_formatter = type_aware_apply_formatters_to_dict(BLOCK_REQUEST_FORMATTERS)
363364

@@ -400,6 +401,7 @@ def storage_key_to_hexstr(value: Union[bytes, int, str]) -> HexStr:
400401
"blobGasUsed": to_integer_if_hex,
401402
"excessBlobGas": to_integer_if_hex,
402403
"parentBeaconBlockRoot": apply_formatter_if(is_not_null, to_hexbytes(32)),
404+
"requestsHash": apply_formatter_if(is_not_null, to_hexbytes(32)),
403405
}
404406
block_result_formatter = type_aware_apply_formatters_to_dict(BLOCK_RESULT_FORMATTERS)
405407

web3/providers/eth_tester/middleware.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def is_hexstr(value: Any) -> bool:
203203
"parent_beacon_block_root": "parentBeaconBlockRoot",
204204
"blob_gas_used": "blobGasUsed",
205205
"excess_blob_gas": "excessBlobGas",
206+
"requests_hash": "requestsHash",
206207
}
207208
block_result_remapper = apply_key_map(BLOCK_RESULT_KEY_MAPPING)
208209

web3/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class BlockData(TypedDict, total=False):
212212
parentBeaconBlockRoot: HexBytes
213213
blobGasUsed: int
214214
excessBlobGas: int
215+
requestsHash: HexBytes
215216

216217
# ExtraDataToPOAMiddleware replaces extraData w/ proofOfAuthorityData
217218
proofOfAuthorityData: HexBytes

0 commit comments

Comments
 (0)