Skip to content

[RULE] Rule G023: Flag Unused Capacity Allocations in Memory Arrays #740

Description

@mijinummi

Labels: good-first-issue, gasguard-rules, solidity, gasguard
Difficulty: Easy
Module: rules/g023_memory_array_allocation.rs


🧠 Concept

Add static rule G023 to detect memory array declarations initialized with large fixed sizes that are only partially populated during execution.

⚠️ Problem

Allocating memory arrays with oversized initial lengths expands the free memory space prematurely, triggering unnecessary memory expansion gas fees.

📁 Implementation Scope

  • rules/g023_memory_array_allocation.rs
  • test/fixtures/g023_samples.sol

🛠️ Requirements

  1. Analyze memory array allocations (new uint256[](size)).
  2. Cross-reference initialized length against maximum loop bounds populated in the function scope.
  3. Flag over-allocated array declarations.

🎯 Acceptance Criteria

  • Flags memory array allocations exceeding maximum population bounds.
  • Passes cleanly when memory array size matches populate bounds.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions