_getWinnerShares() function is intended to iterate through all users and sum their shares for the winning country, returning the total.Problem:
The function loops through the entire usersAddress array without bounds or batching, and writes to a state variable (totalWinnerShares), compounding gas costs.
Once the user array grows large, this function can no longer execute successfully due to block gas limit constraints.
Likelihood:
The loop executes every time _getWinnerShares() is called, regardless of array size.
As usersAddress grows, gas consumption increases linearly until it exceeds the block gas limit.
Impact:
Functions depending on _getWinnerShares() will revert, halting reward distribution or result settlement.
Contract becomes non-functional for large user bases (DoS against entire protocol).
function getWinnerSharesBatch(uint256 start, uint256 end) external view returns (uint256 batchTotal) {
require(end <= usersAddress.length, "Invalid range");
for (uint256 i = start; i < end; ++i) {
address user = usersAddress[i];
batchTotal += userSharesToCountry[user][winnerCountryId];
}
}
What This Does
Instead of processing every user in one transaction, it processes only a small range (start → end).
You can call it multiple times (or off-chain) to sum the results in parts.
The _getWinnerShares() function is intended to iterate through all users and sum their shares for the winning country, returning the total.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.