Skip to content

test(st): attestation with already-justified target is silently skipped #576

@tcoratger

Description

@tcoratger

Context

During attestation processing, if the target slot is already justified, the attestation is silently skipped. Re-justifying an already-justified slot is pointless and could lead to accounting errors.

The check in `process_attestations`:
```python
if self.justified_slots.is_slot_justified(att_data.target.slot, ...):
continue # Already justified, skip
```

This matters because:

  • After justification, attestations targeting that slot may still arrive (delayed gossip)
  • Blocks containing such attestations must not be rejected
  • The attestation simply has no effect

What to test

Write a state transition filler that:

  1. Builds a chain and achieves justification at slot X
  2. In a subsequent block, includes an attestation targeting slot X (already justified)
  3. Verifies the attestation is silently skipped (no error, no state change)

Key assertions

  • Post-state shows slot X was justified (from the first round)
  • The second attestation targeting X produces no additional state change
  • No errors during processing

Where to add the test

Add to: `tests/consensus/devnet/state_transition/test_justification.py`

Code skeleton

def test_attestation_with_already_justified_target_is_silently_skipped(
    state_transition_test: StateTransitionTestFiller,
) -> None:
    """Attestation targeting an already-justified slot is ignored without error."""
    # 1. Build chain and justify slot 1 (supermajority attest)
    # 2. In a later block, include attestation also targeting slot 1
    # 3. Verify no double-counting or error
    pass  # TODO: implement with justification setup from existing patterns

How to run

uv run fill --fork=devnet --clean -n auto -k test_attestation_with_already_justified

References

  • `State.process_attestations`: `src/lean_spec/subspecs/containers/state/state.py`
  • Justification patterns: `tests/consensus/devnet/state_transition/test_justification.py`

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomerstestsScope: Changes to the spec tests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions