Skip to content

Process Electra and Single attestations in the slasher - #728

Open
rocker-zhang wants to merge 1 commit into
grandinetech:developfrom
rocker-zhang:slasher-electra-single-attestations
Open

Process Electra and Single attestations in the slasher#728
rocker-zhang wants to merge 1 commit into
grandinetech:developfrom
rocker-zhang:slasher-electra-single-attestations

Conversation

@rocker-zhang

Copy link
Copy Markdown

Summary

The slasher was silently dropping Attestation::Electra and Attestation::Single from its detection path, so attester-slashing detection has been effectively dead on mainnet since the Electra fork.

This change unifies the slasher's internal IndexedAttestation and AttesterSlashing types on the Electra form (Electra's bound supersets Phase 0's, and the live network is post-Electra). The three attestation kinds are handled as follows:

  • Attestation::Single: built directly from attester_index into an Electra IndexedAttestation via ContiguousList::try_from_iter.
  • Attestation::Electra: passed through electra::get_indexed_attestation.
  • Attestation::Phase0: widened to Electra via ContiguousList::try_from_iter (Phase 0's MaxValidatorsPerCommittee bound is a subset of Electra's MaxAttestersPerSlot).

process_attester_slashing now emits CombinedAttesterSlashing::Electra. The change ripples through slasher/src/{attestations,indexed_attestations,messages,status,targets}.rs, validator/src/validator.rs, and a 3-line comment in block_producer/src/block_producer.rs documenting the intentional pre-Electra filter drop.

Tests

Three new tests:

  • single_attestation_converts_to_single_index_indexed_attestation (slasher.rs): Single → Electra IndexedAttestation round-trip.
  • phase0_indexed_attestation_widens_preserving_indices_data_and_signature (slasher.rs): Phase 0 → Electra widening preserves all fields.
  • detects_double_vote_for_each_attester_in_multi_index_attestation (attestations.rs): multi-attester double-vote detection path.

cargo test -p slasher: 9/9 pass. cargo check -p validator: clean.

Compat notes

  • Fork choice and block production re-validate independently, so the always-Electra-output choice does not affect their correctness.
  • AttestationData is fork-independent, so existing slasher DB entries remain byte-compatible.
  • SSZ encoding of an Electra IndexedAttestation containing a single index has the same on-wire shape as a Phase 0 IndexedAttestation with the same index, modulo the attesting_indices type bound.

Fixes #655.

…etech#655

The slasher silently dropped Attestation::Electra and Attestation::Single, so attester-slashing detection was dead on networks past the Electra fork. Unify the slasher's internal IndexedAttestation and AttesterSlashing on the Electra form (its attesting_indices bound is a superset of Phase 0's) and emit slashings as combined AttesterSlashing::Electra.

Note: the pre-Electra block-production path cannot include these slashings, which is acceptable since post-Electra nodes do not build pre-Electra blocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slasher ignores Electra and Single attestations

1 participant