Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

Missing event emission in `EggHuntGame::setEggFindThreshold` function

Summary

The setEggFindThreshold function allows the contract owner to change the eggFindThreshold state variable, which dictates the probability of finding an egg. However, this function does not emit an event upon successful execution.

Vulnerability Details

State-changing functions, especially those modifying critical parameters like the chance to find an egg, should emit events. This allows off-chain monitoring tools, user interfaces, and other interested parties to track changes in the contract's state without having to constantly poll the contract's storage. The setEggFindThreshold function updates the eggFindThreshold variable but lacks an accompanying event emission.

/// @notice Allows the owner to adjust the egg-finding chance.
function setEggFindThreshold(uint256 newThreshold) external onlyOwner {
require(newThreshold <= 100, "Threshold must be <= 100");
eggFindThreshold = newThreshold;
}

Impact

The absence of an event makes it difficult for external systems and users to track changes to the egg finding probability. This lack of transparency can lead to confusion for players or issues for applications relying on this parameter, as they might operate based on outdated information.

Tools Used

Manual Review

Recommendations

Emit an event within the setEggFindThreshold function to signal the change in the threshold.

  1. Define a new event, for example:

    event EggFindThresholdUpdated(uint256 newThreshold);
  2. Emit this event within the setEggFindThreshold function after the update:

    function setEggFindThreshold(uint256 newThreshold) external onlyOwner {
    require(newThreshold <= 100, "Threshold must be <= 100");
    eggFindThreshold = newThreshold;
    emit EggFindThresholdUpdated(newThreshold); // Add this line
    }
Updates

Lead Judging Commences

m3dython Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Event Emission

Standard practice for clarifying important contract behaviors

Support

FAQs

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