Skip to content

Conversation

@mtabasco
Copy link
Contributor

Overview

This PR introduces a bitmask-based feature flags mechanism to the StrategyManager module, allowing the DAO (contract owner) to enable or disable key on-chain functionality in bulk—without a full contract redeploy.

Key benefits:

  • Compact storage: Packs multiple booleans into a single uint32.
  • Gas-efficient: Minimal overhead for checking and updating flags.
  • Emergency control: Rapidly disable critical operations if needed.

Changes

  1. New constants & storage

    uint32 private constant SLASHING_DISABLED    = 1 << 0;
    uint32 private constant WITHDRAWALS_DISABLED = 1 << 1;
    // Added `uint32 disabledFeatures` in `ProtocolStorageLib.Data`
  2. DAO-only toggle

    function updateDisabledFeatures(uint32 disabledFeatures) external onlyOwner;
    • Bulk updates all feature flags in one call.
  3. Runtime guards

    • checkSlashingAllowed() in slash(...) → reverts SlashingDisabled() if bit 0 set.
    • checkWithdrawalsAllowed() in withdrawal functions → reverts WithdrawalsDisabled() if bit 1 set.
  4. Spec documentation

    • Added Feature Flags in StrategyManager spec outlining bit layout, purpose, and usage.
  5. Test coverage

    • New unit tests ensure:
      • Slashing disabled only → slash reverts, withdrawals still work.
      • Withdrawals disabled only → withdrawal calls revert, slashing works.
      • Both disabled → both families revert.
      • Clearing flags restores functionality.

Testing

All new logic is covered in StrategyManagerTest:

  • Toggle each bit individually and verify expected reverts or successes.
  • Bulk toggle combinations.

Security & Governance

  • Access: Only the DAO (owner) may call updateFeatureDisabledFlags.
  • Bulk toggles: No per-feature transaction overhead; simpler governance process.

Future Work

  • Reserve bits 2–31 for new toggles (e.g., new feature launches, global pause).

@mtabasco
Copy link
Contributor Author

pending to adapt deployment scripts for different environments in another PR

@mtabasco mtabasco changed the base branch from main to develop April 23, 2025 11:27
@mtabasco mtabasco merged commit cbef692 into develop Apr 23, 2025
3 checks passed
@mtabasco mtabasco deleted the feature/feature-flags branch April 23, 2025 11:50
mtabasco added a commit that referenced this pull request Jun 18, 2025
* Support Delayed Token Update (#40)
* Feature deactivation on demand (#42)
* feat: update adjust percentage formula and optimizations
* Updated deployment scripts (#45)
* Release/v0.1.0 (#46)
* Fix: Propose Obligation Update (#73)
* fix(obligationRequests): set correct storage location
* chore: add v0.1.1 fix deployment metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants