mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
Update consensus code and tests to v0.12.3 (#1655)
## Proposed Changes Update test vectors for v0.12.3, and introduced configurable `proportional_slashing_multiplier`. Also makes `YamlConfig` a bit safer by making every field access in `apply_to_chain_spec` explicit, and removing the `#[serde(default)]` attribute, which would instantiate missing fields to type defaults! Risky!
This commit is contained in:
@@ -11,6 +11,10 @@ pub fn process_slashings<T: EthSpec>(
|
||||
) -> Result<(), Error> {
|
||||
let epoch = state.current_epoch();
|
||||
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)?,
|
||||
total_balance,
|
||||
);
|
||||
|
||||
for (index, validator) in state.validators.iter().enumerate() {
|
||||
if validator.slashed
|
||||
@@ -21,7 +25,7 @@ pub fn process_slashings<T: EthSpec>(
|
||||
let penalty_numerator = validator
|
||||
.effective_balance
|
||||
.safe_div(increment)?
|
||||
.safe_mul(std::cmp::min(sum_slashings.safe_mul(3)?, total_balance))?;
|
||||
.safe_mul(adjusted_total_slashing_balance)?;
|
||||
let penalty = penalty_numerator
|
||||
.safe_div(total_balance)?
|
||||
.safe_mul(increment)?;
|
||||
|
||||
Reference in New Issue
Block a user