MyCut

First Flight #23
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Valid

Could cost a lot of gas to create Contest

Summary

In the ContestManager.sol to create a contest calls the createContest function, this function could cost a lot of gas if there a ot of players.

Vulnerability Details

In the constructor of Pot in Pot.sol when the contract is deployed a loop is ran to assign rewards to players.

  • if the number of players are a lot this loop will run for a very large number of time which will cost a lot of gas

constructor(address[] memory players, uint256[] memory rewards, IERC20 token, uint256 totalRewards) {
i_players = players;
i_rewards = rewards;
i_token = token;
i_totalRewards = totalRewards;
remainingRewards = totalRewards;
i_deployedAt = block.timestamp;
// i_token.transfer(address(this), i_totalRewards);
for (uint256 i = 0; i < i_players.length; i++) {
playersToRewards[i_players[i]] = i_rewards[i];
}
}

Impact

Cost a lot to create contest

Tools Used

Manual Reveiw

Recommendations

A better method can be used for players to claim, e.g. merkle trees

Updates

Lead Judging Commences

equious Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Unbound for loop in Contest Creation

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.