Commit 0866722
refactor: audit batch — drop dead helpers, fields, properties (leanEthereum#757)
* refactor: audit batch — drop dead helpers, fields, properties
Eleven cleanups from the consensus-researcher audit, bundled.
snappy: get_uncompressed_length and is_valid_compressed_data were
tests-only helpers. The two corruption tests that used them are
rewritten to assert decompression outcomes directly.
subspecs/ssz/hash: the _htr_bytes / _htr_bytearray / _htr_memoryview
register overloads existed only for one parametrize test; both leave
together. Production hash_tree_root callers always pass typed SSZ
containers.
subspecs/xmss/rand: Rand.rho was the only Randomness-shaped helper
used solely in test_message_hash; the test now builds Randomness
from rand.field_elements directly.
subspecs/xmss/constants: XmssConfig.PUBLIC_KEY_LEN_BYTES had a
single test consumer that effectively re-derived the public-key SSZ
shape. Test rewritten to compute the expected size inline as
(HASH_LEN_FE + PARAMETER_LEN) * P_BYTES.
subspecs/observability: get_observer was only read by tests; the
private singleton is now read via observer_module._observer in the
two affected tests. NullObserver is privatised to _NullObserver and
dropped from the package's public re-exports.
subspecs/genesis/config: num_validators field and its consistency
validator were both informational; the actual count is always taken
from len(genesis_validators). from_yaml was a tests-only string
shortcut for model_validate(yaml.safe_load(...)); tests use a local
_load helper for the same ergonomics without a public method.
subspecs/validator/service: blocks_skipped_lag,
attestations_skipped_lag, and duty_gate_closed were read only from
tests. The private state machine stays; tests now access the
underscored attributes directly.
subspecs/sync/block_cache: PendingBlock.received_at was a debug-only
timestamp written but never read in src. Field dropped together with
the dedicated default-timestamp test; remaining test constructions
no longer pass received_at.
subspecs/sync/head_sync: HeadSyncResult slimmed to processed plus
error. The cached, backfill_triggered, and descendants_processed
fields had no readers outside their own assignments. The error
field is retained per the audit note for incident-response logs.
Six construction sites in head_sync.py and ~14 test assertions
updated accordingly. Also drops the unused peer_id parameter on
_process_cached_descendants; the rest of the file keeps peer_id
where it actually drives attribution.
subspecs/api/server: ApiServerConfig.enabled flag dropped (Node
already gates construction). ApiServer.run no longer polls with
asyncio.sleep(1); it awaits a stop event that _async_stop sets,
matching the same pattern adopted earlier in live.py.
Items deliberately skipped:
- Container.to_hex / from_hex: both used in xmss/containers.py.
- IntFieldElement protocol: removing requires Fp to grow its own
Pydantic core schema; deferred as a real redesign.
- The 7 Spec*Type protocols in forks/protocol.py: serve as
documentation labels distinguishing block-body from block-header
from aggregated-attestations etc. Collapsing to type[SpecSSZType]
erased meaningful type intent.
- ValidatorRegistry.primary_index: two production callers.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fixup: apply ruff format + drop HeadSyncResult fields in routing tests
Two follow-ups to land the audit batch through CI.
- ruff format reformatted two source files (decompress.py and the
validator service) whose edits left awkward blank-line spacing.
- A second test module, test_head_sync_backfill_routing.py, also
constructed HeadSyncResult with the now-dropped cached,
backfill_triggered, and descendants_processed fields. Stripped
those argument lines so ty check passes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fixup: restore _htr_bytes / _htr_bytearray / _htr_memoryview overloads
The audit listed these as tests-only and the unit tests passed
without them, but the consensus fixture filler hit
"TypeError: hash_tree_root: unsupported value type bytes" the
moment a lstar State container with a raw-bytes-typed field was
walked. Production traversal does reach raw bytes; the three
overloads are load-bearing for the fixture pipeline.
Restored along with the parametrize-over-byte-likes test that was
retired together with them. Verified by filling a previously
failing fc test_tick_system fixture.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 363797e commit 0866722
22 files changed
Lines changed: 65 additions & 393 deletions
File tree
- src/lean_spec
- snappy
- subspecs
- api
- genesis
- observability
- sync
- validator
- xmss
- tests/lean_spec
- snappy
- subspecs
- api
- genesis
- observability
- sync
- validator
- xmss
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
| |||
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
31 | | - | |
32 | | - | |
33 | 29 | | |
34 | 30 | | |
35 | 31 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 48 | | |
52 | 49 | | |
53 | 50 | | |
| |||
85 | 82 | | |
86 | 83 | | |
87 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | 95 | | |
100 | 96 | | |
101 | 97 | | |
| |||
126 | 122 | | |
127 | 123 | | |
128 | 124 | | |
129 | | - | |
130 | | - | |
131 | | - | |
| 125 | + | |
132 | 126 | | |
133 | 127 | | |
134 | 128 | | |
| |||
146 | 140 | | |
147 | 141 | | |
148 | 142 | | |
| 143 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | 82 | | |
91 | 83 | | |
92 | 84 | | |
| |||
99 | 91 | | |
100 | 92 | | |
101 | 93 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 94 | | |
115 | 95 | | |
116 | 96 | | |
| |||
146 | 126 | | |
147 | 127 | | |
148 | 128 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | | - | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | | - | |
26 | 23 | | |
27 | | - | |
28 | 24 | | |
29 | 25 | | |
30 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 84 | | |
95 | 85 | | |
96 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | 112 | | |
123 | 113 | | |
124 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | 74 | | |
84 | 75 | | |
85 | 76 | | |
| |||
177 | 168 | | |
178 | 169 | | |
179 | 170 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 171 | | |
184 | 172 | | |
185 | 173 | | |
186 | 174 | | |
187 | 175 | | |
188 | 176 | | |
189 | 177 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | 178 | | |
194 | 179 | | |
195 | 180 | | |
| |||
255 | 240 | | |
256 | 241 | | |
257 | 242 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | 243 | | |
262 | 244 | | |
263 | 245 | | |
264 | 246 | | |
265 | | - | |
| 247 | + | |
266 | 248 | | |
267 | 249 | | |
268 | | - | |
269 | 250 | | |
270 | 251 | | |
271 | 252 | | |
272 | 253 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | 254 | | |
277 | 255 | | |
278 | 256 | | |
| |||
282 | 260 | | |
283 | 261 | | |
284 | 262 | | |
285 | | - | |
286 | 263 | | |
287 | 264 | | |
288 | 265 | | |
| |||
296 | 273 | | |
297 | 274 | | |
298 | 275 | | |
299 | | - | |
300 | 276 | | |
301 | 277 | | |
302 | 278 | | |
| |||
331 | 307 | | |
332 | 308 | | |
333 | 309 | | |
334 | | - | |
335 | 310 | | |
336 | 311 | | |
337 | 312 | | |
| |||
382 | 357 | | |
383 | 358 | | |
384 | 359 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | 360 | | |
389 | 361 | | |
390 | 362 | | |
| |||
427 | 399 | | |
428 | 400 | | |
429 | 401 | | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | 402 | | |
434 | 403 | | |
435 | 404 | | |
| |||
0 commit comments