Skip to content

Commit

Permalink
update slash_validator
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed Jun 25, 2024
1 parent 394a2f6 commit d2a7bf9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions consensus/state_processing/src/common/slash_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,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)?;
let whistleblower_reward = validator_effective_balance
.safe_div(spec.whistleblower_reward_quotient_for_state(state))?;
let proposer_reward = match state {
BeaconState::Base(_) => whistleblower_reward.safe_div(spec.proposer_reward_quotient)?,
BeaconState::Altair(_)
Expand Down
13 changes: 13 additions & 0 deletions consensus/types/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,19 @@ impl ChainSpec {
}
}

/// For a given `BeaconState`, return the whistleblower reward quotient associated with its variant.
pub fn whistleblower_reward_quotient_for_state<E: EthSpec>(
&self,
state: &BeaconState<E>,
) -> u64 {
let fork_name = state.fork_name_unchecked();
if fork_name >= ForkName::Electra {
self.whistleblower_reward_quotient_electra
} else {
self.whistleblower_reward_quotient
}
}

/// Returns a full `Fork` struct for a given epoch.
pub fn fork_at_epoch(&self, epoch: Epoch) -> Fork {
let current_fork_name = self.fork_name_at_epoch(epoch);
Expand Down

0 comments on commit d2a7bf9

Please sign in to comment.