Skip to content

Commit

Permalink
Merge pull request #127 from lidofinance/feature/pending-dg-state
Browse files Browse the repository at this point in the history
Pending DualGovernance state
  • Loading branch information
Psirex authored Sep 27, 2024
2 parents 8296824 + a3e6a8e commit 1ffa251
Show file tree
Hide file tree
Showing 22 changed files with 2,513 additions and 364 deletions.
321 changes: 245 additions & 76 deletions contracts/DualGovernance.sol

Large diffs are not rendered by default.

163 changes: 98 additions & 65 deletions contracts/EmergencyProtectedTimelock.sol

Large diffs are not rendered by default.

232 changes: 187 additions & 45 deletions contracts/Escrow.sol

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion contracts/TimelockedGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ contract TimelockedGovernance is IGovernance {
}

/// @dev Cancels all pending proposals that have not been executed.
function cancelAllPendingProposals() external {
function cancelAllPendingProposals() external returns (bool) {
_checkCallerIsGovernance();
TIMELOCK.cancelAllNonExecutedProposals();
return true;
}

/// @dev Checks if the msg.sender is the governance address.
Expand Down
5 changes: 3 additions & 2 deletions contracts/committees/EmergencyActivationCommittee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Durations} from "../types/Duration.sol";
import {Timestamp} from "../types/Timestamp.sol";

import {ITimelock} from "../interfaces/ITimelock.sol";
import {IEmergencyProtectedTimelock} from "../interfaces/IEmergencyProtectedTimelock.sol";

import {HashConsensus} from "./HashConsensus.sol";

Expand Down Expand Up @@ -54,7 +54,8 @@ contract EmergencyActivationCommittee is HashConsensus {
function executeActivateEmergencyMode() external {
_markUsed(EMERGENCY_ACTIVATION_HASH);
Address.functionCall(
EMERGENCY_PROTECTED_TIMELOCK, abi.encodeWithSelector(ITimelock.activateEmergencyMode.selector)
EMERGENCY_PROTECTED_TIMELOCK,
abi.encodeWithSelector(IEmergencyProtectedTimelock.activateEmergencyMode.selector)
);
}
}
14 changes: 10 additions & 4 deletions contracts/committees/EmergencyExecutionCommittee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Durations} from "../types/Duration.sol";
import {Timestamp} from "../types/Timestamp.sol";

import {ITimelock} from "../interfaces/ITimelock.sol";
import {IEmergencyProtectedTimelock} from "../interfaces/IEmergencyProtectedTimelock.sol";

import {HashConsensus} from "./HashConsensus.sol";
import {ProposalsList} from "./ProposalsList.sol";
Expand Down Expand Up @@ -72,14 +72,18 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList {
(, bytes32 key) = _encodeEmergencyExecute(proposalId);
_markUsed(key);
Address.functionCall(
EMERGENCY_PROTECTED_TIMELOCK, abi.encodeWithSelector(ITimelock.emergencyExecute.selector, proposalId)
EMERGENCY_PROTECTED_TIMELOCK,
abi.encodeWithSelector(IEmergencyProtectedTimelock.emergencyExecute.selector, proposalId)
);
}

/// @notice Checks if a proposal exists
/// @param proposalId The ID of the proposal to check
function _checkProposalExists(uint256 proposalId) internal view {
if (proposalId == 0 || proposalId > ITimelock(EMERGENCY_PROTECTED_TIMELOCK).getProposalsCount()) {
if (
proposalId == 0
|| proposalId > IEmergencyProtectedTimelock(EMERGENCY_PROTECTED_TIMELOCK).getProposalsCount()
) {
revert ProposalDoesNotExist(proposalId);
}
}
Expand Down Expand Up @@ -128,7 +132,9 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList {
function executeEmergencyReset() external {
bytes32 proposalKey = _encodeEmergencyResetProposalKey();
_markUsed(proposalKey);
Address.functionCall(EMERGENCY_PROTECTED_TIMELOCK, abi.encodeWithSelector(ITimelock.emergencyReset.selector));
Address.functionCall(
EMERGENCY_PROTECTED_TIMELOCK, abi.encodeWithSelector(IEmergencyProtectedTimelock.emergencyReset.selector)
);
}

/// @notice Encodes the proposal key for an emergency reset
Expand Down
5 changes: 3 additions & 2 deletions contracts/interfaces/IDualGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {State} from "../libraries/DualGovernanceStateMachine.sol";

interface IDualGovernance is IGovernance, ITiebreaker {
struct StateDetails {
State state;
Timestamp enteredAt;
State effectiveState;
State persistedState;
Timestamp persistedStateEnteredAt;
Timestamp vetoSignallingActivatedAt;
Timestamp vetoSignallingReactivationTime;
Timestamp normalOrVetoCooldownExitedAt;
Expand Down
3 changes: 3 additions & 0 deletions contracts/interfaces/IEmergencyProtectedTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface IEmergencyProtectedTimelock is ITimelock {
Timestamp emergencyProtectionEndsAfter;
}

function activateEmergencyMode() external;
function emergencyExecute(uint256 proposalId) external;
function emergencyReset() external;
function getEmergencyGovernance() external view returns (address emergencyGovernance);
function getEmergencyActivationCommittee() external view returns (address committee);
function getEmergencyExecutionCommittee() external view returns (address committee);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface IGovernance {
string calldata metadata
) external returns (uint256 proposalId);
function scheduleProposal(uint256 proposalId) external;
function cancelAllPendingProposals() external;
function cancelAllPendingProposals() external returns (bool);

function canScheduleProposal(uint256 proposalId) external view returns (bool);
}
9 changes: 2 additions & 7 deletions contracts/interfaces/ITimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ interface ITimelock {
function canExecute(uint256 proposalId) external view returns (bool);

function getAdminExecutor() external view returns (address);
function getGovernance() external view returns (address);
function setGovernance(address governance) external;

function getProposal(uint256 proposalId)
external
view
returns (ProposalDetails memory proposal, ExternalCall[] memory calls);
function getProposalDetails(uint256 proposalId) external view returns (ProposalDetails memory proposalDetails);

function getGovernance() external view returns (address);
function setGovernance(address governance) external;

function activateEmergencyMode() external;
function emergencyExecute(uint256 proposalId) external;
function emergencyReset() external;
function getProposalsCount() external view returns (uint256 count);
}
Loading

0 comments on commit 1ffa251

Please sign in to comment.