Merge pull request #373 from ethereum/fix-slashing
fix slashing conditons
This commit is contained in:
commit
8f29bcdf08
|
@ -1077,7 +1077,9 @@ def is_double_vote(attestation_data_1: AttestationData,
|
||||||
Returns True if the provided ``AttestationData`` are slashable
|
Returns True if the provided ``AttestationData`` are slashable
|
||||||
due to a 'double vote'.
|
due to a 'double vote'.
|
||||||
"""
|
"""
|
||||||
return attestation_data_1.slot == attestation_data_2.slot
|
target_epoch_1 = attestation_data_1.slot // EPOCH_LENGTH
|
||||||
|
target_epoch_2 = attestation_data_2.slot // EPOCH_LENGTH
|
||||||
|
return target_epoch_1 == target_epoch_2
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `is_surround_vote`
|
#### `is_surround_vote`
|
||||||
|
@ -1092,10 +1094,14 @@ def is_surround_vote(attestation_data_1: AttestationData,
|
||||||
Note: parameter order matters as this function only checks
|
Note: parameter order matters as this function only checks
|
||||||
that ``attestation_data_1`` surrounds ``attestation_data_2``.
|
that ``attestation_data_1`` surrounds ``attestation_data_2``.
|
||||||
"""
|
"""
|
||||||
|
source_epoch_1 = attestation_data_1.justified_slot // EPOCH_LENGTH
|
||||||
|
source_epoch_2 = attestation_data_2.justified_slot // EPOCH_LENGTH
|
||||||
|
target_epoch_1 = attestation_data_1.slot // EPOCH_LENGTH
|
||||||
|
target_epoch_2 = attestation_data_2.slot // EPOCH_LENGTH
|
||||||
return (
|
return (
|
||||||
(attestation_data_1.justified_slot < attestation_data_2.justified_slot) and
|
(source_epoch_1 < source_epoch_2) and
|
||||||
(attestation_data_2.justified_slot + 1 == attestation_data_2.slot) and
|
(source_epoch_2 + 1 == target_epoch_2) and
|
||||||
(attestation_data_2.slot < attestation_data_1.slot)
|
(target_epoch_2 < target_epoch_1)
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue