Commit 85aeacd
committed
fix(storage): scope BlockSignatures synthesis to slot-0 anchor only
Reviewers (Claude, Greptile, Codex) on PR #371 flagged that the new
synthesize-on-read fallback was too broad: it covered *any* block whose
`BlockSignatures` row was missing, not just the slot-0 anchor. The
documented invariant is that non-genesis blocks have entries in all
three tables (CLAUDE.md), so a missing signature row for slot > 0 is
storage corruption, not a valid placeholder case — but `get_signed_block`
was hiding it by fabricating a `SignedBlock` with empty
`attestation_signatures`, regardless of what the body actually carried.
Guard the synthesis on `header.slot == 0`. For any other slot, fall
back to returning `None` (the pre-existing "block not found" semantics).
Update the doc on `get_signed_block` to make the scoping explicit.
Also add direct coverage for the synthesis path:
- `attestation::tests::blank_xmss_signature_has_expected_ssz_offsets`
reads the three SSZ offsets back out of `blank_xmss_signature()` and
asserts every non-offset byte is zero — catches a one-off in any of
the three constants that would silently break inner-`Signature`
decoding without changing the outer length.
- `storage::store::tests::get_signed_block_synthesizes_blank_signatures_for_genesis_anchor`
exercises the synthesis path directly against a `from_anchor_state`
store.
- `storage::store::tests::get_signed_block_returns_none_for_non_genesis_with_missing_signatures`
hand-inserts a slot-1 header without its signature row and confirms
the new guard returns `None`.
- The RPC test for the genesis-finalized-block endpoint now asserts the
response body equals the expected SSZ encoding and the Content-Type
header, matching the adjacent `test_get_latest_finalized_block` (per
Greptile Issue 2).
Cosmetic: move `empty_block_signatures` below the `use` block in
`storage/src/store.rs` to follow the file's existing layout.1 parent 2cf0e45 commit 85aeacd
3 files changed
Lines changed: 139 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
309 | 341 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
562 | 568 | | |
563 | 569 | | |
564 | 570 | | |
| |||
568 | 574 | | |
569 | 575 | | |
570 | 576 | | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
571 | 592 | | |
572 | 593 | | |
573 | 594 | | |
| |||
581 | 602 | | |
582 | 603 | | |
583 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
584 | 612 | | |
585 | 613 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
4 | 20 | | |
5 | 21 | | |
6 | 22 | | |
| |||
19 | 35 | | |
20 | 36 | | |
21 | 37 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
984 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
985 | 987 | | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
990 | 994 | | |
991 | 995 | | |
992 | 996 | | |
| |||
1006 | 1010 | | |
1007 | 1011 | | |
1008 | 1012 | | |
1009 | | - | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
1010 | 1019 | | |
1011 | 1020 | | |
1012 | 1021 | | |
| |||
2312 | 2321 | | |
2313 | 2322 | | |
2314 | 2323 | | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
2315 | 2372 | | |
0 commit comments