Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Optimization of gas consumption in `WithdrawalPool::getWithdrawalIdsByOwner`

Summary

This function takes the length of activeWithdrawals in the loop, which causes more gas consumption

for (uint256 i = 0; i < activeWithdrawals.length; ++i) {
uint256 withdrawalId = queuedWithdrawalsByAccount[_account][i];
Withdrawal memory withdrawal = queuedWithdrawals[withdrawalId];
if (withdrawal.sharesRemaining != 0 || withdrawal.partiallyWithdrawableAmount != 0) {
activeWithdrawals[i] = withdrawalId;
totalActiveWithdrawals++;
}
}

Vulnerability Details

More gas consumption

Impact

Tools Used

Recommendations

To use less gas, the length of activeWithdrawals can be extended

uint256 totalActiveWithdrawals;
+ uint256 lenghthOfActiveWithdrawals=activeWithdrawals.length;
for (uint256 i = 0; i <lenghthOfActiveWithdrawals ; ++i) {
uint256 withdrawalId = queuedWithdrawalsByAccount[_account][i];
Withdrawal memory withdrawal = queuedWithdrawals[withdrawalId];
if (withdrawal.sharesRemaining != 0 || withdrawal.partiallyWithdrawableAmount != 0) {
activeWithdrawals[i] = withdrawalId;
totalActiveWithdrawals++;
}
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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