mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Remove state dependency from core module in consensus/types (#8653)
#8652 - This removes instances of `BeaconStateError` from `eth_spec.rs`, and replaces them directly with `ArithError` which can be trivially converted back to `BeaconStateError` at the call site. - Also moves the state related methods on `ChainSpec` to be methods on `BeaconState` instead. I think this might be a more natural place for them to exist anyway. Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -42,8 +42,7 @@ pub fn slash_validator<E: EthSpec>(
|
||||
decrease_balance(
|
||||
state,
|
||||
slashed_index,
|
||||
validator_effective_balance
|
||||
.safe_div(spec.min_slashing_penalty_quotient_for_state(state))?,
|
||||
validator_effective_balance.safe_div(state.get_min_slashing_penalty_quotient(spec))?,
|
||||
)?;
|
||||
|
||||
update_progressive_balances_on_slashing(state, slashed_index, validator_effective_balance)?;
|
||||
@@ -54,8 +53,8 @@ pub fn slash_validator<E: EthSpec>(
|
||||
// Apply proposer and whistleblower rewards
|
||||
let proposer_index = ctxt.get_proposer_index(state, spec)? as usize;
|
||||
let whistleblower_index = opt_whistleblower_index.unwrap_or(proposer_index);
|
||||
let whistleblower_reward = validator_effective_balance
|
||||
.safe_div(spec.whistleblower_reward_quotient_for_state(state))?;
|
||||
let whistleblower_reward =
|
||||
validator_effective_balance.safe_div(state.get_whistleblower_reward_quotient(spec))?;
|
||||
let proposer_reward = if state.fork_name_unchecked().altair_enabled() {
|
||||
whistleblower_reward
|
||||
.safe_mul(PROPOSER_WEIGHT)?
|
||||
|
||||
Reference in New Issue
Block a user