Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Missing events in `HuffStore.sol::feedHorse` and `HuffStore.huff::FEED_HORSE`

Description

Both HuffStore.sol::feedHorse and HuffStore.huff::FEED_HORSE update the mapping containing horse and their feeding time. It is crucial to emit an event when a state change occurs in a contract to provide off-chain visibility.

Impact

Lack of visibility off-chain when a horse is fed.

Recommended Mitigation

Add events as shown in the examples below:

HuffStore.sol
+ event HorseIsFed(uint256 indexed horseId, uint256 indexed timestamp);
.
.
.
function feedHorse(uint256 horseId) external {
horseIdToFedTimeStamp[horseId] = block.timestamp;
+ emit HorseIsFed(horseId, block.timestamp);
}
Foundry PoC
+#define event HorseIsFed(uint256 indexed, uint256 indexed)
.
.
.
#define macro FEED_HORSE() = takes (0) returns (0) {
timestamp // [timestamp]
0x04 calldataload // [horseId, timestamp]
STORE_ELEMENT(0x00) // []
// End execution
0x11 timestamp mod
endFeed jumpi
revert
endFeed:
+ timestamp // [timestamp]
+ 0x04 calldataload // [horseId, timestamp]
+ __EVENT_HASH(HorseIsFed) // [sig, horseId, timestamp]
+ 0x40 0x00 // [offset, size, sig, horseId, timestamp]
+ log3
stop
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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