Labels: medium-difficulty, gasguard-rules, ast, gasguard
Difficulty: Medium
Module: rules/g014_storage_array_length.rs
🧠 Concept
Implement rule G014 to detect storage dynamic array reads where .length is queried directly from storage inside execution loops or repeated conditions.
⚠️ Problem
Reading the length of a storage array (storageArray.length) issues an SLOAD opcode on every query, costing $2,100\text{ gas}$ (cold) or $100\text{ gas}$ (warm).
📁 Implementation Scope
rules/g014_storage_array_length.rs
test/fixtures/g014_samples.sol
🛠️ Requirements
- Identify storage array variable references evaluating
.length.
- Check if the evaluation occurs inside a loop or conditional block without stack assignment.
- Emit actionable warning recommending stack caching.
🎯 Acceptance Criteria
Labels:
medium-difficulty,gasguard-rules,ast,gasguardDifficulty: Medium
Module:
rules/g014_storage_array_length.rs🧠 Concept
Implement rule
G014to detect storage dynamic array reads where.lengthis queried directly from storage inside execution loops or repeated conditions.Reading the length of a storage array ($2,100\text{ gas}$ (cold) or $100\text{ gas}$ (warm).
storageArray.length) issues anSLOADopcode on every query, costing📁 Implementation Scope
rules/g014_storage_array_length.rstest/fixtures/g014_samples.sol🛠️ Requirements
.length.🎯 Acceptance Criteria