Skip to content

[PERF] Compress Contract Configuration Flags into a Single Storage Slot #734

Description

@mijinummi

Labels: medium-difficulty, solidity, storage-packing, gasguard
Difficulty: Medium
Module: contracts/config/


🧠 Concept

Refactor multiple individual boolean configuration state variables (bool isPaused, bool isLocked, bool allowPublic) into a single bytes32 bitmask variable.

⚠️ Problem

Using individual bool state variables allocates multiple 32-byte storage slots (or requires complex struct packing), incurring multiple SLOAD operations during execution.

📁 Implementation Scope

  • contracts/config/BitmaskConfig.sol
  • test/config/BitmaskConfig.test.ts

🛠️ Requirements

  1. Define bit-flag offsets (uint256 constant PAUSED_BIT = 1 << 0, etc.).
  2. Implement inline assembly getters and setters to check and set individual bits within a single bytes32 storage slot.

🎯 Acceptance Criteria

  • All operational flags fit into a single storage slot.
  • Queries and toggles operate using low-gas bitwise operators (AND, OR, XOR).

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