stake.link

stake.link
DeFiHardhatBridge
27,500 USDC
View results
Submission Details
Severity: low
Valid

Audit Report for SDLPool.sol - Scalability Concern

Summary

This report highlights a potential scalability issue in the SDLPool.sol smart contract, specifically within the getLockIdsByOwner function. The current storage and retrieval method for lock IDs will become increasingly expensive over time.

Vulnerability Details

In SDLPool.sol:177, the getLockIdsByOwner function iterates through all lock IDs from 1 to lastLockId to determine which locks belong to a specific owner. This approach, while functional, becomes inefficient as the number of lock IDs grows, leading to increased gas costs and slower execution times.

Impact

The linear search methodology employed in the function poses the following risks:

  1. High Gas Costs: As the lastLockId increases, the cost of iterating through all lock IDs grows, resulting in expensive read operations.

  2. Scalability Issues: The function's performance degrades over time as the dataset grows, potentially making it impractical or too costly to use in the long term.

  3. Reduced User Experience: Slower execution times and higher costs can negatively impact the user experience, especially for accounts with a large number of locks.

Since the protocol itself doesn't use the function there is no risk of it affecting it but being a user facing function is it worth to be aware of it.

Tools Used

Manual Review

Recommendations

To address these issues, consider implementing a more efficient storage solution:

  • Indexing Locks by Owner: Maintain a mapping of owner addresses to an array of their lock IDs. This approach enables direct access to an owner's locks without iterating through the entire dataset.

Updates

Lead Judging Commences

0kage Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

unbounded-locks

getLockIdsByOwner could be very gas intensive and revert

Support

FAQs

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