Unbounded Loop in `briVault::_getWinnerShares` Can Lead to Contract DoS
Description
The `briVault::_getWinnerShares` function an unbounded loop that iterates over all participants stored in `briVault::usersAddress` array. This function is called during winner selection and calculates total shares for the winning team. The loop performs storage operations in each iteration, which is gas-intensive. If there are huge numbers of participants, the gas cost increases linearly. Which lead to exceeding the block gas limit.
Risk
Likelihood:
Impact:
Proof of Concept
Recommended Mitigation
- remove this code
+ add this codeUse a ` mapping(uint256 => uint256) public sharesPerCountry;` to track shares per country and use `sharesPerCountry[countryId] += participantShares;` in `briVault::joinEvent` to update immediately and then return in `briVault::setWinner`.