Skip to content

Commit

Permalink
Resolve Conflict, take develop branch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
F-WRunTime committed Jul 31, 2024
2 parents 68c00e9 + 3bb434b commit b2ea538
Show file tree
Hide file tree
Showing 56 changed files with 3,147 additions and 1,664 deletions.
53 changes: 29 additions & 24 deletions contracts/Configuration.sol
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {Durations, Duration} from "./types/Duration.sol";
import {IConfiguration, DualGovernanceConfig} from "./interfaces/IConfiguration.sol";

uint256 constant PERCENT = 10 ** 16;

contract Configuration is IConfiguration {
error MaxSealablesLimitOverflow(uint256 count, uint256 limit);

uint256 public immutable MIN_WITHDRAWALS_BATCH_SIZE = 8;
uint256 public immutable MAX_WITHDRAWALS_BATCH_SIZE = 128;

// ---
// Dual Governance State Properties
// ---
uint256 public immutable FIRST_SEAL_RAGE_QUIT_SUPPORT = 3 * PERCENT;
uint256 public immutable SECOND_SEAL_RAGE_QUIT_SUPPORT = 15 * PERCENT;

uint256 public immutable DYNAMIC_TIMELOCK_MIN_DURATION = 3 days;
uint256 public immutable DYNAMIC_TIMELOCK_MAX_DURATION = 30 days;
Duration public immutable DYNAMIC_TIMELOCK_MIN_DURATION = Durations.from(3 days);
Duration public immutable DYNAMIC_TIMELOCK_MAX_DURATION = Durations.from(30 days);

uint256 public immutable VETO_SIGNALLING_MIN_ACTIVE_DURATION = 5 hours;
uint256 public immutable VETO_SIGNALLING_DEACTIVATION_MAX_DURATION = 5 days;
uint256 public immutable RAGE_QUIT_ACCUMULATION_MAX_DURATION = 3 days;
Duration public immutable VETO_SIGNALLING_MIN_ACTIVE_DURATION = Durations.from(5 hours);
Duration public immutable VETO_SIGNALLING_DEACTIVATION_MAX_DURATION = Durations.from(5 days);
Duration public immutable RAGE_QUIT_ACCUMULATION_MAX_DURATION = Durations.from(3 days);

uint256 public immutable VETO_COOLDOWN_DURATION = 4 days;
Duration public immutable VETO_COOLDOWN_DURATION = Durations.from(4 days);

uint256 public immutable RAGE_QUIT_EXTENSION_DELAY = 7 days;
uint256 public immutable RAGE_QUIT_ETH_CLAIM_MIN_TIMELOCK = 60 days;
uint256 public immutable RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_START_SEQ_NUMBER = 2;
Duration public immutable RAGE_QUIT_EXTENSION_DELAY = Durations.from(7 days);
Duration public immutable RAGE_QUIT_ETH_WITHDRAWALS_MIN_TIMELOCK = Durations.from(60 days);
uint256 public immutable RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_START_SEQ_NUMBER = 2;

uint256 public immutable RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_COEFF_A = 0;
uint256 public immutable RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_COEFF_B = 0;
uint256 public immutable RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_COEFF_C = 0;
uint256 public immutable RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_COEFF_A = 0;
uint256 public immutable RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_COEFF_B = 0;
uint256 public immutable RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_COEFF_C = 0;
// ---

address public immutable ADMIN_EXECUTOR;
address public immutable EMERGENCY_GOVERNANCE;

uint256 public immutable AFTER_SUBMIT_DELAY = 3 days;
uint256 public immutable AFTER_SCHEDULE_DELAY = 2 days;
Duration public immutable AFTER_SUBMIT_DELAY = Durations.from(3 days);
Duration public immutable AFTER_SCHEDULE_DELAY = Durations.from(2 days);

uint256 public immutable SIGNALLING_ESCROW_MIN_LOCK_TIME = 5 hours;
Duration public immutable SIGNALLING_ESCROW_MIN_LOCK_TIME = Durations.from(5 hours);

uint256 public immutable TIE_BREAK_ACTIVATION_TIMEOUT = 365 days;
Duration public immutable TIE_BREAK_ACTIVATION_TIMEOUT = Durations.from(365 days);

// Sealables Array Representation
uint256 private immutable MAX_SELABLES_COUNT = 5;
Expand Down Expand Up @@ -84,8 +88,8 @@ contract Configuration is IConfiguration {
returns (
uint256 firstSealRageQuitSupport,
uint256 secondSealRageQuitSupport,
uint256 dynamicTimelockMinDuration,
uint256 dynamicTimelockMaxDuration
Duration dynamicTimelockMinDuration,
Duration dynamicTimelockMaxDuration
)
{
firstSealRageQuitSupport = FIRST_SEAL_RAGE_QUIT_SUPPORT;
Expand All @@ -103,12 +107,13 @@ contract Configuration is IConfiguration {
config.vetoSignallingDeactivationMaxDuration = VETO_SIGNALLING_DEACTIVATION_MAX_DURATION;
config.vetoCooldownDuration = VETO_COOLDOWN_DURATION;
config.rageQuitExtensionDelay = RAGE_QUIT_EXTENSION_DELAY;
config.rageQuitEthClaimMinTimelock = RAGE_QUIT_ETH_CLAIM_MIN_TIMELOCK;
config.rageQuitEthClaimTimelockGrowthStartSeqNumber = RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_START_SEQ_NUMBER;
config.rageQuitEthClaimTimelockGrowthCoeffs = [
RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_COEFF_A,
RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_COEFF_B,
RAGE_QUIT_ETH_CLAIM_TIMELOCK_GROWTH_COEFF_C
config.rageQuitEthWithdrawalsMinTimelock = RAGE_QUIT_ETH_WITHDRAWALS_MIN_TIMELOCK;
config.rageQuitEthWithdrawalsTimelockGrowthStartSeqNumber =
RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_START_SEQ_NUMBER;
config.rageQuitEthWithdrawalsTimelockGrowthCoeffs = [
RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_COEFF_A,
RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_COEFF_B,
RAGE_QUIT_ETH_WITHDRAWALS_TIMELOCK_GROWTH_COEFF_C
];
}
}
66 changes: 42 additions & 24 deletions contracts/DualGovernance.sol
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {Duration} from "./types/Duration.sol";
import {Timestamp} from "./types/Timestamp.sol";
import {ITimelock, IGovernance} from "./interfaces/ITimelock.sol";
import {ISealable} from "./interfaces/ISealable.sol";
import {IResealManager} from "./interfaces/IResealManager.sol";

import {ConfigurationProvider} from "./ConfigurationProvider.sol";
import {Proposers, Proposer} from "./libraries/Proposers.sol";
import {ExecutorCall} from "./libraries/Proposals.sol";
import {EmergencyProtection} from "./libraries/EmergencyProtection.sol";
import {State, DualGovernanceState} from "./libraries/DualGovernanceState.sol";
import {TiebreakerProtection} from "./libraries/TiebreakerProtection.sol";

contract DualGovernance is IGovernance, ConfigurationProvider {
using Proposers for Proposers.State;
using DualGovernanceState for DualGovernanceState.Store;
using TiebreakerProtection for TiebreakerProtection.Tiebreaker;

event TiebreakerSet(address tiebreakCommittee);
event ProposalScheduled(uint256 proposalId);

error ProposalNotExecutable(uint256 proposalId);
error NotTiebreaker(address account, address tiebreakCommittee);
error NotResealCommitttee(address account);

ITimelock public immutable TIMELOCK;

address internal _tiebreaker;

TiebreakerProtection.Tiebreaker internal _tiebreaker;
Proposers.State internal _proposers;
DualGovernanceState.Store internal _dgState;
EmergencyProtection.State internal _emergencyProtection;
address internal _resealCommittee;
IResealManager internal _resealManager;

constructor(
address config,
Expand All @@ -49,8 +54,12 @@ contract DualGovernance is IGovernance, ConfigurationProvider {

function scheduleProposal(uint256 proposalId) external {
_dgState.activateNextState(CONFIG.getDualGovernanceConfig());
uint256 proposalSubmissionTime = TIMELOCK.schedule(proposalId);

Timestamp proposalSubmissionTime = TIMELOCK.getProposalSubmissionTime(proposalId);
_dgState.checkCanScheduleProposal(proposalSubmissionTime);

TIMELOCK.schedule(proposalId);

emit ProposalScheduled(proposalId);
}

Expand All @@ -59,11 +68,11 @@ contract DualGovernance is IGovernance, ConfigurationProvider {
TIMELOCK.cancelAllNonExecutedProposals();
}

function vetoSignallingEscrow() external view returns (address) {
function getVetoSignallingEscrow() external view returns (address) {
return address(_dgState.signallingEscrow);
}

function rageQuitEscrow() external view returns (address) {
function getRageQuitEscrow() external view returns (address) {
return address(_dgState.rageQuitEscrow);
}

Expand All @@ -79,27 +88,27 @@ contract DualGovernance is IGovernance, ConfigurationProvider {
_dgState.activateNextState(CONFIG.getDualGovernanceConfig());
}

function currentState() external view returns (State) {
function getCurrentState() external view returns (State) {
return _dgState.currentState();
}

function getVetoSignallingState()
external
view
returns (bool isActive, uint256 duration, uint256 activatedAt, uint256 enteredAt)
returns (bool isActive, Duration duration, Timestamp activatedAt, Timestamp enteredAt)
{
(isActive, duration, activatedAt, enteredAt) = _dgState.getVetoSignallingState(CONFIG.getDualGovernanceConfig());
}

function getVetoSignallingDeactivationState()
external
view
returns (bool isActive, uint256 duration, uint256 enteredAt)
returns (bool isActive, Duration duration, Timestamp enteredAt)
{
(isActive, duration, enteredAt) = _dgState.getVetoSignallingDeactivationState(CONFIG.getDualGovernanceConfig());
}

function getVetoSignallingDuration() external view returns (uint256) {
function getVetoSignallingDuration() external view returns (Duration) {
return _dgState.getVetoSignallingDuration(CONFIG.getDualGovernanceConfig());
}

Expand Down Expand Up @@ -141,29 +150,38 @@ contract DualGovernance is IGovernance, ConfigurationProvider {
// Tiebreaker Protection
// ---

function tiebreakerResumeSealable(address sealable) external {
_tiebreaker.checkTiebreakerCommittee(msg.sender);
_dgState.checkTiebreak(CONFIG);
_tiebreaker.resumeSealable(sealable);
}

function tiebreakerScheduleProposal(uint256 proposalId) external {
_checkTiebreakerCommittee(msg.sender);
_dgState.activateNextState(CONFIG.getDualGovernanceConfig());
_tiebreaker.checkTiebreakerCommittee(msg.sender);
_dgState.checkTiebreak(CONFIG);
TIMELOCK.schedule(proposalId);
}

function setTiebreakerCommittee(address newTiebreaker) external {
function setTiebreakerProtection(address newTiebreaker, address resealManager) external {
_checkAdminExecutor(msg.sender);
address oldTiebreaker = _tiebreaker;
if (newTiebreaker != oldTiebreaker) {
_tiebreaker = newTiebreaker;
emit TiebreakerSet(newTiebreaker);
}
_tiebreaker.setTiebreaker(newTiebreaker, resealManager);
}

// ---
// Internal Helper Methods
// Reseal executor
// ---

function _checkTiebreakerCommittee(address account) internal view {
if (account != _tiebreaker) {
revert NotTiebreaker(account, _tiebreaker);
function resealSealables(address[] memory sealables) external {
if (msg.sender != _resealCommittee) {
revert NotResealCommitttee(msg.sender);
}
_dgState.checkResealState();
_resealManager.reseal(sealables);
}

function setReseal(address resealManager, address resealCommittee) external {
_checkAdminExecutor(msg.sender);
_resealCommittee = resealCommittee;
_resealManager = IResealManager(resealManager);
}
}
Loading

0 comments on commit b2ea538

Please sign in to comment.