Process Electra and Single attestations in the slasher - #728
Open
rocker-zhang wants to merge 1 commit into
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The slasher was silently dropping
Attestation::ElectraandAttestation::Singlefrom its detection path, so attester-slashing detection has been effectively dead on mainnet since the Electra fork.This change unifies the slasher's internal
IndexedAttestationandAttesterSlashingtypes 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 fromattester_indexinto an ElectraIndexedAttestationviaContiguousList::try_from_iter.Attestation::Electra: passed throughelectra::get_indexed_attestation.Attestation::Phase0: widened to Electra viaContiguousList::try_from_iter(Phase 0'sMaxValidatorsPerCommitteebound is a subset of Electra'sMaxAttestersPerSlot).process_attester_slashingnow emitsCombinedAttesterSlashing::Electra. The change ripples throughslasher/src/{attestations,indexed_attestations,messages,status,targets}.rs,validator/src/validator.rs, and a 3-line comment inblock_producer/src/block_producer.rsdocumenting the intentional pre-Electra filter drop.Tests
Three new tests:
single_attestation_converts_to_single_index_indexed_attestation(slasher.rs): Single → ElectraIndexedAttestationround-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
AttestationDatais fork-independent, so existing slasher DB entries remain byte-compatible.IndexedAttestationcontaining a single index has the same on-wire shape as a Phase 0IndexedAttestationwith the same index, modulo theattesting_indicestype bound.Fixes #655.