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:
Mac L
2026-01-15 06:16:40 +04:00
committed by GitHub
parent f584521e85
commit 605ef8e8e6
9 changed files with 53 additions and 66 deletions

View File

@@ -886,7 +886,7 @@ impl SlashingsContext {
) -> Result<Self, Error> {
let sum_slashings = state.get_all_slashings().iter().copied().safe_sum()?;
let adjusted_total_slashing_balance = min(
sum_slashings.safe_mul(spec.proportional_slashing_multiplier_for_state(state))?,
sum_slashings.safe_mul(state.get_proportional_slashing_multiplier(spec))?,
state_ctxt.total_active_balance,
);

View File

@@ -17,7 +17,7 @@ pub fn process_slashings<E: EthSpec>(
let sum_slashings = state.get_all_slashings().iter().copied().safe_sum()?;
let adjusted_total_slashing_balance = std::cmp::min(
sum_slashings.safe_mul(spec.proportional_slashing_multiplier_for_state(state))?,
sum_slashings.safe_mul(state.get_proportional_slashing_multiplier(spec))?,
total_balance,
);