We advise the code to be refactored, permitting users to gradually catch up to the latest cycle.
As an example implementation to achieve this, the system could store the latest cycle index that was claimed in lastClaim (i.e. renamed to lastClaimIndex) and permit the user to specify the number of cycles they wish to iterate and claim.
Such a mechanism would permit the RevenueStreamETH::claimETH function to be invoke-able regardless of how many cycles have elapsed as the user could iterate f.e. 100 at a time.
RSE-04M: Unscalable Revenue System
Description:
The structure of the
RevenueStreamETH::_claimable
andRevenueStreamETH::_checkForExpiredRevenue
functions prevent the system from scaling, potentially resulting in inoperable functions if many cycles are introduced (for expiry) or are left unclaimed (for users).Impact:
Revenue will become permanently unclaimable if multiple cycles elapse due to a claim transaction breaching the block gas limit.
Similarly, expired revenue will be impossible to clear as the loop always starts at
1
.Example:
Recommendation:
We advise the code to be refactored, permitting users to gradually catch up to the latest cycle.
As an example implementation to achieve this, the system could store the latest cycle index that was claimed in
lastClaim
(i.e. renamed tolastClaimIndex
) and permit the user to specify the number of cycles they wish to iterate and claim.Such a mechanism would permit the
RevenueStreamETH::claimETH
function to be invoke-able regardless of how many cycles have elapsed as the user could iterate f.e.100
at a time.Identically, the
RevenueStreamETH::_checkForExpiredRevenue
should store the last cycle that was "expired" and continue from there with the same approach.