Skip to content

[RULE] Rule G009: Detect Redundant Double Storage Writes (SSTORE) #657

Description

@mijinummi

Labels: medium-difficulty, gasguard-rules, static-analysis, gasguard
Difficulty: Medium
Module: rules/g009_redundant_sstore.rs


🧠 Concept

Develop rule G009 to detect multiple writes (SSTORE) to the same storage variable within a single execution path before final state settlement.

⚠️ Problem

Updating a state variable multiple times within a single function call burns unnecessary gas when only the final state update needs to be persisted.

📁 Implementation Scope

  • rules/g009_redundant_sstore.rs
  • test/fixtures/g009_samples.sol

🛠️ Requirements

  1. Analyze control flow graphs to track state variable assignments.
  2. Flag cases where a variable is written, overridden, or updated multiple times prior to function exit without intermediate external reads.

🎯 Acceptance Criteria

  • Successfully flags redundant state variable writes.
  • Recommends holding intermediate values in stack variables prior to a single final SSTORE.

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