Skip to content

Commit

Permalink
feat(contracts): revert zero timelock protocol
Browse files Browse the repository at this point in the history
Remove protocol for using custom time-lock zero delay for urgent situations.
The default Timelock delay has also been changed to 7 days.
  • Loading branch information
kangsorang committed Oct 6, 2023
1 parent 347e139 commit c666e0a
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 795 deletions.
2 changes: 1 addition & 1 deletion bindings/bindings/timelock.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/bindings/timelock_more.go

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions bindings/bindings/upgradegovernor.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/bindings/upgradegovernor_more.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/contracts/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ SystemConfig_Setters_TestFail:test_setUnsafeBlockSigner_notOwner_reverts() (gas:
SystemConfig_Setters_TestFail:test_setValidatorRewardScalar_outOfRange_reverts() (gas: 11927)
UpgradeGovernorTest:test_createProposal_succeeds() (gas: 105845)
UpgradeGovernorTest:test_createProposal_tokenThreshold_reverts() (gas: 37558)
UpgradeGovernorTest:test_executeProposal_succeeds() (gas: 376807)
UpgradeGovernorTest:test_executeProposal_succeeds() (gas: 376823)
UpgradeGovernorTest:test_initialize_succeeds() (gas: 85053)
UpgradeGovernorTest:test_queueProposal_succeeds() (gas: 280038)
UpgradeGovernorTest:test_queueProposal_succeeds() (gas: 280046)
UpgradeGovernorTest:test_voteProposal_overPeriod_reverts() (gas: 151818)
UpgradeGovernorTest:test_voteProposal_succeeds() (gas: 198060)
ValidatorPoolTest:test_addPendingBond_insufficientBalances_reverts() (gas: 298263)
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/contracts/governance/TimeLock.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "../vendor/TimelockControllerUpgradeable.sol";
import { Semver } from "../universal/Semver.sol";

/**
Expand Down
47 changes: 1 addition & 46 deletions packages/contracts/contracts/governance/UpgradeGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorSettin
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorCountingSimpleUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorTimelockControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

import "../vendor/GovernorTimelockControlUpgradeable.sol";
import { Semver } from "../universal/Semver.sol";

/**
Expand Down Expand Up @@ -64,51 +64,6 @@ contract UpgradeGovernor is
__GovernorTimelockControl_init(TimelockControllerUpgradeable(_timelock));
}

/**
* @notice Function to queue a proposal to the timelock.
* Added protocol for using custom time-lock zero delay for urgent situations.
*
* @param _targets The destination address that send the message to.
* @param _values Amount of ether sent with the message.
* @param _calldatas The data portion of the message.
* @param _descriptionHash A hashed form of the description string.
*
* @return Whether the challenge was canceled.
*/
function queue(
address[] memory _targets,
uint256[] memory _values,
bytes[] memory _calldatas,
bytes32 _descriptionHash
) public virtual override returns (uint256) {
uint256 proposalId = hashProposal(_targets, _values, _calldatas, _descriptionHash);

require(
state(proposalId) == ProposalState.Succeeded,
"UpgradeGovernor: proposal not successful"
);

uint256 delay = _timelock.getMinDelay();
// Protocol for reflecting urgent decisions on proposals.
// A zero delay is applied if the first element of the argument satisfies conditions.
if (_targets[0] == address(0) && _values[0] == 0) {
delay = 0;
}

_timelockIds[proposalId] = _timelock.hashOperationBatch(
_targets,
_values,
_calldatas,
0,
_descriptionHash
);
_timelock.scheduleBatch(_targets, _values, _calldatas, 0, _descriptionHash, delay);

emit ProposalQueued(proposalId, block.timestamp + delay);

return proposalId;
}

// The following functions are overridden cause required by Solidity.

function votingDelay()
Expand Down

This file was deleted.

Loading

0 comments on commit c666e0a

Please sign in to comment.