Commit fbb157d
committed
fix(stf): invalidate blocks with out-of-range justified-slot votes (leanSpec #1023)
`is_slot_justified` read a slot past the tracked justification window as
"not justified" via `unwrap_or(false)`, so a vote whose source or target
slot sits at or beyond the importing block's own slot was silently skipped
and the block accepted. leanSpec raises `JUSTIFIED_SLOT_OUT_OF_RANGE`
there and treats the block as invalid, so a crafted block would split
ethlambda from spec-strict clients. Honest ethlambda proposers never emit
one, since the builder mirrors `is_valid_vote`.
`is_slot_justified` now returns `Result<bool, Error>` with a new
`Error::JustifiedSlotOutOfRange`, which `is_valid_vote` propagates out of
`process_attestations`.
The block builder's `entry_passes_filters` keeps the lenient reading on
purpose. Its projection is seeded from the head state, whose window stops
at `head.slot - 1`, while the chain view it filters against reaches
`candidate.slot - 1`; a vote targeting the head block's own slot is
routinely untracked there, so propagating would have dropped the dominant
attestation shape. It pre-filters gossip candidates rather than deciding
validity, and the state transition stays the authority.
The spec fixture `test_source_slot_beyond_tracked_range_rejects_block`
already passed, but vacuously: the filler zeroes `stateRoot` on an invalid
test's final block, so ethlambda rejected on `StateRootMismatch` instead
of the real reason. It now rejects with the matching error.1 parent 948353f commit fbb157d
3 files changed
Lines changed: 61 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
460 | 466 | | |
461 | 467 | | |
462 | 468 | | |
463 | 469 | | |
464 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
465 | 473 | | |
466 | 474 | | |
467 | 475 | | |
| |||
471 | 479 | | |
472 | 480 | | |
473 | 481 | | |
| 482 | + | |
| 483 | + | |
474 | 484 | | |
475 | 485 | | |
476 | 486 | | |
477 | 487 | | |
478 | 488 | | |
479 | 489 | | |
| 490 | + | |
480 | 491 | | |
481 | 492 | | |
482 | 493 | | |
| |||
Lines changed: 23 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
23 | 42 | | |
24 | 43 | | |
25 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
309 | 317 | | |
310 | 318 | | |
311 | 319 | | |
312 | | - | |
| 320 | + | |
313 | 321 | | |
314 | 322 | | |
315 | 323 | | |
| |||
392 | 400 | | |
393 | 401 | | |
394 | 402 | | |
395 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
396 | 412 | | |
397 | 413 | | |
398 | 414 | | |
| |||
401 | 417 | | |
402 | 418 | | |
403 | 419 | | |
404 | | - | |
405 | | - | |
406 | | - | |
| 420 | + | |
| 421 | + | |
407 | 422 | | |
408 | 423 | | |
409 | 424 | | |
410 | 425 | | |
411 | 426 | | |
412 | 427 | | |
413 | 428 | | |
414 | | - | |
415 | | - | |
| 429 | + | |
| 430 | + | |
416 | 431 | | |
417 | 432 | | |
418 | 433 | | |
419 | 434 | | |
420 | 435 | | |
421 | | - | |
| 436 | + | |
422 | 437 | | |
423 | 438 | | |
424 | 439 | | |
425 | 440 | | |
426 | | - | |
| 441 | + | |
427 | 442 | | |
428 | 443 | | |
429 | 444 | | |
430 | 445 | | |
431 | | - | |
| 446 | + | |
432 | 447 | | |
433 | 448 | | |
434 | | - | |
| 449 | + | |
435 | 450 | | |
436 | 451 | | |
437 | 452 | | |
| |||
0 commit comments