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

Wrong documentation in `HorseStore.huff::GET_HORSE_FED_TIMESTAMP`

Description

The documentation in GET_HORSE_FED_TIMESTAMP incorrectly indicates that GET_SLOT_FROM_KEY returns the timestamp when the horse is fed. In reality, it returns the slot where this information is stored. Sload reads from the slot and places the timestamp information on the stack. The documentation suggests that the stack is empty at this point, which is not true. In addition, using mstore requires two elements on the stack to work.

#define macro GET_HORSE_FED_TIMESTAMP() = takes (0) returns (0) {
0x04 calldataload // [horseId]
@> GET_SLOT_FROM_KEY(0x00) // [horseFedTimestamp]
@> sload // []
0x00 mstore // [] Store value in memory.
0x20 0x00 return // Returns what's in memory
}

Impact

Huff is already a low-level language with inherent complexity. Incorrect documentation will confuse a developer or an auditor.

Recommended Mitigation

Here is a more relevant documentation:

#define macro GET_HORSE_FED_TIMESTAMP() = takes (0) returns (0) {
0x04 calldataload // [horseId]
- GET_SLOT_FROM_KEY(0x00) // [horseFedTimestamp]
- sload // []
+ GET_SLOT_FROM_KEY(0x00) // [SlotForHorseFedTimestamp]
+ sload // [horseFedTimestamp]
0x00 mstore // [] Store value in memory.
0x20 0x00 return // Returns what's in memory
}
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.