diff --git a/contracts/stake/src/lib.rs b/contracts/stake/src/lib.rs index 4f6c65ca0e..a52d0e8b7f 100644 --- a/contracts/stake/src/lib.rs +++ b/contracts/stake/src/lib.rs @@ -119,9 +119,9 @@ unsafe fn slash(arg_len: u32) -> u32 { #[no_mangle] unsafe fn hard_slash(arg_len: u32) -> u32 { - rusk_abi::wrap_call(arg_len, |(pk, value)| { + rusk_abi::wrap_call(arg_len, |(pk, value, severity)| { assert_external_caller(); - STATE.hard_slash(&pk, value); + STATE.hard_slash(&pk, value, severity); }) } diff --git a/contracts/stake/src/state.rs b/contracts/stake/src/state.rs index cf78bd5709..d9de21e36b 100644 --- a/contracts/stake/src/state.rs +++ b/contracts/stake/src/state.rs @@ -363,23 +363,23 @@ impl StakeState { ) { self.check_new_block(); - let stake_info = self + let stake = self .get_stake_mut(stake_pk) .expect("The stake to slash should exist"); - let prev_value = Some(stake_info.clone()); - - let stake = stake_info.amount.as_mut(); - // This can happen if the provisioner unstake in the same block - if stake.is_none() { - return; + // Stake can have no amount if provisioner unstake in the same block + if stake.amount().is_none() { + return; } + let prev_value = Some(stake.clone()); + let (stake_amount, eligibility) = stake.amount.as_mut().expect("stake_to_exists"); let severity = severity.unwrap_or(1); stake.hard_faults = stake.hard_faults.saturating_add(severity); + let hard_faults = stake.hard_faults as u64; // The stake is shifted (aka suspended) for the rest of the current // epoch plus hard_faults epochs