Skip to content

[PERF] Replace Mapping(address => bool) with Compact Bitmap Storage #632

Description

@mijinummi

Labels: medium-difficulty, solidity, bitmaps, gasguard
Difficulty: Medium
Module: contracts/data/


🧠 Concept

Replace standard mapping(uint256 => bool) or mapping(address => bool) structures with bitwise Bitmap libraries to store 256 boolean flags per storage slot.

⚠️ Problem

Using full 32-byte storage slots to track single boolean states (20,000 gas per new slot) creates excessive storage bloat.

📁 Implementation Scope

  • contracts/data/BitmapTracker.sol
  • test/data/BitmapTracker.test.ts

🛠️ Requirements

  1. Integrate OpenZeppelin BitMaps.sol or custom Yul bit-shift operations.
  2. Store operational flags, processed nonces, and user claims using bitmap offset indexes.
  3. Provide isSet(uint256 index) and set(uint256 index) helper routines.

🎯 Acceptance Criteria

  • Storage cost for nonces/claims drops significantly after initial slot warm-up.
  • Bitwise operations verify boolean status accurately.

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