Proud Wintergreen Butterfly
Medium
The set_range_handler
function in the wooracle
module does not properly propagate errors from the update_range_max
call due to the missing ?
operator. This omission can lead to silent failures, where the function appears to succeed even when an error has occurred.
In the set_range_handler
function, the ?
operator is used to propagate errors from the update_range_min
function call, but is missing from the subsequent update_range_max
call. The ?
operator is essential for propagating errors to the caller. Without it, any error returned by update_range_max
is ignored, and the function returns Ok(())
even when the operation fails.
This could lead to silent failures where the range_max
value is not updated as expected. The wooracle
may remain in an inconsistent state because the function incorrectly indicates success. Incorrect setup of the range_max
variable can result in wrong calculations and functioning of the protocol.
Manual Review
Add the ? operator to the update_range_max call in the set_range_handler function to ensure proper error propagation. This will prevent silent failures and ensure that the function returns an error when update_range_max fails.
pub fn set_range_handler(
ctx: Context<SetWooStateOnlyGuardian>,
range_min: u128,
range_max: u128,
) -> Result<()> {
ctx.accounts.wooracle.update_range_min(range_min)?;
— ctx.accounts.wooracle.update_range_max(range_max)
++ ctx.accounts.wooracle.update_range_max(range_max)?
}