mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-21 14:58:12 +00:00
test
This commit is contained in:
parent
77d607a760
commit
a6b8574962
@ -366,11 +366,10 @@ def get_flag_index_deltas(state: BeaconState, flag_index: int) -> Tuple[Sequence
|
|||||||
unslashed_participating_balance = get_total_balance(state, unslashed_participating_indices)
|
unslashed_participating_balance = get_total_balance(state, unslashed_participating_indices)
|
||||||
unslashed_participating_increments = unslashed_participating_balance // EFFECTIVE_BALANCE_INCREMENT
|
unslashed_participating_increments = unslashed_participating_balance // EFFECTIVE_BALANCE_INCREMENT
|
||||||
active_increments = get_total_active_balance(state) // EFFECTIVE_BALANCE_INCREMENT
|
active_increments = get_total_active_balance(state) // EFFECTIVE_BALANCE_INCREMENT
|
||||||
in_inactivity_leak = is_in_inactivity_leak(state)
|
|
||||||
for index in get_eligible_validator_indices(state):
|
for index in get_eligible_validator_indices(state):
|
||||||
base_reward = get_base_reward(state, index)
|
base_reward = get_base_reward(state, index)
|
||||||
if index in unslashed_participating_indices:
|
if index in unslashed_participating_indices:
|
||||||
if not in_inactivity_leak:
|
if not is_in_inactivity_leak(state):
|
||||||
reward_numerator = base_reward * weight * unslashed_participating_increments
|
reward_numerator = base_reward * weight * unslashed_participating_increments
|
||||||
rewards[index] += Gwei(reward_numerator // (active_increments * WEIGHT_DENOMINATOR))
|
rewards[index] += Gwei(reward_numerator // (active_increments * WEIGHT_DENOMINATOR))
|
||||||
else:
|
else:
|
||||||
|
@ -133,10 +133,17 @@ def run_attestation_component_deltas(spec, state, component_delta_fn, matching_a
|
|||||||
validator = state.validators[index]
|
validator = state.validators[index]
|
||||||
enough_for_reward = has_enough_for_reward(spec, state, index)
|
enough_for_reward = has_enough_for_reward(spec, state, index)
|
||||||
if index in matching_indices and not validator.slashed:
|
if index in matching_indices and not validator.slashed:
|
||||||
if enough_for_reward:
|
if is_post_altair(spec):
|
||||||
assert rewards[index] > 0
|
if not spec.is_in_inactivity_leak(state) and enough_for_reward:
|
||||||
|
assert rewards[index] > 0
|
||||||
|
else:
|
||||||
|
assert rewards[index] == 0
|
||||||
else:
|
else:
|
||||||
assert rewards[index] == 0
|
if enough_for_reward:
|
||||||
|
assert rewards[index] > 0
|
||||||
|
else:
|
||||||
|
assert rewards[index] == 0
|
||||||
|
|
||||||
assert penalties[index] == 0
|
assert penalties[index] == 0
|
||||||
else:
|
else:
|
||||||
assert rewards[index] == 0
|
assert rewards[index] == 0
|
||||||
@ -225,18 +232,19 @@ def run_get_inactivity_penalty_deltas(spec, state):
|
|||||||
if not is_post_altair(spec):
|
if not is_post_altair(spec):
|
||||||
cancel_base_rewards_per_epoch = spec.BASE_REWARDS_PER_EPOCH
|
cancel_base_rewards_per_epoch = spec.BASE_REWARDS_PER_EPOCH
|
||||||
base_penalty = cancel_base_rewards_per_epoch * base_reward - spec.get_proposer_reward(state, index)
|
base_penalty = cancel_base_rewards_per_epoch * base_reward - spec.get_proposer_reward(state, index)
|
||||||
else:
|
|
||||||
base_penalty = sum(
|
|
||||||
base_reward * numerator // spec.WEIGHT_DENOMINATOR
|
|
||||||
for (_, numerator) in spec.PARTICIPATION_FLAG_WEIGHTS
|
|
||||||
)
|
|
||||||
|
|
||||||
if not has_enough_for_reward(spec, state, index):
|
if not has_enough_for_reward(spec, state, index):
|
||||||
assert penalties[index] == 0
|
assert penalties[index] == 0
|
||||||
elif index in matching_attesting_indices or not has_enough_for_leak_penalty(spec, state, index):
|
elif index in matching_attesting_indices or not has_enough_for_leak_penalty(spec, state, index):
|
||||||
assert penalties[index] == base_penalty
|
if is_post_altair(spec):
|
||||||
|
assert penalties[index] == 0
|
||||||
|
else:
|
||||||
|
assert penalties[index] == base_penalty
|
||||||
else:
|
else:
|
||||||
assert penalties[index] > base_penalty
|
if is_post_altair(spec):
|
||||||
|
assert penalties[index] > 0
|
||||||
|
else:
|
||||||
|
assert penalties[index] > base_penalty
|
||||||
else:
|
else:
|
||||||
assert penalties[index] == 0
|
assert penalties[index] == 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user