@@ -18,6 +18,7 @@ import (
18
18
19
19
"github.com/spacemeshos/go-spacemesh/activation/wire"
20
20
"github.com/spacemeshos/go-spacemesh/atxsdata"
21
+ "github.com/spacemeshos/go-spacemesh/codec"
21
22
"github.com/spacemeshos/go-spacemesh/common/types"
22
23
"github.com/spacemeshos/go-spacemesh/datastore"
23
24
"github.com/spacemeshos/go-spacemesh/events"
@@ -626,9 +627,7 @@ func (h *HandlerV2) syntacticallyValidateDeps(
626
627
zap .Int ("index" , invalidIdx .Index ),
627
628
)
628
629
// TODO(mafa): finish proof
629
- proof := & wire.ATXProof {
630
- ProofType : wire .InvalidPost ,
631
- }
630
+ var proof wire.Proof
632
631
if err := h .malPublisher .Publish (ctx , id , proof ); err != nil {
633
632
return nil , fmt .Errorf ("publishing malfeasance proof for invalid post: %w" , err )
634
633
}
@@ -669,7 +668,7 @@ func (h *HandlerV2) checkMalicious(
669
668
return nil
670
669
}
671
670
672
- malicious , err = h .checkDoubleMarry (ctx , tx , watx . ID () , marrying )
671
+ malicious , err = h .checkDoubleMarry (ctx , tx , watx , marrying )
673
672
if err != nil {
674
673
return fmt .Errorf ("checking double marry: %w" , err )
675
674
}
@@ -704,18 +703,31 @@ func (h *HandlerV2) checkMalicious(
704
703
func (h * HandlerV2 ) checkDoubleMarry (
705
704
ctx context.Context ,
706
705
tx * sql.Tx ,
707
- atxID types. ATXID ,
706
+ atx * wire. ActivationTxV2 ,
708
707
marrying []marriage ,
709
708
) (bool , error ) {
710
709
for _ , m := range marrying {
711
710
mATX , err := identities .MarriageATX (tx , m .id )
712
711
if err != nil {
713
712
return false , fmt .Errorf ("checking if ID is married: %w" , err )
714
713
}
715
- if mATX != atxID {
716
- // TODO(mafa): finish proof
717
- proof := & wire.ATXProof {
718
- ProofType : wire .DoubleMarry ,
714
+ if mATX != atx .ID () {
715
+ var blob sql.Blob
716
+ v , err := atxs .LoadBlob (ctx , tx , mATX .Bytes (), & blob )
717
+ if err != nil {
718
+ return true , fmt .Errorf ("creating double marry proof: %w" , err )
719
+ }
720
+ if v != types .AtxV2 {
721
+ h .logger .Fatal ("Failed to create double marry malfeasance proof: ATX is not v2" ,
722
+ zap .Stringer ("atx_id" , mATX ),
723
+ )
724
+ }
725
+ var otherAtx wire.ActivationTxV2
726
+ codec .MustDecode (blob .Bytes , & otherAtx )
727
+
728
+ proof , err := wire .NewDoubleMarryProof (tx , atx , & otherAtx , m .id )
729
+ if err != nil {
730
+ return true , fmt .Errorf ("creating double marry proof: %w" , err )
719
731
}
720
732
return true , h .malPublisher .Publish (ctx , m .id , proof )
721
733
}
@@ -747,9 +759,7 @@ func (h *HandlerV2) checkDoublePost(
747
759
zap .Uint32 ("epoch" , atx .PublishEpoch .Uint32 ()),
748
760
)
749
761
// TODO(mafa): finish proof
750
- proof := & wire.ATXProof {
751
- ProofType : wire .DoublePublish ,
752
- }
762
+ var proof wire.Proof
753
763
return true , h .malPublisher .Publish (ctx , id , proof )
754
764
}
755
765
return false , nil
@@ -776,10 +786,7 @@ func (h *HandlerV2) checkDoubleMerge(ctx context.Context, tx *sql.Tx, watx *wire
776
786
zap .Stringer ("smesher_id" , watx .SmesherID ),
777
787
)
778
788
779
- // TODO(mafa): finish proof
780
- proof := & wire.ATXProof {
781
- ProofType : wire .DoubleMerge ,
782
- }
789
+ var proof wire.Proof
783
790
return true , h .malPublisher .Publish (ctx , watx .SmesherID , proof )
784
791
}
785
792
0 commit comments