Inconsistent HorseStore.isHappyHorse
between 2 contract versions
HorseStore.isHappyHorse
should return true if a horse is happy, when it was fed in within the last 24h. But, there are differences between the 2 contract versions:
Solidity version uses <=
to compare fed time and timestamp 24 ago
Huff version uses lt
or <=
to compare 1 day in seconds and the time pass since fed and .
This creates inconsistencies when calling the function at:
t = fed time + 24hours - 1 sec: Huff version will return false
while solidity version will return true
t = fed time + 24hours : Both return false
t = fed time + 24hours + 1 sec: Huff version will return true
while solidity version will return false
The solidity version mistakingly compares horseIdToFedTimeStamp[horseId] <= block.timestamp - HORSE_HAPPY_IF_FED_WITHIN
, it should be >=
The Huff version returns true if 24h < timestamp - horseFedTimestamp
or timestamp == horseFedTimestamp
Even thought the logic is completely useless, as it not returning correctly if horse is happy, the values returned should be the same between both versions.
HIGH. Invariant broken, both contract should behave the same.
Manual review, Foundry.
Consider adjusting the timestamp check, to make sure that it only returns true if:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.