@@ -714,8 +714,21 @@ func TestValidateBeaconBlockPubSub_SeenProposerSlot(t *testing.T) {
714
714
msg .Signature , err = signing .ComputeDomainAndSign (beaconState , 0 , msg .Block , params .BeaconConfig ().DomainBeaconProposer , privKeys [proposerIdx ])
715
715
require .NoError (t , err )
716
716
717
- chainService := & mock.ChainService {Genesis : time .Unix (time .Now ().Unix ()- int64 (params .BeaconConfig ().SecondsPerSlot ), 0 ),
718
- State : beaconState ,
717
+ // Create a clone of the same block (same signature, not an equivocation)
718
+ msgClone := util .NewBeaconBlock ()
719
+ msgClone .Block .Slot = 1
720
+ msgClone .Block .ProposerIndex = proposerIdx
721
+ msgClone .Block .ParentRoot = bRoot [:]
722
+ msgClone .Signature = msg .Signature // Use the same signature
723
+
724
+ signedBlock , err := blocks .NewSignedBeaconBlock (msg )
725
+ require .NoError (t , err )
726
+
727
+ slashingPool := & slashingsmock.PoolMock {}
728
+ chainService := & mock.ChainService {
729
+ Genesis : time .Unix (time .Now ().Unix ()- int64 (params .BeaconConfig ().SecondsPerSlot ), 0 ),
730
+ State : beaconState ,
731
+ Block : signedBlock , // Set the first block as the head block
719
732
FinalizedCheckPoint : & ethpb.Checkpoint {
720
733
Epoch : 0 ,
721
734
Root : make ([]byte , 32 ),
@@ -729,17 +742,23 @@ func TestValidateBeaconBlockPubSub_SeenProposerSlot(t *testing.T) {
729
742
chain : chainService ,
730
743
clock : startup .NewClock (chainService .Genesis , chainService .ValidatorsRoot ),
731
744
blockNotifier : chainService .BlockNotifier (),
745
+ slashingPool : slashingPool ,
732
746
},
733
747
seenBlockCache : lruwrpr .New (10 ),
734
748
badBlockCache : lruwrpr .New (10 ),
735
749
slotToPendingBlocks : gcache .New (time .Second , 2 * time .Second ),
736
750
seenPendingBlocks : make (map [[32 ]byte ]bool ),
737
751
}
738
752
753
+ // Mark the proposer/slot as seen
754
+ r .setSeenBlockIndexSlot (msg .Block .Slot , msg .Block .ProposerIndex )
755
+ time .Sleep (10 * time .Millisecond ) // Wait for cached value to pass through buffers
756
+
757
+ // Prepare and validate the second message (clone)
739
758
buf := new (bytes.Buffer )
740
- _ , err = p .Encoding ().EncodeGossip (buf , msg )
759
+ _ , err = p .Encoding ().EncodeGossip (buf , msgClone )
741
760
require .NoError (t , err )
742
- topic := p2p .GossipTypeMapping [reflect .TypeOf (msg )]
761
+ topic := p2p .GossipTypeMapping [reflect .TypeOf (msgClone )]
743
762
digest , err := r .currentForkDigest ()
744
763
assert .NoError (t , err )
745
764
topic = r .addDigestToTopic (topic , digest )
@@ -749,11 +768,14 @@ func TestValidateBeaconBlockPubSub_SeenProposerSlot(t *testing.T) {
749
768
Topic : & topic ,
750
769
},
751
770
}
752
- r . setSeenBlockIndexSlot ( msg . Block . Slot , msg . Block . ProposerIndex )
753
- time . Sleep ( 10 * time . Millisecond ) // Wait for cached value to pass through buffers.
771
+
772
+ // Since this is not an equivocation (same signature), it should be ignored
754
773
res , err := r .validateBeaconBlockPubSub (ctx , "" , m )
755
774
assert .NoError (t , err )
756
- assert .Equal (t , res , pubsub .ValidationIgnore , "seen proposer block should be ignored" )
775
+ assert .Equal (t , pubsub .ValidationIgnore , res , "block with same signature should be ignored" )
776
+
777
+ // Verify no slashings were created
778
+ assert .Equal (t , 0 , len (slashingPool .PendingPropSlashings ), "Expected no slashings for same signature" )
757
779
}
758
780
759
781
func TestValidateBeaconBlockPubSub_FilterByFinalizedEpoch (t * testing.T ) {
0 commit comments