Skip to content

Commit

Permalink
fixing find_slashes_in_range
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Jun 1, 2023
1 parent 1c7b434 commit 7848f9c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,11 @@ where
let slashes_for_this_unbond = find_slashes_in_range(
storage,
start_epoch,
Some(withdraw_epoch - params.slash_processing_epoch_offset()),
Some(
withdraw_epoch
- params.unbonding_len
- params.cubic_slashing_window_length,
),
validator,
)?;

Expand Down Expand Up @@ -3282,7 +3286,8 @@ where
Some(
infraction_epoch
.checked_sub(Epoch(
params.slash_processing_epoch_offset(),
params.unbonding_len
+ params.cubic_slashing_window_length,
))
.unwrap_or_default(),
),
Expand Down Expand Up @@ -3331,7 +3336,8 @@ where
Some(
infraction_epoch
.checked_sub(Epoch(
params.slash_processing_epoch_offset(),
params.unbonding_len
+ params.cubic_slashing_window_length,
))
.unwrap_or_default(),
),
Expand Down Expand Up @@ -3585,8 +3591,8 @@ where
Ok(bond_iter.sum::<token::Amount>())
}

/// Find slashes applicable to a validator with inclusive `start` and `end`
/// epoch.
/// Find slashes applicable to a validator with inclusive `start` and exclusive
/// `end` epoch.
fn find_slashes_in_range<S>(
storage: &S,
start: Epoch,
Expand All @@ -3600,7 +3606,7 @@ where
for slash in validator_slashes_handle(validator).iter(storage)? {
let slash = slash?;
if start <= slash.epoch
&& end.map(|end| slash.epoch <= end).unwrap_or(true)
&& end.map(|end| slash.epoch < end).unwrap_or(true)
{
// println!(
// "Slash (epoch, rate) = ({}, {})",
Expand Down

0 comments on commit 7848f9c

Please sign in to comment.