Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use prefix new for arguments in the setters #229

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions contracts/DualGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ contract DualGovernance is IDualGovernance {
/// @dev Ensures that at least one proposer remains assigned to the `adminExecutor` following the update.
/// Reverts if updating the proposer’s executor would leave the `adminExecutor` without any associated proposer.
/// @param proposerAccount The address of the proposer whose executor is being updated.
/// @param executor The new executor address to assign to the proposer.
function setProposerExecutor(address proposerAccount, address executor) external {
/// @param newExecutor The new executor address to assign to the proposer.
function setProposerExecutor(address proposerAccount, address newExecutor) external {
_checkCallerIsAdminExecutor();
_proposers.setProposerExecutor(proposerAccount, executor);
_proposers.setProposerExecutor(proposerAccount, newExecutor);

/// @dev after update of the proposer, check that admin executor still belongs to some proposer
_proposers.checkRegisteredExecutor(TIMELOCK.getAdminExecutor());
Expand Down Expand Up @@ -450,21 +450,21 @@ contract DualGovernance is IDualGovernance {
}

/// @notice Sets the new address of the tiebreaker committee in the system.
/// @param tiebreakerCommittee The address of the new tiebreaker committee.
function setTiebreakerCommittee(address tiebreakerCommittee) external {
/// @param newTiebreakerCommittee The address of the new tiebreaker committee.
function setTiebreakerCommittee(address newTiebreakerCommittee) external {
_checkCallerIsAdminExecutor();
_tiebreaker.setTiebreakerCommittee(tiebreakerCommittee);
_tiebreaker.setTiebreakerCommittee(newTiebreakerCommittee);
}

/// @notice Sets the new value for the tiebreaker activation timeout.
/// @dev If the Dual Governance system remains out of the `Normal` or `VetoCooldown` state for longer than
/// the `tiebreakerActivationTimeout` duration, the tiebreaker committee is allowed to schedule
/// submitted proposals.
/// @param tiebreakerActivationTimeout The new duration for the tiebreaker activation timeout.
function setTiebreakerActivationTimeout(Duration tiebreakerActivationTimeout) external {
/// @param newTiebreakerActivationTimeout The new duration for the tiebreaker activation timeout.
function setTiebreakerActivationTimeout(Duration newTiebreakerActivationTimeout) external {
_checkCallerIsAdminExecutor();
_tiebreaker.setTiebreakerActivationTimeout(
MIN_TIEBREAKER_ACTIVATION_TIMEOUT, tiebreakerActivationTimeout, MAX_TIEBREAKER_ACTIVATION_TIMEOUT
MIN_TIEBREAKER_ACTIVATION_TIMEOUT, newTiebreakerActivationTimeout, MAX_TIEBREAKER_ACTIVATION_TIMEOUT
);
}

Expand Down Expand Up @@ -516,17 +516,17 @@ contract DualGovernance is IDualGovernance {
}

/// @notice Sets the address of the reseal committee.
/// @param resealCommittee The address of the new reseal committee.
function setResealCommittee(address resealCommittee) external {
/// @param newResealCommittee The address of the new reseal committee.
function setResealCommittee(address newResealCommittee) external {
_checkCallerIsAdminExecutor();
_resealer.setResealCommittee(resealCommittee);
_resealer.setResealCommittee(newResealCommittee);
}

/// @notice Sets the address of the Reseal Manager.
/// @param resealManager The address of the new Reseal Manager.
function setResealManager(address resealManager) external {
/// @param newResealManager The address of the new Reseal Manager.
function setResealManager(address newResealManager) external {
_checkCallerIsAdminExecutor();
_resealer.setResealManager(resealManager);
_resealer.setResealManager(newResealManager);
}

/// @notice Gets the address of the Reseal Manager.
Expand Down
30 changes: 15 additions & 15 deletions contracts/EmergencyProtectedTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,40 +180,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 {
/// @param newEmergencyActivationCommittee The address of the emergency activation committee.
function setEmergencyProtectionActivationCommittee(address newEmergencyActivationCommittee) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyActivationCommittee(emergencyActivationCommittee);
_emergencyProtection.setEmergencyActivationCommittee(newEmergencyActivationCommittee);
}

/// @notice Sets the emergency execution committee address.
/// @param emergencyExecutionCommittee The address of the emergency execution committee.
function setEmergencyProtectionExecutionCommittee(address emergencyExecutionCommittee) external {
/// @param newEmergencyExecutionCommittee The address of the emergency execution committee.
function setEmergencyProtectionExecutionCommittee(address newEmergencyExecutionCommittee) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyExecutionCommittee(emergencyExecutionCommittee);
_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 {
/// @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 {
/// @param newEmergencyModeDuration The duration of the emergency mode.
function setEmergencyModeDuration(Duration newEmergencyModeDuration) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyModeDuration(emergencyModeDuration, MAX_EMERGENCY_MODE_DURATION);
_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 {
/// @param newEmergencyGovernance The address of the emergency governance.
function setEmergencyGovernance(address newEmergencyGovernance) external {
_timelockState.checkCallerIsAdminExecutor();
_emergencyProtection.setEmergencyGovernance(emergencyGovernance);
_emergencyProtection.setEmergencyGovernance(newEmergencyGovernance);
}

/// @notice Activates the emergency mode.
Expand Down
12 changes: 6 additions & 6 deletions contracts/committees/HashConsensus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ abstract contract HashConsensus is Ownable {

/// @notice Sets the timelock duration
/// @dev Only callable by the owner
/// @param timelock The new timelock duration in seconds
function setTimelockDuration(Duration timelock) external {
/// @param newTimelock The new timelock duration in seconds
function setTimelockDuration(Duration newTimelock) external {
_checkOwner();
if (timelock == _timelockDuration) {
revert InvalidTimelockDuration(timelock);
if (newTimelock == _timelockDuration) {
revert InvalidTimelockDuration(newTimelock);
}
_timelockDuration = timelock;
emit TimelockDurationSet(timelock);
_timelockDuration = newTimelock;
emit TimelockDurationSet(newTimelock);
}

/// @notice Gets the quorum value
Expand Down
5 changes: 3 additions & 2 deletions contracts/interfaces/IDualGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ interface IDualGovernance is IGovernance, ITiebreaker {
function getStateDetails() external view returns (StateDetails memory stateDetails);

function registerProposer(address proposer, address executor) external;
function setProposerExecutor(address proposerAccount, address newExecutor) external;
function unregisterProposer(address proposer) external;
function isRegisteredProposer(address account) external view returns (bool);
function getProposer(address account) external view returns (Proposers.Proposer memory proposer);
function getProposers() external view returns (Proposers.Proposer[] memory proposers);
function isRegisteredExecutor(address account) external view returns (bool);

function resealSealable(address sealable) external;
function setResealCommittee(address resealCommittee) external;
function setResealManager(address resealManager) external;
function setResealCommittee(address newResealCommittee) external;
function setResealManager(address newResealManager) external;
function getResealManager() external view returns (IResealManager);
function getResealCommittee() external view returns (address);
}
10 changes: 5 additions & 5 deletions contracts/interfaces/IEmergencyProtectedTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ interface IEmergencyProtectedTimelock is ITimelock {
function MAX_EMERGENCY_MODE_DURATION() external view returns (Duration);
function MAX_EMERGENCY_PROTECTION_DURATION() external view returns (Duration);

function setEmergencyProtectionActivationCommittee(address emergencyActivationCommittee) external;
function setEmergencyProtectionExecutionCommittee(address emergencyExecutionCommittee) external;
function setEmergencyProtectionEndDate(Timestamp emergencyProtectionEndDate) external;
function setEmergencyModeDuration(Duration emergencyModeDuration) external;
function setEmergencyGovernance(address emergencyGovernance) external;
function setEmergencyProtectionActivationCommittee(address newEmergencyActivationCommittee) external;
function setEmergencyProtectionExecutionCommittee(address newEmergencyExecutionCommittee) external;
function setEmergencyProtectionEndDate(Timestamp newEmergencyProtectionEndDate) external;
function setEmergencyModeDuration(Duration newEmergencyModeDuration) external;
function setEmergencyGovernance(address newEmergencyGovernance) external;

function activateEmergencyMode() external;
function emergencyExecute(uint256 proposalId) external;
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/ITiebreaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface ITiebreaker {

function addTiebreakerSealableWithdrawalBlocker(address sealableWithdrawalBlocker) external;
function removeTiebreakerSealableWithdrawalBlocker(address sealableWithdrawalBlocker) external;
function setTiebreakerCommittee(address tiebreakerCommittee) external;
function setTiebreakerActivationTimeout(Duration tiebreakerActivationTimeout) external;
function setTiebreakerCommittee(address newTiebreakerCommittee) external;
function setTiebreakerActivationTimeout(Duration newTiebreakerActivationTimeout) external;
function tiebreakerScheduleProposal(uint256 proposalId) external;
function getTiebreakerDetails() external view returns (TiebreakerDetails memory tiebreakerState);
function tiebreakerResumeSealable(address sealable) external;
Expand Down
14 changes: 7 additions & 7 deletions contracts/libraries/Proposers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ library Proposers {
/// @notice Updates the executor for a registered proposer.
/// @param self The context storage of the Proposers library.
/// @param proposerAccount The address of the proposer to update.
/// @param executor The new executor address to assign to the proposer.
function setProposerExecutor(Context storage self, address proposerAccount, address executor) internal {
/// @param newExecutor The new executor address to assign to the proposer.
function setProposerExecutor(Context storage self, address proposerAccount, address newExecutor) internal {
ExecutorData memory executorData = self.executors[proposerAccount];
_checkRegisteredProposer(proposerAccount, executorData);

if (executor == address(0) || executorData.executor == executor) {
revert InvalidExecutor(executor);
if (newExecutor == address(0) || executorData.executor == newExecutor) {
revert InvalidExecutor(newExecutor);
}

self.executors[proposerAccount].executor = executor;
self.executors[proposerAccount].executor = newExecutor;

self.executorRefsCounts[executor] += 1;
self.executorRefsCounts[newExecutor] += 1;
self.executorRefsCounts[executorData.executor] -= 1;

emit ProposerExecutorSet(proposerAccount, executor);
emit ProposerExecutorSet(proposerAccount, newExecutor);
}

/// @notice Unregisters a proposer, removing its association with an executor.
Expand Down
2 changes: 1 addition & 1 deletion docs/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ Returns if an address is a member.
### Function: HashConsensus.setTimelockDuration

```solidity
function setTimelockDuration(uint256 timelock)
function setTimelockDuration(uint256 newTimelock)
```

Sets the timelock duration.
Expand Down
1 change: 1 addition & 0 deletions test/unit/DualGovernance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,7 @@ contract DualGovernanceUnitTests is UnitTest {
}

function testFuzz_setResealCommittee_RevertOn_InvalidResealCommittee(address newResealCommittee) external {
vm.assume(_dualGovernance.getResealCommittee() != newResealCommittee);
_executor.execute(
address(_dualGovernance),
0,
Expand Down
Loading