Raisebox Faucet

First Flight #50
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: medium
Invalid

L02. Unnecessary Persistent State Variable (faucetClaimer) Increases Gas Cost and Creates Maintenance Risk

Root + Impact

Description

  • The claimFaucetTokens() function assigns msg.sender to a persistent state variable faucetClaimer at the start of every call.

  • Normally, msg.sender is used as a local variable within the function since its value changes per transaction and does not need to persist in storage.

  • Storing msg.sender in contract storage leads to unnecessary gas consumption (an SSTORE operation) and introduces a minor logical risk if future code relies on this global variable outside of its intended context.

function claimFaucetTokens() public {
// Checks
@> faucetClaimer = msg.sender; // Unnecessary state write operation
...
}

Risk

Likelihood:

  • The issue occurs every time claimFaucetTokens() is called, since the function always writes to storage.

  • Any future extension that references faucetClaimer outside of this function could incorrectly use an outdated value.

Impact:

  • Each call performs a redundant SSTORE (≈20,000 gas if storage is updated from zero, or 5,000 gas if overwriting nonzero data), increasing user gas costs per claim.

  • Future contract updates that depend on faucetClaimer risk referencing a stale or incorrect address, causing functional confusion or incorrect event attribution.

Proof of Concept

function testClaimGasUsage() public {
uint256 gasStart = gasleft();
raiseBoxFaucet.claimFaucetTokens();
uint256 gasUsed = gasStart - gasleft();
console.log("Gas used:", gasUsed);
}
// Removing faucetClaimer assignment would reduce gas usage by up to ~20,000 units per call.

Explanation:
Every call to claimFaucetTokens() writes msg.sender to contract storage. Since this value is not reused anywhere else, it introduces an unnecessary gas overhead and modifies global state on each claim execution.

Recommended Mitigation

- faucetClaimer = msg.sender;
+ address faucetClaimer = msg.sender;

This change converts the variable into a local variable, preserving the same functionality while eliminating redundant storage operations and lowering gas costs.

Updates

Lead Judging Commences

inallhonesty Lead Judge 9 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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