Skip to content
DoS Audit finding Intermediate

Gas Inefficiency in Loop Storage Reads _processMaturedCooldowns

The _processMaturedCooldowns function performs repeated storage reads inside a loop over a user's associated validators, causing unnecessary gas costs. An attacker or power user with many validator associations could face prohibitively high gas fees when processing cooldowns, limiting scalability.

Opzteam Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

49639 sc insight gas inefficiency in loop storage reads processmaturedcooldowns

Submitted on Jul 17th 2025 at 20:24:34 UTC by @Opzteam for Attackathon | Plume Network

Impacts

(As provided in the original report.)

Description

The _processMaturedCooldowns function performs multiple storage reads within loops, creating gas inefficiencies for users with many validator associations.

Example snippet:

Solidity
// File: contracts-src/facets/StakingFacet.sol:854-871
for (uint256 i = 0; i < userAssociatedValidators.length; i++) {
    uint16 validatorId = userAssociatedValidators[i];
    PlumeStakingStorage.CooldownEntry memory cooldownEntry = $.userValidatorCooldowns[user][validatorId];
    // ... multiple storage reads follow
    if ($.userValidatorStakes[user][validatorId].staked == 0) {
        // ... more storage access
    }
}
  • Batch load data before loop execution to minimize storage reads.
  • Users with many validator associations face significantly higher gas costs during cooldown processing operations, potentially making the protocol prohibitively expensive for power users and creating scalability limitations.

Proof of Concept

Implement batch loading by pre-fetching validator states and user stakes into memory arrays before loop execution, reducing per-iteration storage access from O(n) to O(1) for repeated data.

Example approach:

Solidity
// Batch load all data once
struct BatchData {
    uint256[] cooldownAmounts;
    bool[] validatorExists;
    bool[] validatorSlashed;
    uint256[] userStakes;
}

BatchData memory batch = _loadBatchData(user, userAssociatedValidators);

for (uint256 i = 0; i < userAssociatedValidators.length; i++) {
    // Use memory data instead of storage reads
    if (batch.cooldownAmounts[i] == 0) continue;
    
    bool canRecover = _canRecoverOptimized(batch.validatorExists[i], batch.validatorSlashed[i]);
    
    if (canRecover && batch.userStakes[i] == 0) {
        PlumeValidatorLogic.removeStakerFromValidator($, user, validatorId);
    }
}

Reported gas savings: Total: 50-70% gas reduction for multi-validator users.

The original report as published on Immunefi, by Opzteam. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

Users with many validator associations could face significantly higher gas costs during cooldown processing, potentially making the protocol prohibitively expensive for power users and creating scalability limitations.

What the attacker needed

User has many validator associations

The fix

The function should be refactored to batch-load validator states and user stakes into memory arrays before the loop, reducing repeated storage reads.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Smart contracts on blockchains charge a fee called gas for every operation, and reading data from permanent storage is expensive. This report points out that a function reads the same kind of data from storage over and over inside a loop, which wastes gas. The suggested fix is to read all needed data once into temporary memory before the loop, then use that copy.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by Opzteam

View all

6 more disclosed reports, best first.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.