Skip to content

Commit

Permalink
Add NatSpec graphs for state transitions and proposal lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Psirex committed Dec 24, 2024
1 parent 0daf99b commit 33a586c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
23 changes: 19 additions & 4 deletions contracts/EmergencyProtectedTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,25 @@ import {TimelockState} from "./libraries/TimelockState.sol";
import {ExecutableProposals} from "./libraries/ExecutableProposals.sol";
import {EmergencyProtection} from "./libraries/EmergencyProtection.sol";

/// @title EmergencyProtectedTimelock
/// @dev A timelock contract with emergency protection functionality. The contract allows for submitting, scheduling,
/// and executing proposals, while providing emergency protection features to prevent unauthorized execution during
/// emergency situations.
/// @notice Timelock contract facilitating the submission, scheduling, and execution of governance proposals.
/// It provides time-limited Emergency Protection to prevent the execution of proposals submitted by
/// a compromised or misbehaving (including those caused by code vulnerabilities) governance entity.
/// @dev The proposal lifecycle:
///
/// afterSubmitDelay afterScheduleDelay
/// passed passed
/// ┌──────────┐ ┌───────────┐ ┌───────────┐ ╔══════════╗
/// │ NotExist ├ submit() ─>│ Submitted ├ schedule() ─>│ Scheduled ├ execute() ─>║ Executed ║
/// └──────────┘ └────────┬──┘ └──┬────────┘ ╚══════════╝
/// cancelAllNonExecutedProposals()
/// │ ╔═══════════╗ │
/// └──>║ Cancelled ║<───┘
/// ╚═══════════╝
///
/// The afterSubmit and afterSchedule delays must be configured appropriately to provide the Emergency Activation
/// Committee sufficient time to activate Emergency Mode if a malicious proposal has been submitted or was
/// unexpectedly scheduled for execution due to governance capture or a vulnerability in the governance contract.
/// While Emergency Mode is active, the execution of proposals is restricted to the Emergency Execution Committee.
contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
using TimelockState for TimelockState.Context;
using ExecutableProposals for ExecutableProposals.Context;
Expand Down
20 changes: 19 additions & 1 deletion contracts/libraries/DualGovernanceStateTransitions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@ import {DualGovernanceConfig} from "./DualGovernanceConfig.sol";
import {State, DualGovernanceStateMachine} from "./DualGovernanceStateMachine.sol";

/// @title Dual Governance State Transitions Library
/// @notice Library containing the transitions logic for the Dual Governance system
/// @notice Library containing the transition logic for the Dual Governance system.
/// @dev The graph of the state transitions:
///
/// ┌─────────────┐ ┌──────────────────┐
/// │ Normal ├────>│ VetoSignalling │<───────┐
/// ┌─>│ [SUB, EXE] │ │ [SUB] │<────┐ │
/// │ └─────────────┘ │ ┌──────────────┐ │ │ │
/// │ ┌──┼─┤ Deactivation ├─┼──┐ │ │
/// │ │ │ │ [ ] │ │ │ │ │
/// │ │ │ └──────────────┘ │ │ │ │
/// │ │ └──────────────────┘ │ │ │
/// │ ┌──────────────┐ │ ┌──────────┐ │ │ │
/// └──┤ VetoCooldown │<┘ │ RageQuit │<──────┘ │ │
/// │ [EXE] │<──────┤ [SUB] │<─────────┘ │
/// └──────┬───────┘ └──────────┘ │
/// └────────────────────────────────────────┘
///
/// SUB - Allows proposals submission while the state is active.
/// EXE - Allows scheduling proposals for execution while the state is active.
library DualGovernanceStateTransitions {
using DualGovernanceConfig for DualGovernanceConfig.Context;

Expand Down

0 comments on commit 33a586c

Please sign in to comment.