@@ -60,49 +60,46 @@ impl<E: EthSpec> AttesterSlashingStatus<E> {
6060 Ok ( match self {
6161 NotSlashable => None ,
6262 AlreadyDoubleVoted => None ,
63- DoubleVote ( existing) | SurroundedByExisting ( existing) => match * existing {
64- IndexedAttestation :: Base ( existing_att) => {
65- Some ( AttesterSlashing :: Base ( AttesterSlashingBase {
66- attestation_1 : existing_att,
67- attestation_2 : new_attestation
68- . as_base ( )
69- . map_err ( |e| format ! ( "{e:?}" ) ) ?
70- . clone ( ) ,
71- } ) )
72- }
73- IndexedAttestation :: Electra ( existing_att) => {
74- Some ( AttesterSlashing :: Electra ( AttesterSlashingElectra {
75- attestation_1 : existing_att,
76- // A double vote should never convert, a surround vote where the surrounding
77- // vote is electra may convert.
63+ DoubleVote ( existing) | SurroundedByExisting ( existing) => {
64+ match ( & * existing, new_attestation) {
65+ ( IndexedAttestation :: Base ( existing_att) , IndexedAttestation :: Base ( new) ) => {
66+ Some ( AttesterSlashing :: Base ( AttesterSlashingBase {
67+ attestation_1 : existing_att. clone ( ) ,
68+ attestation_2 : new. clone ( ) ,
69+ } ) )
70+ }
71+ // A slashing involving an electra attestation type must return an `AttesterSlashingElectra` type
72+ ( _, _) => Some ( AttesterSlashing :: Electra ( AttesterSlashingElectra {
73+ attestation_1 : existing
74+ . clone ( )
75+ . to_electra ( )
76+ . map_err ( |e| format ! ( "{e:?}" ) ) ?,
7877 attestation_2 : new_attestation
7978 . clone ( )
8079 . to_electra ( )
8180 . map_err ( |e| format ! ( "{e:?}" ) ) ?,
81+ } ) ) ,
82+ }
83+ }
84+ SurroundsExisting ( existing) => match ( & * existing, new_attestation) {
85+ ( IndexedAttestation :: Base ( existing_att) , IndexedAttestation :: Base ( new) ) => {
86+ Some ( AttesterSlashing :: Base ( AttesterSlashingBase {
87+ attestation_1 : new. clone ( ) ,
88+ attestation_2 : existing_att. clone ( ) ,
8289 } ) )
8390 }
91+ // A slashing involving an electra attestation type must return an `AttesterSlashingElectra` type
92+ ( _, _) => Some ( AttesterSlashing :: Electra ( AttesterSlashingElectra {
93+ attestation_1 : new_attestation
94+ . clone ( )
95+ . to_electra ( )
96+ . map_err ( |e| format ! ( "{e:?}" ) ) ?,
97+ attestation_2 : existing
98+ . clone ( )
99+ . to_electra ( )
100+ . map_err ( |e| format ! ( "{e:?}" ) ) ?,
101+ } ) ) ,
84102 } ,
85- SurroundsExisting ( existing) => {
86- match new_attestation {
87- IndexedAttestation :: Base ( new_attestation) => {
88- Some ( AttesterSlashing :: Base ( AttesterSlashingBase {
89- attestation_1 : existing
90- . as_base ( )
91- . map_err ( |e| format ! ( "{e:?}" ) ) ?
92- . clone ( ) ,
93- attestation_2 : new_attestation. clone ( ) ,
94- } ) )
95- }
96- IndexedAttestation :: Electra ( new_attestation) => {
97- Some ( AttesterSlashing :: Electra ( AttesterSlashingElectra {
98- attestation_1 : existing. to_electra ( ) . map_err ( |e| format ! ( "{e:?}" ) ) ?,
99- // A double vote should never convert, a surround vote where the surrounding
100- // vote is electra may convert.
101- attestation_2 : new_attestation. clone ( ) ,
102- } ) )
103- }
104- }
105- }
106103 } )
107104 }
108105}
0 commit comments