The withdrawalBatches array in the WithdrawalPool contract grows indefinitely as new withdrawal batches are added, without a mechanism to remove old, processed batches. This could result in increasing gas costs and inefficiencies over time as the array expands, particularly impacting later transactions that need to interact with this array.
The issue occurs within the WithdrawalPool contract, where the withdrawalBatches array stores information about each batch of processed withdrawals. As new withdrawals are added and processed, the array continues to grow without any cleanup of old, completed batches.
The contract lacks a mechanism to remove or clear old, processed entries from the withdrawalBatches array. While the contract does implement a withdrawalBatchIdCutoff to optimize batch processing, it doesn't actually remove old data. This results in continuous state bloat as the array keeps growing with every new withdrawal batch.
Increased Gas Costs: As the withdrawalBatches array grows, operations that interact with this array will consume more gas, particularly for functions that iterate over the entire list.
Storage Bloat: The unbounded growth of the array increases the contract's storage requirements, leading to inefficiencies and potentially higher operational costs.
Scalability Issues: Over time, as more withdrawal batches are processed, the contract's performance may degrade, making it harder to manage and maintain.
The likelihood of this issue impacting the system is high, especially in scenarios where the contract processes frequent withdrawals over an extended period. Each withdrawal batch adds to the withdrawalBatches array, making it increasingly likely that gas costs will rise and the contract will face scalability challenges.
Implement a Batch Cleanup Mechanism: Introduce a function to remove or clean up old, fully processed batches from the withdrawalBatches array once they are no longer needed.
Optimize Storage: Consider restructuring the array to limit growth, either by reusing slots or using more efficient data structures that allow for removal of old entries.
Batch Removal on Cutoff Update: When updating withdrawalBatchIdCutoff, old batches before the cutoff can be deleted or pruned to prevent unnecessary growth.
By implementing these recommendations, the contract can avoid unbounded storage growth and maintain efficiency in the long run.
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.