|
16 | 16 | from execution_testing.base_types import Bytes |
17 | 17 | from execution_testing.fixtures import BlockchainEngineFixture |
18 | 18 | from execution_testing.fixtures.blockchain import ( |
19 | | - FixtureEngineNewPayload, |
20 | 19 | FixtureExecutionPayload, |
21 | 20 | FixtureHeader, |
22 | 21 | ) |
|
29 | 28 | ) |
30 | 29 | from execution_testing.rpc.rpc_types import ( |
31 | 30 | ForkchoiceState, |
32 | | - PayloadAttributes, |
33 | 31 | PayloadStatusEnum, |
34 | 32 | ) |
35 | 33 | from execution_testing.test_types.block_access_list import BlockAccessList |
|
42 | 40 |
|
43 | 41 | logger = get_logger(__name__) |
44 | 42 |
|
45 | | -# Execution-dependent fields that must match exactly between the built |
46 | | -# and expected payloads. Excluded: |
47 | | -# - gas_limit: testing_buildBlockV1 doesn't accept it; the client |
48 | | -# picks its own via EIP-1559 (validated separately by range check). |
49 | | -# - block_hash: depends on gas_limit, so it will differ too. |
50 | | -_VALIDATED_FIELDS = ( |
51 | | - "state_root", |
52 | | - "receipts_root", |
53 | | - "gas_used", |
54 | | - "logs_bloom", |
55 | | - "base_fee_per_gas", |
56 | | - "blob_gas_used", |
57 | | - "excess_blob_gas", |
58 | | - "block_access_list", |
59 | | - "fee_recipient", |
60 | | - "number", |
61 | | - "timestamp", |
62 | | - "extra_data", |
63 | | - "prev_randao", |
64 | | - "parent_hash", |
65 | | - "transactions", |
66 | | - "withdrawals", |
67 | | -) |
68 | | - |
69 | 43 |
|
70 | 44 | def _format_block_access_list_diff( |
71 | 45 | expected_rlp: bytes | None, |
@@ -114,23 +88,6 @@ def _format_block_access_list_diff( |
114 | 88 | ) |
115 | 89 |
|
116 | 90 |
|
117 | | -def _payload_attributes( |
118 | | - payload: FixtureEngineNewPayload, |
119 | | -) -> PayloadAttributes: |
120 | | - """Extract PayloadAttributes from a fixture payload.""" |
121 | | - execution_payload = payload.params[0] |
122 | | - parent_beacon_block_root = ( |
123 | | - payload.params[2] if len(payload.params) >= 3 else None |
124 | | - ) |
125 | | - return PayloadAttributes( |
126 | | - timestamp=execution_payload.timestamp, |
127 | | - prev_randao=execution_payload.prev_randao, |
128 | | - suggested_fee_recipient=execution_payload.fee_recipient, |
129 | | - withdrawals=execution_payload.withdrawals, |
130 | | - parent_beacon_block_root=parent_beacon_block_root, |
131 | | - ) |
132 | | - |
133 | | - |
134 | 91 | def _validate_gas_limit( |
135 | 92 | built: FixtureExecutionPayload, |
136 | 93 | parent_gas_limit: int, |
@@ -161,7 +118,17 @@ def _validate_built_block( |
161 | 118 | _validate_gas_limit(built, parent_gas_limit) |
162 | 119 |
|
163 | 120 | mismatches: List[str] = [] |
164 | | - for field in _VALIDATED_FIELDS: |
| 121 | + |
| 122 | + # All FixtureExecutionPayload fields are validated except: |
| 123 | + # - gas_limit: testing_buildBlockV1 doesn't accept it; the client |
| 124 | + # picks its own via EIP-1559 (validated separately by range check). |
| 125 | + # - block_hash: depends on gas_limit, so it will differ too. |
| 126 | + validated_fields = tuple( |
| 127 | + name |
| 128 | + for name in FixtureExecutionPayload.model_fields |
| 129 | + if name not in {"gas_limit", "block_hash"} |
| 130 | + ) |
| 131 | + for field in validated_fields: |
165 | 132 | built_val = getattr(built, field) |
166 | 133 | expected_val = getattr(expected, field) |
167 | 134 | if built_val != expected_val: |
@@ -257,10 +224,9 @@ def test_blockchain_via_build( |
257 | 224 | with total_build_timing.time(f"Block {i + 1}") as block_timing: |
258 | 225 | # 1. Build the block |
259 | 226 | with block_timing.time("testing_buildBlockV1"): |
260 | | - attributes = _payload_attributes(payload) |
261 | 227 | build_response = testing_rpc.build_block( |
262 | 228 | parent_block_hash=(expected_payload.parent_hash), |
263 | | - payload_attributes=attributes, |
| 229 | + payload_attributes=payload.get_payload_attributes(), |
264 | 230 | transactions=(expected_payload.transactions), |
265 | 231 | extra_data=expected_payload.extra_data, |
266 | 232 | ) |
|
0 commit comments