Skip to content

Commit

Permalink
contracts: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
fed-franz committed Jul 3, 2024
1 parent 0d73ab4 commit 35c774a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions contracts/stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
}

Expand Down
14 changes: 7 additions & 7 deletions contracts/stake/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 35c774a

Please sign in to comment.