File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -430,3 +430,21 @@ def is_double_vote(attestation_data_1: 'AttestationData',
430
430
due to a 'double vote'.
431
431
"""
432
432
return attestation_data_1 .slot == attestation_data_2 .slot
433
+
434
+
435
+ def is_surround_vote (attestation_data_1 : 'AttestationData' ,
436
+ attestation_data_2 : 'AttestationData' ) -> bool :
437
+ """
438
+ Assumes ``attestation_data_1`` is distinct from ``attestation_data_2``.
439
+
440
+ Returns True if the provided ``AttestationData`` are slashable
441
+ due to a 'surround vote'.
442
+
443
+ Note: parameter order matters as this function only checks
444
+ that ``attestation_data_1`` surrounds ``attestation_data_2``.
445
+ """
446
+ return (
447
+ (attestation_data_1 .justified_slot < attestation_data_2 .justified_slot ) and
448
+ (attestation_data_2 .justified_slot + 1 == attestation_data_2 .slot ) and
449
+ (attestation_data_2 .slot < attestation_data_1 .slot )
450
+ )
Original file line number Diff line number Diff line change 36
36
_get_shard_committees_at_slot ,
37
37
get_block_committees_info ,
38
38
is_double_vote ,
39
+ is_surround_vote ,
39
40
)
40
41
41
42
@@ -757,3 +758,22 @@ def test_is_double_vote(sample_attestation_data_params):
757
758
attestation_data_3 = AttestationData (** attestation_data_3_params )
758
759
759
760
assert not is_double_vote (attestation_data_1 , attestation_data_3 )
761
+
762
+
763
+ def test_is_surround_vote (sample_attestation_data_params ):
764
+ attestation_data_1_params = {
765
+ ** sample_attestation_data_params ,
766
+ 'slot' : 4 ,
767
+ 'justified_slot' : 0 ,
768
+
769
+ }
770
+ attestation_data_1 = AttestationData (** attestation_data_1_params )
771
+
772
+ attestation_data_2_params = {
773
+ ** sample_attestation_data_params ,
774
+ 'slot' : 3 ,
775
+ 'justified_slot' : 2 ,
776
+ }
777
+ attestation_data_2 = AttestationData (** attestation_data_2_params )
778
+
779
+ assert is_surround_vote (attestation_data_1 , attestation_data_2 )
You can’t perform that action at this time.
0 commit comments