Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
stake-pool: Add comments about unnecessary ownership checks (HAL-01) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque authored Sep 1, 2023
1 parent c9edc4d commit 25381b2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stake-pool/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,17 @@ impl Processor {
return Err(StakePoolError::AlreadyInUse.into());
}

// This check is unnecessary since the runtime will check the ownership,
// but provides clarity that the parameter is in fact checked.
check_account_owner(stake_pool_info, program_id)?;
let mut stake_pool = try_from_slice_unchecked::<StakePool>(&stake_pool_info.data.borrow())?;
if !stake_pool.is_uninitialized() {
msg!("Provided stake pool already in use");
return Err(StakePoolError::AlreadyInUse.into());
}

// This check is unnecessary since the runtime will check the ownership,
// but provides clarity that the parameter is in fact checked.
check_account_owner(validator_list_info, program_id)?;
let mut validator_list =
try_from_slice_unchecked::<ValidatorList>(&validator_list_info.data.borrow())?;
Expand Down

0 comments on commit 25381b2

Please sign in to comment.