Skip to content

Commit

Permalink
Merge pull request #236 from lidofinance/develop
Browse files Browse the repository at this point in the history
1.0.0-rc1
  • Loading branch information
Psirex authored Dec 9, 2024
2 parents e99d4fc + 1f1b02d commit ad15aed
Show file tree
Hide file tree
Showing 98 changed files with 8,058 additions and 2,991 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
MAINNET_RPC_URL=<your RPC url>

# Deploy script env vars
CHAIN=<"mainnet" OR "holesky" OR "holesky-mocks">
ETHERSCAN_MAINNET_KEY=...
DEPLOY_CONFIG_FILE_PATH=deploy-config/deploy-config.json
DEPLOYED_ADDRESSES_FILE_PATH=deploy-config/deployed-addrs.json
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ cache_forge/
out/

# Foundry: development broadcast logs
!/broadcast
/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
.vscode/
deploy-config
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = tags/v1.9.3
[submodule "lib/kontrol-cheatcodes"]
path = lib/kontrol-cheatcodes
url = https://github.com/runtimeverification/kontrol-cheatcodes
Expand Down
7 changes: 7 additions & 0 deletions addresses/holesky-addresses.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

address constant DAO_VOTING = 0xdA7d2573Df555002503F29aA4003e398d28cc00f;
address constant ST_ETH = 0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034;
address constant WST_ETH = 0x8d09a4502Cc8Cf1547aD300E066060D043f6982D;
address constant WITHDRAWAL_QUEUE = 0xc7cc160b58F8Bb0baC94b80847E2CF2800565C50;
File renamed without changes.
245 changes: 147 additions & 98 deletions contracts/DualGovernance.sol

Large diffs are not rendered by default.

92 changes: 37 additions & 55 deletions contracts/EmergencyProtectedTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
using ExecutableProposals for ExecutableProposals.Context;
using EmergencyProtection for EmergencyProtection.Context;

// ---
// Errors
// ---

error CallerIsNotAdminExecutor(address value);

// ---
// Sanity Check Parameters & Immutables
// ---
Expand Down Expand Up @@ -61,13 +55,6 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
/// @notice The upper bound for the time the emergency protection mechanism can be activated.
Duration public immutable MAX_EMERGENCY_PROTECTION_DURATION;

// ---
// Admin Executor Immutables
// ---

/// @dev The address of the admin executor, authorized to manage the EmergencyProtectedTimelock instance.
address private immutable _ADMIN_EXECUTOR;

// ---
// Aspects
// ---
Expand All @@ -91,14 +78,14 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
Duration afterSubmitDelay,
Duration afterScheduleDelay
) {
_ADMIN_EXECUTOR = adminExecutor;

MIN_EXECUTION_DELAY = sanityCheckParams.minExecutionDelay;
MAX_AFTER_SUBMIT_DELAY = sanityCheckParams.maxAfterSubmitDelay;
MAX_AFTER_SCHEDULE_DELAY = sanityCheckParams.maxAfterScheduleDelay;
MAX_EMERGENCY_MODE_DURATION = sanityCheckParams.maxEmergencyModeDuration;
MAX_EMERGENCY_PROTECTION_DURATION = sanityCheckParams.maxEmergencyProtectionDuration;

_timelockState.setAdminExecutor(adminExecutor);

if (afterSubmitDelay > Durations.ZERO) {
_timelockState.setAfterSubmitDelay(afterSubmitDelay, MAX_AFTER_SUBMIT_DELAY);
}
Expand All @@ -115,19 +102,12 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
// ---

/// @notice Submits a new proposal to execute a series of calls through an executor.
/// @param proposer The address of the proposer submitting the proposal.
/// @param executor The address of the executor contract that will execute the calls.
/// @param calls An array of `ExternalCall` structs representing the calls to be executed.
/// @param metadata A string containing additional information about the proposal.
/// @return newProposalId The id of the newly created proposal.
function submit(
address proposer,
address executor,
ExternalCall[] calldata calls,
string calldata metadata
) external returns (uint256 newProposalId) {
function submit(address executor, ExternalCall[] calldata calls) external returns (uint256 newProposalId) {
_timelockState.checkCallerIsGovernance();
newProposalId = _proposals.submit(proposer, executor, calls, metadata);
newProposalId = _proposals.submit(executor, calls);
}

/// @notice Schedules a proposal for execution after a specified delay.
Expand Down Expand Up @@ -157,15 +137,16 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
/// @notice Updates the address of the governance contract.
/// @param newGovernance The address of the new governance contract to be set.
function setGovernance(address newGovernance) external {
_checkCallerIsAdminExecutor();
_timelockState.checkCallerIsAdminExecutor();
_timelockState.setGovernance(newGovernance);
_proposals.cancelAll();
}

/// @notice Sets the delay required to pass from the submission of a proposal before it can be scheduled for execution.
/// Ensures that the new delay value complies with the defined sanity check bounds.
/// @param newAfterSubmitDelay The delay required before a submitted proposal can be scheduled.
function setAfterSubmitDelay(Duration newAfterSubmitDelay) external {
_checkCallerIsAdminExecutor();
_timelockState.checkCallerIsAdminExecutor();
_timelockState.setAfterSubmitDelay(newAfterSubmitDelay, MAX_AFTER_SUBMIT_DELAY);
_timelockState.checkExecutionDelay(MIN_EXECUTION_DELAY);
}
Expand All @@ -174,7 +155,7 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
/// Ensures that the new delay value complies with the defined sanity check bounds.
/// @param newAfterScheduleDelay The delay required before a scheduled proposal can be executed.
function setAfterScheduleDelay(Duration newAfterScheduleDelay) external {
_checkCallerIsAdminExecutor();
_timelockState.checkCallerIsAdminExecutor();
_timelockState.setAfterScheduleDelay(newAfterScheduleDelay, MAX_AFTER_SCHEDULE_DELAY);
_timelockState.checkExecutionDelay(MIN_EXECUTION_DELAY);
}
Expand All @@ -183,7 +164,7 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
/// @param executor The address of the executor contract.
/// @param owner The address of the new owner.
function transferExecutorOwnership(address executor, address owner) external {
_checkCallerIsAdminExecutor();
_timelockState.checkCallerIsAdminExecutor();
IOwnable(executor).transferOwnership(owner);
}

Expand All @@ -192,40 +173,40 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
// ---

/// @notice Sets the emergency activation committee address.
/// @param emergencyActivationCommittee The address of the emergency activation committee.
function setEmergencyProtectionActivationCommittee(address emergencyActivationCommittee) external {
_checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyActivationCommittee(emergencyActivationCommittee);
/// @param newEmergencyActivationCommittee The address of the emergency activation committee.
function setEmergencyProtectionActivationCommittee(address newEmergencyActivationCommittee) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyActivationCommittee(newEmergencyActivationCommittee);
}

/// @notice Sets the emergency execution committee address.
/// @param emergencyExecutionCommittee The address of the emergency execution committee.
function setEmergencyProtectionExecutionCommittee(address emergencyExecutionCommittee) external {
_checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyExecutionCommittee(emergencyExecutionCommittee);
/// @param newEmergencyExecutionCommittee The address of the emergency execution committee.
function setEmergencyProtectionExecutionCommittee(address newEmergencyExecutionCommittee) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyExecutionCommittee(newEmergencyExecutionCommittee);
}

/// @notice Sets the emergency protection end date.
/// @param emergencyProtectionEndDate The timestamp of the emergency protection end date.
function setEmergencyProtectionEndDate(Timestamp emergencyProtectionEndDate) external {
_checkCallerIsAdminExecutor();
/// @param newEmergencyProtectionEndDate The timestamp of the emergency protection end date.
function setEmergencyProtectionEndDate(Timestamp newEmergencyProtectionEndDate) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyProtectionEndDate(
emergencyProtectionEndDate, MAX_EMERGENCY_PROTECTION_DURATION
newEmergencyProtectionEndDate, MAX_EMERGENCY_PROTECTION_DURATION
);
}

/// @notice Sets the emergency mode duration.
/// @param emergencyModeDuration The duration of the emergency mode.
function setEmergencyModeDuration(Duration emergencyModeDuration) external {
_checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyModeDuration(emergencyModeDuration, MAX_EMERGENCY_MODE_DURATION);
/// @param newEmergencyModeDuration The duration of the emergency mode.
function setEmergencyModeDuration(Duration newEmergencyModeDuration) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyModeDuration(newEmergencyModeDuration, MAX_EMERGENCY_MODE_DURATION);
}

/// @notice Sets the emergency governance address.
/// @param emergencyGovernance The address of the emergency governance.
function setEmergencyGovernance(address emergencyGovernance) external {
_checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyGovernance(emergencyGovernance);
/// @param newEmergencyGovernance The address of the emergency governance.
function setEmergencyGovernance(address newEmergencyGovernance) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyGovernance(newEmergencyGovernance);
}

/// @notice Activates the emergency mode.
Expand All @@ -247,7 +228,7 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
function deactivateEmergencyMode() external {
_emergencyProtection.checkEmergencyMode({isActive: true});
if (!_emergencyProtection.isEmergencyModeDurationPassed()) {
_checkCallerIsAdminExecutor();
_timelockState.checkCallerIsAdminExecutor();
}
_emergencyProtection.deactivateEmergencyMode();
_proposals.cancelAll();
Expand Down Expand Up @@ -312,7 +293,7 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
/// @notice Returns the address of the admin executor.
/// @return adminExecutor The address of the admin executor.
function getAdminExecutor() external view returns (address) {
return _ADMIN_EXECUTOR;
return _timelockState.adminExecutor;
}

/// @notice Returns the configured delay duration required before a submitted proposal can be scheduled.
Expand Down Expand Up @@ -388,12 +369,13 @@ contract EmergencyProtectedTimelock is IEmergencyProtectedTimelock {
}

// ---
// Internal Methods
// Admin Executor Methods
// ---

function _checkCallerIsAdminExecutor() internal view {
if (msg.sender != _ADMIN_EXECUTOR) {
revert CallerIsNotAdminExecutor(msg.sender);
}
/// @notice Sets the address of the admin executor.
/// @param newAdminExecutor The address of the new admin executor.
function setAdminExecutor(address newAdminExecutor) external {
_timelockState.checkCallerIsAdminExecutor();
_timelockState.setAdminExecutor(newAdminExecutor);
}
}
Loading

0 comments on commit ad15aed

Please sign in to comment.