Skip to content

Commit 8ad3e07

Browse files
authored
refactor: improve operation scheduling logic in ExecutorBase (#4436)
### Description Refactored the `_validateAndConsumeSchedule` function in `ExecutorBase.sol` to improve clarity and fix a logical issue with operation scheduling. ### Changes - Simplified conditional logic for unauthorized calls - Fixed a bug where operations with delay would execute without being scheduled - Added explicit check for unscheduled operations that require delay - Improved handling of scheduled operations by checking the schedule timepoint once - Separated the conditions for consuming scheduled operations from delay enforcement ### Checklist - [ ] Tests added where required - [ ] Documentation updated where applicable - [ ] Changes adhere to the repository's contribution guidelines
1 parent f09d570 commit 8ad3e07

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/contracts/src/spaces/facets/executor/ExecutorBase.sol

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,18 +460,15 @@ abstract contract ExecutorBase is IExecutorBase {
460460
// Fetch restrictions that apply to the caller on the targeted function
461461
(bool allowed, uint32 delay) = _canCall(msg.sender, target, selector);
462462

463-
// If call is not authorized, revert
464-
if (!allowed && delay == 0) {
465-
UnauthorizedCall.selector.revertWith();
466-
}
463+
if (!allowed && delay == 0) UnauthorizedCall.selector.revertWith();
467464

468465
bytes32 operationId = _hashOperation(msg.sender, target, data);
466+
uint48 scheduleTimepoint = _getScheduleTimepoint(operationId);
469467

470-
// If caller is authorized, check operation was scheduled early enough
471-
// Consume an available schedule even if there is no currently enforced delay
472-
if (delay != 0 || _getScheduleTimepoint(operationId) != 0) {
473-
nonce = _consumeScheduledOp(operationId);
474-
}
468+
if (delay != 0 && scheduleTimepoint == 0) NotScheduled.selector.revertWith();
469+
470+
// Consume scheduled operation if one exists
471+
if (scheduleTimepoint != 0) nonce = _consumeScheduledOp(operationId);
475472
}
476473

477474
/// @dev Determines if a caller can invoke a function on a target, and if a delay is required.

0 commit comments

Comments
 (0)