Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
82e34fd
first proposal
RenanSouza2 Jun 16, 2023
536628e
Add changeset
RenanSouza2 Jun 16, 2023
a2a6a0c
Merge branch 'master' into timelockControler-getter
RenanSouza2 Jun 16, 2023
b2b6844
Improove getOperationState decision tree
RenanSouza2 Jun 16, 2023
813360d
Merge branch 'master' into timelockControler-getter
RenanSouza2 Jun 17, 2023
c3f0ac1
Merge branch 'master' into timelockControler-getter
RenanSouza2 Jun 28, 2023
832c2d5
Reinstate functions
RenanSouza2 Jun 28, 2023
e0bbaad
Change Pending to Blocked
RenanSouza2 Jun 29, 2023
8e671f9
Change TimelockController error from state to bitmap
RenanSouza2 Jul 1, 2023
de0fb95
Fix tests
RenanSouza2 Jul 1, 2023
ef63f37
Fix linter
RenanSouza2 Jul 1, 2023
7587ab4
Merge branch 'master' into timelockControler-getter
RenanSouza2 Jul 1, 2023
9e8c8ca
Update loud-shrimps-play.md
frangio Jul 4, 2023
cf4a2df
rename error param
frangio Jul 4, 2023
ab10a19
remove isOperationBlocked
frangio Jul 4, 2023
643b549
remove virtual
frangio Jul 4, 2023
86f1724
revert afterCall change
frangio Jul 4, 2023
f9498a9
rename Blocked to Waiting
frangio Jul 4, 2023
84099df
Merge branch 'master' into timelockControler-getter
frangio Jul 4, 2023
220cfc3
Change enum in documentation
RenanSouza2 Jul 4, 2023
bd74728
Remove interfaces from docs
RenanSouza2 Jul 4, 2023
a608384
Update contracts/governance/TimelockController.sol
frangio Jul 4, 2023
bd2f0fa
Update contracts/governance/TimelockController.sol
frangio Jul 4, 2023
8d43f44
Update contracts/governance/TimelockController.sol
frangio Jul 4, 2023
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
Prev Previous commit
Next Next commit
Change Pending to Blocked
  • Loading branch information
RenanSouza2 committed Jun 29, 2023
commit e0bbaada41609aee5f6f930ea0b8c8ca7e58c471
3 changes: 2 additions & 1 deletion contracts/governance/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ In a governance system, the {TimelockController} contract is in charge of introd
* *Operation:* A transaction (or a set of transactions) that is the subject of the timelock. It has to be scheduled by a proposer and executed by an executor. The timelock enforces a minimum delay between the proposition and the execution (see xref:access-control.adoc#operation_lifecycle[operation lifecycle]). If the operation contains multiple transactions (batch mode), they are executed atomically. Operations are identified by the hash of their content.
* *Operation status:*
** *Unset:* An operation that is not part of the timelock mechanism.
** *Pending:* An operation that has been scheduled but not executed or canceled.
** *Blocked:* An operation that has been scheduled, before the timer expires.
** *Ready:* An operation that has been scheduled, after the timer expires.
** *Pending:* An operation that is either blocked or ready.
** *Done:* An operation that has been executed.
* *Predecessor*: An (optional) dependency between operations. An operation can depend on another operation (its predecessor), forcing the execution order of these two operations.
* *Role*:
Expand Down
27 changes: 17 additions & 10 deletions contracts/governance/TimelockController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder {

enum OperationState {
Unset,
Pending,
Blocked,
Ready,
Done
}
Expand Down Expand Up @@ -170,11 +170,10 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder {
}

/**
* @dev Returns whether an operation is pending or not. Note that a "pending" operation may also be "ready".
* @dev Returns whether an operation is waitinf for expiration. Note that a "blocked" operation is also "pending".
*/
function isOperationPending(bytes32 id) public view virtual returns (bool) {
OperationState state = getOperationState(id);
return state == OperationState.Pending || state == OperationState.Ready;
function isOperationBlocked(bytes32 id) public view virtual returns (bool) {
return getOperationState(id) == OperationState.Blocked;
}

/**
Expand All @@ -184,6 +183,14 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder {
return getOperationState(id) == OperationState.Ready;
}

/**
* @dev Returns whether an operation is pending or not. Note that a "pending" operation may also be "ready".
*/
function isOperationPending(bytes32 id) public view virtual returns (bool) {
OperationState state = getOperationState(id);
return state == OperationState.Blocked || state == OperationState.Ready;
}

/**
* @dev Returns whether an operation is done or not.
*/
Expand All @@ -209,7 +216,7 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder {
} else if (timestamp == _DONE_TIMESTAMP) {
return OperationState.Done;
} else if (timestamp > block.timestamp) {
return OperationState.Pending;
return OperationState.Blocked;
} else {
return OperationState.Ready;
}
Expand Down Expand Up @@ -330,8 +337,8 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder {
* - the caller must have the 'canceller' role.
*/
function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {
if (getOperationState(id) != OperationState.Pending) {
revert TimelockUnexpectedOperationState(id, OperationState.Pending);
if (!isOperationPending(id)) {
revert TimelockUnexpectedOperationState(id, OperationState.Blocked);
}
delete _timestamps[id];

Expand Down Expand Up @@ -413,10 +420,10 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder {
* @dev Checks before execution of an operation's calls.
*/
function _beforeCall(bytes32 id, bytes32 predecessor) private view {
if (getOperationState(id) != OperationState.Ready) {
if (!isOperationReady(id)) {
revert TimelockUnexpectedOperationState(id, OperationState.Ready);
}
if (predecessor != bytes32(0) && getOperationState(predecessor) != OperationState.Done) {
if (predecessor != bytes32(0) && !isOperationDone(predecessor)) {
revert TimelockUnexecutedPredecessor(predecessor);
}
}
Expand Down