Occurs when code fails to respect predefined boundaries or intervals (e.g., epochs, time windows, thresholds)
Game
Examine how setRewardTier assigns reward tiers based on the score value. Can you identify any boundary misalignments in the conditions that might cause scores on the boundary to be assigned incorrectly?
// SPDX-License-Identifier: MIT// Open me in VSCode and really think before opening the hints!// Add @audit tags wherever suspicious// Go to the solidity docs to complete missing knowledge of what's happening here// Solve by drafting a fix!pragmasolidity ^0.8.0;contract BoundaryMisalignmentGame {uint256public rewardTier;// Function to assign a reward tier based on scorefunctionsetRewardTier(uint256 score) public {if (score <50) { rewardTier =1; } elseif (score <=100) { rewardTier =2; } elseif (score <150) { rewardTier =3; } else { rewardTier =4; } }}
Pay attention to how each boundary is defined and consider what happens at the cutoff points, especially around 100 and 150.
Think about how overlapping or missing ranges could lead to certain scores being assigned to the wrong tier or skipped entirely.