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

Different horse happiness intervals between huff and solidity versions

Summary

There is a difference between how quickly the horse becomes unhappy in the huff and solidity versions.

Vulnerability Details

The solidity version is 1 day whereas the huff version is 15180 seconds which is not one day

https://github.com/Cyfrin/2024-01-horse-store/blob/8255173c9340c12501881c9ecdd4175ff7350f5d/src/HorseStore.huff#L36

Paste this into Base_Test.t.sol and you will see that the huff version fails.

function testHuffVsSolidityHorseHappy() public {
uint256 horseId = horseStore.totalSupply();
vm.warp(horseStore.HORSE_HAPPY_IF_FED_WITHIN());
vm.roll(horseStore.HORSE_HAPPY_IF_FED_WITHIN());
vm.prank(user);
horseStore.mintHorse();
//feed horse
horseStore.feedHorse(horseId);
//horse happy
assertEq(horseStore.isHappyHorse(horseId), true);
// warp time to less than 1 day
vm.warp(block.timestamp + horseStore.HORSE_HAPPY_IF_FED_WITHIN() / 2);
assertEq(horseStore.isHappyHorse(horseId), true);
}

Impact

Horse becomes unhappy more quickly but not that big a deal so medium risk.

Tools Used

Foundry

Recommendations

Adjust the huff version to match solidity - 86400 seconds

#define constant HORSE_HAPPY_IF_FED_WITHIN_CONST = 0x0000000000000000000000000000000000000000000000000000000000086400 // 1 days
Updates

Lead Judging Commences

inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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