mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-24 17:39:05 +00:00
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
|
||||
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`
|
||||
@ -1092,10 +1094,14 @@ def is_surround_vote(attestation_data_1: AttestationData,
|
||||
Note: parameter order matters as this function only checks
|
||||
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 (
|
||||
(attestation_data_1.justified_slot < attestation_data_2.justified_slot) and
|
||||
(attestation_data_2.justified_slot + 1 == attestation_data_2.slot) and
|
||||
(attestation_data_2.slot < attestation_data_1.slot)
|
||||
(source_epoch_1 < source_epoch_2) and
|
||||
(source_epoch_2 + 1 == target_epoch_2) and
|
||||
(target_epoch_2 < target_epoch_1)
|
||||
)
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user