Puppy Raffle

AI First Flight #1
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Unused Internal Function _isActivePlayer() Wastes Gas

Root + Impact

Description

  • The _isActivePlayer() function is defined but never used anywhere in the contract. This adds unnecessary bytecode to the contract, increasing deployment costs. Additionally, the function has a linear O(n) complexity which would be inefficient if it were used.

// Root cause in the codebase with @> marks to highlight the relevant section
function _isActivePlayer() internal view returns (bool) {
for (uint256 i = 0; i < players.length; i++) {
if (players[i] == msg.sender) {
return true;
}
}
return false;
}

Risk

Likelihood:

Deployment gas cost is slightly higher due to unused bytecode.

  • No security impact (function is internal and not called).

  • Removing it will reduce contract size and save deployment gas.

Impact:

  • Increased deployment gas costs due to unused bytecode. No functional impact since the function is never called

Proof of Concept

This PoC demonstrates that the function is never called, so it has no functional impact but increases contract size and deployment gas.

function _isActivePlayer() internal view returns (bool) {
for (uint256 i = 0; i < players.length; i++) {
if (players[i] == msg.sender) {
return true;
}
}
return false;
}

Recommended Mitigation

Remove the unused function to save gas and reduce contract size:

- remove this code
+ add this code
diff --git a/contracts/PuppyRaffle.sol b/contracts/PuppyRaffle.sol
index abc1234..def5678 100644
--- a/contracts/PuppyRaffle.sol
+++ b/contracts/PuppyRaffle.sol
@@ -164,8 +164,6 @@ contract PuppyRaffle is ERC721, Ownable {
- function _isActivePlayer() internal view returns (bool) {
- for (uint256 i = 0; i < players.length; i++) {
- if (players[i] == msg.sender) {
- return true;
- }
- }
- return false;
- }
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 3 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!