Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: low
Valid

Suboptimal Array Sizing in `_distributeToGauges`

Summary

The _distributeToGauges function allocates a fixed-size array matching _gaugeList.length, regardless of how many gauges are actually active. This implementation creates unnecessary memory overhead when working with partially active gauge lists.

Vulnerability Details

The current implementation pre-allocates memory for all possible gauges:

uint256[] memory gaugeWeights = new uint256[](_gaugeList.length);

This approach reserves memory space for every gauge in _gaugeList, even though only active gauges require storage. When dealing with lists containing numerous inactive gauges, this creates unnecessary memory bloat.

Impact

  • Excessive gas consumption from over-allocation of memory

  • Inefficient resource utilization, particularly noticeable in scenarios with a low ratio of active to total gauges

Tools Used

  • Manual code review

Recommendations

  • Implement dynamic array allocation to store only active gauge weights:

  • Consider using a mapping structure to eliminate excess memory allocation

uint256[] memory gaugeWeights;
for (uint256 i = 0; i < _gaugeList.length; i++) {
address gauge = _gaugeList[i];
if (gauges[gauge].isActive && gauges[gauge].gaugeType == gaugeType) {
gaugeWeights.push(gauges[gauge].weight);
totalTypeWeight += gauges[gauge].weight;
}
}

This revised approach using push() ensures memory allocation aligns with the actual number of active gauges, leading to improved gas efficiency and better resource management.

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

GaugeController._distributeToGauges iterates twice over unbounded gauges list without error handling, causing DoS risk from out-of-gas or single gauge revert

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

GaugeController._distributeToGauges iterates twice over unbounded gauges list without error handling, causing DoS risk from out-of-gas or single gauge revert

Support

FAQs

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