diff --git a/src/Executor.sol b/src/Executor.sol index f886466..e0524e1 100644 --- a/src/Executor.sol +++ b/src/Executor.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity ^0.8.10; +pragma solidity ^0.8.22; import { AccessControl } from "openzeppelin-contracts/contracts/access/AccessControl.sol"; import { Address } from "openzeppelin-contracts/contracts/utils/Address.sol"; @@ -7,7 +7,7 @@ import { Address } from "openzeppelin-contracts/contracts/utils/Address.so import { IExecutor } from './interfaces/IExecutor.sol'; /** - * @title Executor + * @title Executor * @author Aave * @notice Executor which queues up message calls and executes them after an optional delay */ @@ -15,40 +15,39 @@ contract Executor is IExecutor, AccessControl { using Address for address; + /******************************************************************************************************************/ + /*** State variables and constructor ***/ + /******************************************************************************************************************/ + bytes32 public constant SUBMISSION_ROLE = keccak256('SUBMISSION_ROLE'); bytes32 public constant GUARDIAN_ROLE = keccak256('GUARDIAN_ROLE'); - // Minimum allowed grace period, which reduces the risk of having an actions set expire due to network congestion - uint256 constant MINIMUM_GRACE_PERIOD = 10 minutes; - - // Time between queuing and execution - uint256 private _delay; - // Time after the execution time during which the actions set can be executed - uint256 private _gracePeriod; + uint256 public constant MINIMUM_GRACE_PERIOD = 10 minutes; - // Number of actions sets - uint256 private _actionsSetCounter; // Map of registered actions sets (id => ActionsSet) mapping(uint256 => ActionsSet) private _actionsSets; - // Map of queued actions (actionHash => isQueued) - mapping(bytes32 => bool) private _queuedActions; + + uint256 public override actionsSetCount; // Number of actions sets + uint256 public override delay; // Time between queuing and execution + uint256 public override gracePeriod; // Time after delay during which an actions set can be executed + + mapping(bytes32 => bool) public override isActionQueued; /** - * @dev Constructor - * - * @param delay The delay before which an actions set can be executed - * @param gracePeriod The time period after a delay during which an actions set can be executed + * @dev Constructor + * @param delay_ The delay before which an actions set can be executed. + * @param gracePeriod_ The time period after a delay during which an actions set can be executed. */ constructor( - uint256 delay, - uint256 gracePeriod + uint256 delay_, + uint256 gracePeriod_ ) { if ( - gracePeriod < MINIMUM_GRACE_PERIOD + gracePeriod_ < MINIMUM_GRACE_PERIOD ) revert InvalidInitParams(); - _updateDelay(delay); - _updateGracePeriod(gracePeriod); + _updateDelay(delay_); + _updateGracePeriod(gracePeriod_); _setRoleAdmin(SUBMISSION_ROLE, DEFAULT_ADMIN_ROLE); _setRoleAdmin(GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE); @@ -57,6 +56,10 @@ contract Executor is IExecutor, AccessControl { _grantRole(DEFAULT_ADMIN_ROLE, address(this)); // Necessary for self-referential calls to change configuration } + /******************************************************************************************************************/ + /*** ActionSet functions ***/ + /******************************************************************************************************************/ + /// @inheritdoc IExecutor function queue( address[] memory targets, @@ -66,21 +69,21 @@ contract Executor is IExecutor, AccessControl { bool[] memory withDelegatecalls ) external override onlyRole(SUBMISSION_ROLE) { if (targets.length == 0) revert EmptyTargets(); + uint256 targetsLength = targets.length; if ( - targetsLength != values.length || + targetsLength != values.length || targetsLength != signatures.length || - targetsLength != calldatas.length || + targetsLength != calldatas.length || targetsLength != withDelegatecalls.length ) revert InconsistentParamsLength(); - uint256 actionsSetId = _actionsSetCounter; - uint256 executionTime = block.timestamp + _delay; - unchecked { - ++_actionsSetCounter; - } + uint256 actionsSetId = actionsSetCount; + uint256 executionTime = block.timestamp + delay; + + unchecked { ++actionsSetCount; } - for (uint256 i = 0; i < targetsLength; ) { + for (uint256 i = 0; i < targetsLength; ++i) { bytes32 actionHash = keccak256( abi.encode( targets[i], @@ -91,20 +94,19 @@ contract Executor is IExecutor, AccessControl { withDelegatecalls[i] ) ); - if (isActionQueued(actionHash)) revert DuplicateAction(); - _queuedActions[actionHash] = true; - unchecked { - ++i; - } + if (isActionQueued[actionHash]) revert DuplicateAction(); + + isActionQueued[actionHash] = true; } ActionsSet storage actionsSet = _actionsSets[actionsSetId]; - actionsSet.targets = targets; - actionsSet.values = values; - actionsSet.signatures = signatures; - actionsSet.calldatas = calldatas; + + actionsSet.targets = targets; + actionsSet.values = values; + actionsSet.signatures = signatures; + actionsSet.calldatas = calldatas; actionsSet.withDelegatecalls = withDelegatecalls; - actionsSet.executionTime = executionTime; + actionsSet.executionTime = executionTime; emit ActionsSetQueued( actionsSetId, @@ -122,13 +124,15 @@ contract Executor is IExecutor, AccessControl { if (getCurrentState(actionsSetId) != ActionsSetState.Queued) revert OnlyQueuedActions(); ActionsSet storage actionsSet = _actionsSets[actionsSetId]; + if (block.timestamp < actionsSet.executionTime) revert TimelockNotFinished(); actionsSet.executed = true; + uint256 actionCount = actionsSet.targets.length; bytes[] memory returnedData = new bytes[](actionCount); - for (uint256 i = 0; i < actionCount; ) { + for (uint256 i = 0; i < actionCount; ++i) { returnedData[i] = _executeTransaction( actionsSet.targets[i], actionsSet.values[i], @@ -137,9 +141,6 @@ contract Executor is IExecutor, AccessControl { actionsSet.executionTime, actionsSet.withDelegatecalls[i] ); - unchecked { - ++i; - } } emit ActionsSetExecuted(actionsSetId, msg.sender, returnedData); @@ -153,8 +154,8 @@ contract Executor is IExecutor, AccessControl { actionsSet.canceled = true; uint256 targetsLength = actionsSet.targets.length; - for (uint256 i = 0; i < targetsLength; ) { - _cancelTransaction( + for (uint256 i = 0; i < targetsLength; ++i) { + _removeActionFromQueue( actionsSet.targets[i], actionsSet.values[i], actionsSet.signatures[i], @@ -162,25 +163,32 @@ contract Executor is IExecutor, AccessControl { actionsSet.executionTime, actionsSet.withDelegatecalls[i] ); - unchecked { - ++i; - } } emit ActionsSetCanceled(actionsSetId); } + /******************************************************************************************************************/ + /*** Admin functions ***/ + /******************************************************************************************************************/ + /// @inheritdoc IExecutor - function updateDelay(uint256 delay) external override onlyRole(DEFAULT_ADMIN_ROLE) { - _updateDelay(delay); + function updateDelay(uint256 newDelay) external override onlyRole(DEFAULT_ADMIN_ROLE) { + _updateDelay(newDelay); } /// @inheritdoc IExecutor - function updateGracePeriod(uint256 gracePeriod) external override onlyRole(DEFAULT_ADMIN_ROLE) { - if (gracePeriod < MINIMUM_GRACE_PERIOD) revert GracePeriodTooShort(); - _updateGracePeriod(gracePeriod); + function updateGracePeriod(uint256 newGracePeriod) + external override onlyRole(DEFAULT_ADMIN_ROLE) + { + if (newGracePeriod < MINIMUM_GRACE_PERIOD) revert GracePeriodTooShort(); + _updateGracePeriod(newGracePeriod); } + /******************************************************************************************************************/ + /*** External misc functions ***/ + /******************************************************************************************************************/ + /// @inheritdoc IExecutor function executeDelegateCall(address target, bytes calldata data) external @@ -195,20 +203,9 @@ contract Executor is IExecutor, AccessControl { /// @inheritdoc IExecutor function receiveFunds() external payable override {} - /// @inheritdoc IExecutor - function getDelay() external view override returns (uint256) { - return _delay; - } - - /// @inheritdoc IExecutor - function getGracePeriod() external view override returns (uint256) { - return _gracePeriod; - } - - /// @inheritdoc IExecutor - function getActionsSetCount() external view override returns (uint256) { - return _actionsSetCounter; - } + /******************************************************************************************************************/ + /*** External view functions ***/ + /******************************************************************************************************************/ /// @inheritdoc IExecutor function getActionsSetById(uint256 actionsSetId) @@ -222,33 +219,19 @@ contract Executor is IExecutor, AccessControl { /// @inheritdoc IExecutor function getCurrentState(uint256 actionsSetId) public view override returns (ActionsSetState) { - if (_actionsSetCounter <= actionsSetId) revert InvalidActionsSetId(); - ActionsSet storage actionsSet = _actionsSets[actionsSetId]; - if (actionsSet.canceled) { - return ActionsSetState.Canceled; - } else if (actionsSet.executed) { - return ActionsSetState.Executed; - } else if (block.timestamp > actionsSet.executionTime + _gracePeriod) { - return ActionsSetState.Expired; - } else { - return ActionsSetState.Queued; - } - } + if (actionsSetCount <= actionsSetId) revert InvalidActionsSetId(); - /// @inheritdoc IExecutor - function isActionQueued(bytes32 actionHash) public view override returns (bool) { - return _queuedActions[actionHash]; - } + ActionsSet storage actionsSet =_actionsSets[actionsSetId]; - function _updateDelay(uint256 delay) internal { - emit DelayUpdate(_delay, delay); - _delay = delay; + if (actionsSet.canceled) return ActionsSetState.Canceled; + else if (actionsSet.executed) return ActionsSetState.Executed; + else if (block.timestamp > actionsSet.executionTime + gracePeriod) return ActionsSetState.Expired; + else return ActionsSetState.Queued; } - function _updateGracePeriod(uint256 gracePeriod) internal { - emit GracePeriodUpdate(_gracePeriod, gracePeriod); - _gracePeriod = gracePeriod; - } + /******************************************************************************************************************/ + /*** Internal ActionSet helper functions ***/ + /******************************************************************************************************************/ function _executeTransaction( address target, @@ -260,26 +243,18 @@ contract Executor is IExecutor, AccessControl { ) internal returns (bytes memory) { if (address(this).balance < value) revert InsufficientBalance(); - bytes32 actionHash = keccak256( - abi.encode(target, value, signature, data, executionTime, withDelegatecall) - ); - _queuedActions[actionHash] = false; + _removeActionFromQueue(target, value, signature, data, executionTime, withDelegatecall); - bytes memory callData; - if (bytes(signature).length == 0) { - callData = data; - } else { - callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); - } + bytes memory callData = bytes(signature).length == 0 + ? data + : abi.encodePacked(bytes4(keccak256(bytes(signature))), data); - if (withDelegatecall) { - return this.executeDelegateCall{value: value}(target, callData); - } else { - return target.functionCallWithValue(callData, value); - } + if (withDelegatecall) return this.executeDelegateCall{value: value}(target, callData); + + return target.functionCallWithValue(callData, value); } - function _cancelTransaction( + function _removeActionFromQueue( address target, uint256 value, string memory signature, @@ -290,7 +265,21 @@ contract Executor is IExecutor, AccessControl { bytes32 actionHash = keccak256( abi.encode(target, value, signature, data, executionTime, withDelegatecall) ); - _queuedActions[actionHash] = false; + isActionQueued[actionHash] = false; + } + + /******************************************************************************************************************/ + /*** Internal admin helper functions ***/ + /******************************************************************************************************************/ + + function _updateDelay(uint256 newDelay) internal { + emit DelayUpdate(delay, newDelay); + delay = newDelay; + } + + function _updateGracePeriod(uint256 newGracePeriod) internal { + emit GracePeriodUpdate(gracePeriod, newGracePeriod); + gracePeriod = newGracePeriod; } } diff --git a/src/interfaces/IExecutor.sol b/src/interfaces/IExecutor.sol index 85a53c9..1869cf2 100644 --- a/src/interfaces/IExecutor.sol +++ b/src/interfaces/IExecutor.sol @@ -4,12 +4,16 @@ pragma solidity >=0.8.0; import { IAccessControl } from 'openzeppelin-contracts/contracts/access/IAccessControl.sol'; /** - * @title IExecutor + * @title IExecutor * @author Aave * @notice Defines the interface for the Executor */ interface IExecutor is IAccessControl { + /******************************************************************************************************************/ + /*** Errors ***/ + /******************************************************************************************************************/ + error InvalidInitParams(); error GracePeriodTooShort(); error OnlyQueuedActions(); @@ -20,6 +24,10 @@ interface IExecutor is IAccessControl { error DuplicateAction(); error InsufficientBalance(); + /******************************************************************************************************************/ + /*** Enums ***/ + /******************************************************************************************************************/ + /** * @notice This enum contains all possible actions set states */ @@ -30,16 +38,20 @@ interface IExecutor is IAccessControl { Expired } + /******************************************************************************************************************/ + /*** Events ***/ + /******************************************************************************************************************/ + /** - * @notice This struct contains the data needed to execute a specified set of actions - * @param targets Array of targets to call - * @param values Array of values to pass in each call - * @param signatures Array of function signatures to encode in each call (can be empty) - * @param calldatas Array of calldatas to pass in each call, appended to the signature at the same array index if not empty - * @param withDelegateCalls Array of whether to delegatecall for each call - * @param executionTime Timestamp starting from which the actions set can be executed - * @param executed True if the actions set has been executed, false otherwise - * @param canceled True if the actions set has been canceled, false otherwise + * @notice This struct contains the data needed to execute a specified set of actions. + * @param targets Array of targets to call. + * @param values Array of values to pass in each call. + * @param signatures Array of function signatures to encode in each call (can be empty). + * @param calldatas Array of calldatas to pass in each call, appended to the signature at the same array index if not empty. + * @param withDelegateCalls Array of whether to delegatecall for each call. + * @param executionTime Timestamp starting from which the actions set can be executed. + * @param executed True if the actions set has been executed, false otherwise. + * @param canceled True if the actions set has been canceled, false otherwise. */ struct ActionsSet { address[] targets; @@ -53,14 +65,14 @@ interface IExecutor is IAccessControl { } /** - * @dev Emitted when an ActionsSet is queued - * @param id Id of the ActionsSet - * @param targets Array of targets to be called by the actions set - * @param values Array of values to pass in each call by the actions set - * @param signatures Array of function signatures to encode in each call by the actions set - * @param calldatas Array of calldata to pass in each call by the actions set - * @param withDelegatecalls Array of whether to delegatecall for each call of the actions set - * @param executionTime The timestamp at which this actions set can be executed + * @dev Emitted when an ActionsSet is queued. + * @param id Id of the ActionsSet. + * @param targets Array of targets to be called by the actions set. + * @param values Array of values to pass in each call by the actions set. + * @param signatures Array of function signatures to encode in each call by the actions set. + * @param calldatas Array of calldata to pass in each call by the actions set. + * @param withDelegatecalls Array of whether to delegatecall for each call of the actions set. + * @param executionTime The timestamp at which this actions set can be executed. **/ event ActionsSetQueued( uint256 indexed id, @@ -73,10 +85,10 @@ interface IExecutor is IAccessControl { ); /** - * @dev Emitted when an ActionsSet is successfully executed - * @param id Id of the ActionsSet - * @param initiatorExecution The address that triggered the ActionsSet execution - * @param returnedData The returned data from the ActionsSet execution + * @dev Emitted when an ActionsSet is successfully executed. + * @param id Id of the ActionsSet. + * @param initiatorExecution The address that triggered the ActionsSet execution. + * @param returnedData The returned data from the ActionsSet execution. **/ event ActionsSetExecuted( uint256 indexed id, @@ -85,25 +97,29 @@ interface IExecutor is IAccessControl { ); /** - * @dev Emitted when an ActionsSet is cancelled by the guardian - * @param id Id of the ActionsSet + * @dev Emitted when an ActionsSet is cancelled by the guardian. + * @param id Id of the ActionsSet. **/ event ActionsSetCanceled(uint256 indexed id); /** - * @dev Emitted when the delay (between queueing and execution) is updated - * @param oldDelay The value of the old delay - * @param newDelay The value of the new delay + * @dev Emitted when the delay (between queueing and execution) is updated. + * @param oldDelay The value of the old delay. + * @param newDelay The value of the new delay. **/ event DelayUpdate(uint256 oldDelay, uint256 newDelay); /** - * @dev Emitted when the grace period (between executionTime and expiration) is updated - * @param oldGracePeriod The value of the old grace period - * @param newGracePeriod The value of the new grace period + * @dev Emitted when the grace period (between executionTime and expiration) is updated. + * @param oldGracePeriod The value of the old grace period. + * @param newGracePeriod The value of the new grace period. **/ event GracePeriodUpdate(uint256 oldGracePeriod, uint256 newGracePeriod); + /******************************************************************************************************************/ + /*** State variables ***/ + /******************************************************************************************************************/ + /** * @notice The role that allows submission of a queued action. **/ @@ -115,13 +131,48 @@ interface IExecutor is IAccessControl { function GUARDIAN_ROLE() external view returns (bytes32); /** - * @notice Queue an ActionsSet - * @dev If a signature is empty, calldata is used for the execution, calldata is appended to signature otherwise - * @param targets Array of targets to be called by the actions set - * @param values Array of values to pass in each call by the actions set - * @param signatures Array of function signatures to encode in each call by the actions (can be empty) - * @param calldatas Array of calldata to pass in each call by the actions set - * @param withDelegatecalls Array of whether to delegatecall for each call of the actions set + * @notice Returns the minimum grace period that can be set, 10 minutes. + */ + function MINIMUM_GRACE_PERIOD() external view returns (uint256); + + /** + * @notice Returns the total number of actions sets of the executor. + * @return The number of actions sets. + **/ + function actionsSetCount() external view returns (uint256); + + /** + * @notice Returns the delay (between queuing and execution) + * @return The value of the delay (in seconds) + **/ + function delay() external view returns (uint256); + + /** + * @notice Time after the execution time during which the actions set can be executed. + * @return The value of the grace period (in seconds) + **/ + function gracePeriod() external view returns (uint256); + + /** + * @notice Returns whether an actions set (by actionHash) is queued. + * @dev actionHash = keccak256(abi.encode(target, value, signature, data, executionTime, withDelegatecall)). + * @param actionHash hash of the action to be checked. + * @return True if the underlying action of actionHash is queued, false otherwise. + **/ + function isActionQueued(bytes32 actionHash) external view returns (bool); + + /******************************************************************************************************************/ + /*** ActionSet functions ***/ + /******************************************************************************************************************/ + + /** + * @notice Queue an ActionsSet. + * @dev If a signature is empty, calldata is used for the execution, calldata is appended to signature otherwise. + * @param targets Array of targets to be called by the actions set. + * @param values Array of values to pass in each call by the actions set. + * @param signatures Array of function signatures to encode in each call by the actions (can be empty). + * @param calldatas Array of calldata to pass in each call by the actions set. + * @param withDelegatecalls Array of whether to delegatecall for each call of the actions set. **/ function queue( address[] memory targets, @@ -133,34 +184,42 @@ interface IExecutor is IAccessControl { /** * @notice Execute the ActionsSet - * @param actionsSetId The id of the ActionsSet to execute + * @param actionsSetId The id of the ActionsSet to execute **/ function execute(uint256 actionsSetId) external payable; /** - * @notice Cancel the ActionsSet - * @param actionsSetId The id of the ActionsSet to cancel + * @notice Cancel the ActionsSet. + * @param actionsSetId The id of the ActionsSet to cancel. **/ function cancel(uint256 actionsSetId) external; + /******************************************************************************************************************/ + /*** Admin functions ***/ + /******************************************************************************************************************/ + /** - * @notice Update the delay, time between queueing and execution of ActionsSet - * @dev It does not affect to actions set that are already queued - * @param delay The value of the delay (in seconds) + * @notice Update the delay, time between queueing and execution of ActionsSet. + * @dev It does not affect to actions set that are already queued. + * @param delay The value of the delay (in seconds). **/ function updateDelay(uint256 delay) external; /** * @notice Update the grace period, the period after the execution time during which an actions set can be executed - * @param gracePeriod The value of the grace period (in seconds) + * @param gracePeriod The value of the grace period (in seconds). **/ function updateGracePeriod(uint256 gracePeriod) external; + /******************************************************************************************************************/ + /*** Misc functions ***/ + /******************************************************************************************************************/ + /** - * @notice Allows to delegatecall a given target with an specific amount of value - * @dev This function is external so it allows to specify a defined msg.value for the delegate call, reducing - * the risk that a delegatecall gets executed with more value than intended - * @return The bytes returned by the delegate call + * @notice Allows to delegatecall a given target with an specific amount of value. + * @dev This function is external so it allows to specify a defined msg.value for the delegate call, reducing + * the risk that a delegatecall gets executed with more value than intended. + * @return The bytes returned by the delegate call. **/ function executeDelegateCall(address target, bytes calldata data) external @@ -168,49 +227,28 @@ interface IExecutor is IAccessControl { returns (bytes memory); /** - * @notice Allows to receive funds into the executor - * @dev Useful for actionsSet that needs funds to gets executed + * @notice Allows to receive funds into the executor. + * @dev Useful for actionsSet that needs funds to gets executed. */ function receiveFunds() external payable; - /** - * @notice Returns the delay (between queuing and execution) - * @return The value of the delay (in seconds) - **/ - function getDelay() external view returns (uint256); - - /** - * @notice Returns the grace period - * @return The value of the grace period (in seconds) - **/ - function getGracePeriod() external view returns (uint256); - - /** - * @notice Returns the total number of actions sets of the executor - * @return The number of actions sets - **/ - function getActionsSetCount() external view returns (uint256); + /******************************************************************************************************************/ + /*** View functions ***/ + /******************************************************************************************************************/ - /** - * @notice Returns the data of an actions set - * @param actionsSetId The id of the ActionsSet - * @return The data of the ActionsSet - **/ - function getActionsSetById(uint256 actionsSetId) external view returns (ActionsSet memory); /** - * @notice Returns the current state of an actions set - * @param actionsSetId The id of the ActionsSet - * @return The current state of theI ActionsSet + * @notice Returns the data of an actions set. + * @param actionsSetId The id of the ActionsSet. + * @return The data of the ActionsSet. **/ - function getCurrentState(uint256 actionsSetId) external view returns (ActionsSetState); + function getActionsSetById(uint256 actionsSetId) external view returns (ActionsSet memory); - /** - * @notice Returns whether an actions set (by actionHash) is queued - * @dev actionHash = keccak256(abi.encode(target, value, signature, data, executionTime, withDelegatecall)) - * @param actionHash hash of the action to be checked - * @return True if the underlying action of actionHash is queued, false otherwise - **/ - function isActionQueued(bytes32 actionHash) external view returns (bool); + /** + * @notice Returns the current state of an actions set. + * @param actionsSetId The id of the ActionsSet. + * @return The current state of theI ActionsSet. + **/ + function getCurrentState(uint256 actionsSetId) external view returns (ActionsSetState); } diff --git a/test/CrosschainTestBase.sol b/test/CrosschainTestBase.sol index 33d5dc6..ebb211c 100644 --- a/test/CrosschainTestBase.sol +++ b/test/CrosschainTestBase.sol @@ -314,11 +314,11 @@ abstract contract CrosschainTestBase is Test { }); assertEq( - bridgeExecutor.getDelay(), + bridgeExecutor.delay(), defaultL2BridgeExecutorArgs.delay ); assertEq( - bridgeExecutor.getGracePeriod(), + bridgeExecutor.gracePeriod(), defaultL2BridgeExecutorArgs.gracePeriod ); assertEq( @@ -357,11 +357,11 @@ abstract contract CrosschainTestBase is Test { bridgeExecutor.execute(0); assertEq( - bridgeExecutor.getDelay(), + bridgeExecutor.delay(), newL2BridgeExecutorParams.delay ); assertEq( - bridgeExecutor.getGracePeriod(), + bridgeExecutor.gracePeriod(), newL2BridgeExecutorParams.gracePeriod ); assertEq( diff --git a/test/Executor.t.sol b/test/Executor.t.sol index ccb29f8..ec138bc 100644 --- a/test/Executor.t.sol +++ b/test/Executor.t.sol @@ -65,8 +65,8 @@ contract ExecutorTestBase is Test { function setUp() public { executor = new Executor({ - delay: DELAY, - gracePeriod: GRACE_PERIOD + delay_: DELAY, + gracePeriod_: GRACE_PERIOD }); executor.grantRole(executor.SUBMISSION_ROLE(), bridge); executor.grantRole(executor.GUARDIAN_ROLE(), guardian); @@ -154,13 +154,13 @@ contract ExecutorConstructorTests is ExecutorTestBase { function test_constructor_invalidInitParams_boundary() public { vm.expectRevert(abi.encodeWithSignature("InvalidInitParams()")); executor = new Executor({ - delay: DELAY, - gracePeriod: 10 minutes - 1 + delay_: DELAY, + gracePeriod_: 10 minutes - 1 }); executor = new Executor({ - delay: DELAY, - gracePeriod: 10 minutes + delay_: DELAY, + gracePeriod_: 10 minutes }); } @@ -170,12 +170,12 @@ contract ExecutorConstructorTests is ExecutorTestBase { vm.expectEmit(); emit GracePeriodUpdate(0, GRACE_PERIOD); executor = new Executor({ - delay: DELAY, - gracePeriod: GRACE_PERIOD + delay_: DELAY, + gracePeriod_: GRACE_PERIOD }); - assertEq(executor.getDelay(), DELAY); - assertEq(executor.getGracePeriod(), GRACE_PERIOD); + assertEq(executor.delay(), DELAY); + assertEq(executor.gracePeriod(), GRACE_PERIOD); assertEq(executor.hasRole(executor.DEFAULT_ADMIN_ROLE(), address(this)), true); assertEq(executor.hasRole(executor.DEFAULT_ADMIN_ROLE(), address(executor)), true); @@ -231,7 +231,7 @@ contract ExecutorQueueTests is ExecutorTestBase { bytes32 actionHash1 = _encodeHash(action, block.timestamp + DELAY); bytes32 actionHash2 = _encodeHash(action, block.timestamp + DELAY + 1); - assertEq(executor.getActionsSetCount(), 0); + assertEq(executor.actionsSetCount(), 0); assertEq(executor.isActionQueued(actionHash1), false); assertEq(executor.isActionQueued(actionHash2), false); @@ -247,7 +247,7 @@ contract ExecutorQueueTests is ExecutorTestBase { ); _queueAction(action); - assertEq(executor.getActionsSetCount(), 1); + assertEq(executor.actionsSetCount(), 1); assertEq(executor.isActionQueued(actionHash1), true); assertEq(executor.isActionQueued(actionHash2), false); _assertActionSet({ @@ -272,7 +272,7 @@ contract ExecutorQueueTests is ExecutorTestBase { ); _queueAction(action); - assertEq(executor.getActionsSetCount(), 2); + assertEq(executor.actionsSetCount(), 2); assertEq(executor.isActionQueued(actionHash1), true); assertEq(executor.isActionQueued(actionHash2), true); _assertActionSet({ @@ -289,14 +289,14 @@ contract ExecutorQueueTests is ExecutorTestBase { contract ExecutorExecuteTests is ExecutorTestBase { function test_execute_actionsSetIdTooHigh_boundary() public { - assertEq(executor.getActionsSetCount(), 0); + assertEq(executor.actionsSetCount(), 0); vm.expectRevert(abi.encodeWithSignature("InvalidActionsSetId()")); executor.execute(0); _queueAction(); skip(DELAY); - assertEq(executor.getActionsSetCount(), 1); + assertEq(executor.actionsSetCount(), 1); executor.execute(0); } @@ -304,7 +304,7 @@ contract ExecutorExecuteTests is ExecutorTestBase { _queueAction(); vm.prank(guardian); executor.cancel(0); - + vm.expectRevert(abi.encodeWithSignature("OnlyQueuedActions()")); executor.execute(0); } @@ -314,7 +314,7 @@ contract ExecutorExecuteTests is ExecutorTestBase { skip(DELAY); executor.execute(0); - + vm.expectRevert(abi.encodeWithSignature("OnlyQueuedActions()")); executor.execute(0); } @@ -322,7 +322,7 @@ contract ExecutorExecuteTests is ExecutorTestBase { function test_execute_notQueued_expired_boundary() public { _queueAction(); skip(DELAY + GRACE_PERIOD + 1); - + vm.expectRevert(abi.encodeWithSignature("OnlyQueuedActions()")); executor.execute(0); @@ -334,7 +334,7 @@ contract ExecutorExecuteTests is ExecutorTestBase { function test_execute_timelockNotFinished_boundary() public { _queueAction(); skip(DELAY - 1); - + vm.expectRevert(abi.encodeWithSignature("TimelockNotFinished()")); executor.execute(0); @@ -536,7 +536,7 @@ contract ExecutorCancelTests is ExecutorTestBase { } function test_cancel_actionsSetIdTooHigh_boundary() public { - assertEq(executor.getActionsSetCount(), 0); + assertEq(executor.actionsSetCount(), 0); vm.expectRevert(abi.encodeWithSignature("InvalidActionsSetId()")); vm.prank(guardian); executor.cancel(0); @@ -544,7 +544,7 @@ contract ExecutorCancelTests is ExecutorTestBase { _queueAction(); skip(DELAY); - assertEq(executor.getActionsSetCount(), 1); + assertEq(executor.actionsSetCount(), 1); vm.prank(guardian); executor.cancel(0); } @@ -553,7 +553,7 @@ contract ExecutorCancelTests is ExecutorTestBase { _queueAction(); vm.prank(guardian); executor.cancel(0); - + vm.expectRevert(abi.encodeWithSignature("OnlyQueuedActions()")); vm.prank(guardian); executor.cancel(0); @@ -564,7 +564,7 @@ contract ExecutorCancelTests is ExecutorTestBase { skip(DELAY); executor.execute(0); - + vm.expectRevert(abi.encodeWithSignature("OnlyQueuedActions()")); vm.prank(guardian); executor.cancel(0); @@ -573,7 +573,7 @@ contract ExecutorCancelTests is ExecutorTestBase { function test_cancel_notQueued_expired_boundary() public { _queueAction(); skip(DELAY + GRACE_PERIOD + 1); - + vm.expectRevert(abi.encodeWithSignature("OnlyQueuedActions()")); vm.prank(guardian); executor.cancel(0); @@ -613,14 +613,14 @@ contract ExecutorUpdateTests is ExecutorTestBase { } function test_updateDelay() public { - assertEq(executor.getDelay(), 1 days); + assertEq(executor.delay(), 1 days); vm.expectEmit(address(executor)); emit DelayUpdate(1 days, 2 days); vm.prank(address(executor)); executor.updateDelay(2 days); - assertEq(executor.getDelay(), 2 days); + assertEq(executor.delay(), 2 days); } function test_updateGracePeriod_notSelf() public { @@ -638,14 +638,14 @@ contract ExecutorUpdateTests is ExecutorTestBase { } function test_updateGracePeriod() public { - assertEq(executor.getGracePeriod(), 30 days); + assertEq(executor.gracePeriod(), 30 days); vm.expectEmit(address(executor)); emit GracePeriodUpdate(30 days, 60 days); vm.prank(address(executor)); executor.updateGracePeriod(60 days); - assertEq(executor.getGracePeriod(), 60 days); + assertEq(executor.gracePeriod(), 60 days); } }