Skip to content

[CORE] Rule G015: Automated AST Storage Slot Re-Ordering Transformer #692

Description

@mijinummi

Labels: high-difficulty, rust, ast, gasguard
Difficulty: High
Module: gasguard-cli/src/transformers/


🧠 Concept

Develop an automated refactoring command in the GasGuard CLI that parses contract ASTs, detects un-packed storage variables, and automatically reorders variable declarations to minimize storage slot usage.

⚠️ Problem

Manually reordering state variables to optimize storage layout across large codebases is time-consuming and prone to human error.

📁 Implementation Scope

  • gasguard-cli/src/transformers/storage_packer.rs
  • gasguard-cli/test/fixtures/storage_packing_transform.sol

🛠️ Requirements

  1. Calculate bit sizes for state variables declared in target contract ASTs.
  2. Group sub-32-byte variables together sequentially to fill 256-bit slots.
  3. Output updated Solidity contract source code while preserving inline comments and code formatting.

🎯 Acceptance Criteria

  • Reorders state variable declarations to achieve minimal storage slot usage.
  • Reordered output code compiles cleanly and passes unit tests.

Metadata

Metadata

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