Skip to content

Commit

Permalink
Add a cancellor role to the TimelockController
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Feb 3, 2022
1 parent 28986d2 commit 78c09a8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions contracts/governance/TimelockController.sol
Expand Up @@ -24,6 +24,7 @@ contract TimelockController is AccessControl {
bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256("TIMELOCK_ADMIN_ROLE");
bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
bytes32 public constant CANCELLOR_ROLE = keccak256("CANCELLOR_ROLE");
uint256 internal constant _DONE_TIMESTAMP = uint256(1);

mapping(bytes32 => uint256) private _timestamps;
Expand Down Expand Up @@ -68,18 +69,22 @@ contract TimelockController is AccessControl {
_setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);
_setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);
_setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);
_setRoleAdmin(CANCELLOR_ROLE, TIMELOCK_ADMIN_ROLE);

// deployer + self administration
_setupRole(TIMELOCK_ADMIN_ROLE, _msgSender());
_setupRole(TIMELOCK_ADMIN_ROLE, address(this));

// register proposers
for (uint256 i = 0; i < proposers.length; ++i) {
// register proposers (and give them cancellor role)
uint256 proposersLength = proposers.length;
for (uint256 i = 0; i < proposersLength; ++i) {
_setupRole(PROPOSER_ROLE, proposers[i]);
_setupRole(CANCELLOR_ROLE, proposers[i]);
}

// register executors
for (uint256 i = 0; i < executors.length; ++i) {
uint256 executorsLength = executors.length;
for (uint256 i = 0; i < executorsLength; ++i) {
_setupRole(EXECUTOR_ROLE, executors[i]);
}

Expand Down Expand Up @@ -243,9 +248,9 @@ contract TimelockController is AccessControl {
*
* Requirements:
*
* - the caller must have the 'proposer' role.
* - the caller must have the 'cancellor' role.
*/
function cancel(bytes32 id) public virtual onlyRole(PROPOSER_ROLE) {
function cancel(bytes32 id) public virtual onlyRole(CANCELLOR_ROLE) {
require(isOperationPending(id), "TimelockController: operation cannot be cancelled");
delete _timestamps[id];

Expand Down

0 comments on commit 78c09a8

Please sign in to comment.