@@ -11,6 +11,7 @@ import (
1111 slashertypes "github.com/prysmaticlabs/prysm/v5/beacon-chain/slasher/types"
1212 "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
1313 ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
14+ "github.com/prysmaticlabs/prysm/v5/runtime/version"
1415 "github.com/sirupsen/logrus"
1516)
1617
@@ -232,6 +233,43 @@ func (m *MinSpanChunksSlice) CheckSlashable(
232233
233234 surroundingVotesTotal .Inc ()
234235
236+ // Both attestations should have the same type. If not, we convert both to Electra attestations.
237+ unifyAttWrapperVersion (existingAttWrapper , incomingAttWrapper )
238+
239+ postElectra := existingAttWrapper .IndexedAttestation .Version () >= version .Electra
240+ if postElectra {
241+ existing , ok := existingAttWrapper .IndexedAttestation .(* ethpb.IndexedAttestationElectra )
242+ if ! ok {
243+ return nil , fmt .Errorf (
244+ "existing attestation has wrong type (expected %T, got %T)" ,
245+ & ethpb.IndexedAttestationElectra {},
246+ existingAttWrapper .IndexedAttestation ,
247+ )
248+ }
249+ incoming , ok := incomingAttWrapper .IndexedAttestation .(* ethpb.IndexedAttestationElectra )
250+ if ! ok {
251+ return nil , fmt .Errorf (
252+ "incoming attestation has wrong type (expected %T, got %T)" ,
253+ & ethpb.IndexedAttestationElectra {},
254+ incomingAttWrapper .IndexedAttestation ,
255+ )
256+ }
257+ slashing := & ethpb.AttesterSlashingElectra {
258+ Attestation_1 : existing ,
259+ Attestation_2 : incoming ,
260+ }
261+
262+ // Ensure the attestation with the lower data root is the first attestation.
263+ if bytes .Compare (existingAttWrapper .DataRoot [:], incomingAttWrapper .DataRoot [:]) > 0 {
264+ slashing = & ethpb.AttesterSlashingElectra {
265+ Attestation_1 : incoming ,
266+ Attestation_2 : existing ,
267+ }
268+ }
269+
270+ return slashing , nil
271+ }
272+
235273 existing , ok := existingAttWrapper .IndexedAttestation .(* ethpb.IndexedAttestation )
236274 if ! ok {
237275 return nil , fmt .Errorf (
@@ -328,6 +366,43 @@ func (m *MaxSpanChunksSlice) CheckSlashable(
328366
329367 surroundedVotesTotal .Inc ()
330368
369+ // Both attestations should have the same type. If not, we convert the non-Electra attestation into an Electra attestation.
370+ unifyAttWrapperVersion (existingAttWrapper , incomingAttWrapper )
371+
372+ postElectra := existingAttWrapper .IndexedAttestation .Version () >= version .Electra
373+ if postElectra {
374+ existing , ok := existingAttWrapper .IndexedAttestation .(* ethpb.IndexedAttestationElectra )
375+ if ! ok {
376+ return nil , fmt .Errorf (
377+ "existing attestation has wrong type (expected %T, got %T)" ,
378+ & ethpb.IndexedAttestationElectra {},
379+ existingAttWrapper .IndexedAttestation ,
380+ )
381+ }
382+ incoming , ok := incomingAttWrapper .IndexedAttestation .(* ethpb.IndexedAttestationElectra )
383+ if ! ok {
384+ return nil , fmt .Errorf (
385+ "incoming attestation has wrong type (expected %T, got %T)" ,
386+ & ethpb.IndexedAttestationElectra {},
387+ incomingAttWrapper .IndexedAttestation ,
388+ )
389+ }
390+ slashing := & ethpb.AttesterSlashingElectra {
391+ Attestation_1 : existing ,
392+ Attestation_2 : incoming ,
393+ }
394+
395+ // Ensure the attestation with the lower data root is the first attestation.
396+ if bytes .Compare (existingAttWrapper .DataRoot [:], incomingAttWrapper .DataRoot [:]) > 0 {
397+ slashing = & ethpb.AttesterSlashingElectra {
398+ Attestation_1 : incoming ,
399+ Attestation_2 : existing ,
400+ }
401+ }
402+
403+ return slashing , nil
404+ }
405+
331406 existing , ok := existingAttWrapper .IndexedAttestation .(* ethpb.IndexedAttestation )
332407 if ! ok {
333408 return nil , fmt .Errorf (
0 commit comments