mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-26 09:15:17 +00:00
Fix the tests that use MIN_SLASHING_PENALTY_QUOTIENT
. (The mainnet tests failed before this fix)
This commit is contained in:
parent
24a244eb9b
commit
dda7010c0c
@ -1,8 +1,16 @@
|
|||||||
|
from eth2spec.test.context import is_post_lightclient_patch
|
||||||
from eth2spec.test.helpers.block_header import sign_block_header
|
from eth2spec.test.helpers.block_header import sign_block_header
|
||||||
from eth2spec.test.helpers.keys import pubkey_to_privkey
|
from eth2spec.test.helpers.keys import pubkey_to_privkey
|
||||||
from eth2spec.test.helpers.state import get_balance
|
from eth2spec.test.helpers.state import get_balance
|
||||||
|
|
||||||
|
|
||||||
|
def get_min_slashing_penalty_quotient(spec):
|
||||||
|
if is_post_lightclient_patch(spec):
|
||||||
|
return spec.HF1_MIN_SLASHING_PENALTY_QUOTIENT
|
||||||
|
else:
|
||||||
|
return spec.MIN_SLASHING_PENALTY_QUOTIENT
|
||||||
|
|
||||||
|
|
||||||
def check_proposer_slashing_effect(spec, pre_state, state, slashed_index):
|
def check_proposer_slashing_effect(spec, pre_state, state, slashed_index):
|
||||||
slashed_validator = state.validators[slashed_index]
|
slashed_validator = state.validators[slashed_index]
|
||||||
assert slashed_validator.slashed
|
assert slashed_validator.slashed
|
||||||
@ -10,7 +18,7 @@ def check_proposer_slashing_effect(spec, pre_state, state, slashed_index):
|
|||||||
assert slashed_validator.withdrawable_epoch < spec.FAR_FUTURE_EPOCH
|
assert slashed_validator.withdrawable_epoch < spec.FAR_FUTURE_EPOCH
|
||||||
|
|
||||||
proposer_index = spec.get_beacon_proposer_index(state)
|
proposer_index = spec.get_beacon_proposer_index(state)
|
||||||
slash_penalty = state.validators[slashed_index].effective_balance // spec.MIN_SLASHING_PENALTY_QUOTIENT
|
slash_penalty = state.validators[slashed_index].effective_balance // get_min_slashing_penalty_quotient(spec)
|
||||||
whistleblower_reward = state.validators[slashed_index].effective_balance // spec.WHISTLEBLOWER_REWARD_QUOTIENT
|
whistleblower_reward = state.validators[slashed_index].effective_balance // spec.WHISTLEBLOWER_REWARD_QUOTIENT
|
||||||
if proposer_index != slashed_index:
|
if proposer_index != slashed_index:
|
||||||
# slashed validator lost initial slash penalty
|
# slashed validator lost initial slash penalty
|
||||||
|
@ -4,6 +4,7 @@ from eth2spec.test.context import (
|
|||||||
from eth2spec.test.helpers.attestations import sign_indexed_attestation
|
from eth2spec.test.helpers.attestations import sign_indexed_attestation
|
||||||
from eth2spec.test.helpers.attester_slashings import get_valid_attester_slashing, \
|
from eth2spec.test.helpers.attester_slashings import get_valid_attester_slashing, \
|
||||||
get_indexed_attestation_participants, get_attestation_2_data, get_attestation_1_data
|
get_indexed_attestation_participants, get_attestation_2_data, get_attestation_1_data
|
||||||
|
from eth2spec.test.helpers.proposer_slashings import get_min_slashing_penalty_quotient
|
||||||
from eth2spec.test.helpers.state import (
|
from eth2spec.test.helpers.state import (
|
||||||
get_balance,
|
get_balance,
|
||||||
next_epoch_via_block,
|
next_epoch_via_block,
|
||||||
@ -70,7 +71,7 @@ def run_attester_slashing_processing(spec, state, attester_slashing, valid=True)
|
|||||||
expected_balance = (
|
expected_balance = (
|
||||||
pre_proposer_balance
|
pre_proposer_balance
|
||||||
+ total_proposer_rewards
|
+ total_proposer_rewards
|
||||||
- pre_slashings[proposer_index] // spec.MIN_SLASHING_PENALTY_QUOTIENT
|
- pre_slashings[proposer_index] // get_min_slashing_penalty_quotient(spec)
|
||||||
)
|
)
|
||||||
|
|
||||||
assert get_balance(state, proposer_index) == expected_balance
|
assert get_balance(state, proposer_index) == expected_balance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user