Description
According to the doc
Horses must be able to be fed at all times.
However, the code checks if the timestamp is a multiple of 17 (0x11) and reverts if this is the case.
#define macro FEED_HORSE() = takes (0) returns (0) {
...
0x11 timestamp mod
endFeed jumpi
revert
endFeed:
stop
}
Impact
Horses can't be fed at all times, which doesn't respect the documentation.
Proof of concept
function testFeedingHorseUpdatesTimestamps(uint256 timestamp) public {
uint256 horseId = horseStore.totalSupply();
vm.prank(user);
horseStore.mintHorse();
vm.warp(timestamp);
vm.roll(timestamp);
uint256 lastFedTimeStamp = block.timestamp;
horseStore.feedHorse(horseId);
uint256 recordedLastFedTimeStamp = horseStore.horseIdToFedTimeStamp(horseId);
assertEq(recordedLastFedTimeStamp, lastFedTimeStamp);
}
results in
Running 6 tests for test/HorseStoreHuff.t.sol:HorseStoreHuff
[FAIL. Reason: EvmError: Revert; counterexample: calldata=0x3fc2d716ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]] testFeedingHorseUpdatesTimestamps(uint256) (runs: 263, μ: 106029, ~: 106029)
with the timestamp being a multiple of 17
>>> 115792089237316195423570985008687907853269984665640564039457584007913129639935 % 17
0
Recommended mitigation
Remove the lines causing the FEED_HORSE
function to revert depending on the timestamp
// End execution
- 0x11 timestamp mod
- endFeed jumpi
- revert
- endFeed:
stop