Platform: Code4rena
Start Date: 21/12/2023
Pot Size: $90,500 USDC
Total HM: 10
Participants: 39
Period: 18 days
Judge: LSDan
Total Solo HM: 5
Id: 315
League: ETH
Rank: 31/39
Findings: 1
Award: $21.90
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x11singh99, 0xA5DF, 0xMilenov, 0xTheC0der, 7ashraf, Bauchibred, EV_om, Kaysoft, Sathish9098, SpicyMeatball, cheatc0d3, erebus, hash, imare, immeas, joaovwfreire, lil_eth, lsaudit, oakcobalt, para8956, peanuts, rvierdiiev, slvDev, trachev
21.8971 USDC - $21.90
In the accountOwnerIncentives
function of Tokenomics.sol
pending rewards are only finalized if lastEpoch < curEpoch
. Furthermore, through the checkpoint
function, the current epoch cannot be updated if diffNumSeconds < curEpochLen || diffNumSeconds > ONE_YEAR
.
Therefore, in the edge case that checkpoint
has not been called for a year, all of the donations from the last epoch will be lost as the if
check in accountOwnerIncentives
, responsible for finalizing pending donations, will always return false.
As the chances of this happening are low but the impact would be high, due to the loss of funds, I have decided to mark this issue with medium severity.
Here we can see that _finalizeIncentivesForUnitId
will only get called if the epoch has been updated:
if (lastEpoch > 0 && lastEpoch < curEpoch) { _finalizeIncentivesForUnitId(lastEpoch, unitTypes[i], unitIds[i]); // Change the last epoch number mapUnitIncentives[unitTypes[i]][unitIds[i]].lastEpoch = 0; }
Manual review
Implement a recovery mechanism in accountOwnerIncentives
that checks if the difference of seconds since the last epoch is more than one year. In that case, a call to _finalizeIncentivesForUnitId` should also be made.
Other
#0 - c4-pre-sort
2024-01-10T15:22:39Z
alex-ppg marked the issue as primary issue
#1 - c4-pre-sort
2024-01-10T15:22:43Z
alex-ppg marked the issue as insufficient quality report
#2 - c4-judge
2024-01-19T22:44:23Z
dmvt changed the severity to QA (Quality Assurance)
#3 - c4-judge
2024-01-19T22:44:53Z
dmvt marked the issue as grade-b