Skip to content

Commit

Permalink
Spearbit Audit Changes (#25)
Browse files Browse the repository at this point in the history
* admin is already default admin role by default

* merge dupe grace period check

* spacing

* remove unused param

* better wording on comment
  • Loading branch information
hexonaut authored Aug 22, 2024
1 parent 38da912 commit 5c16676
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
13 changes: 2 additions & 11 deletions src/Executor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,9 @@ contract Executor is IExecutor, AccessControl {
uint256 delay_,
uint256 gracePeriod_
) {
if (
gracePeriod_ < MINIMUM_GRACE_PERIOD
) revert InvalidInitParams();

_updateDelay(delay_);
_updateGracePeriod(gracePeriod_);

_setRoleAdmin(SUBMISSION_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(GUARDIAN_ROLE, DEFAULT_ADMIN_ROLE);

_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(DEFAULT_ADMIN_ROLE, address(this)); // Necessary for self-referential calls to change configuration
}
Expand Down Expand Up @@ -120,7 +113,6 @@ contract Executor is IExecutor, AccessControl {
actionsSet.values[i],
actionsSet.signatures[i],
actionsSet.calldatas[i],
actionsSet.executionTime,
actionsSet.withDelegatecalls[i]
);
}
Expand Down Expand Up @@ -151,7 +143,6 @@ contract Executor is IExecutor, AccessControl {
function updateGracePeriod(uint256 newGracePeriod)
external override onlyRole(DEFAULT_ADMIN_ROLE)
{
if (newGracePeriod < MINIMUM_GRACE_PERIOD) revert GracePeriodTooShort();
_updateGracePeriod(newGracePeriod);
}

Expand Down Expand Up @@ -191,7 +182,7 @@ contract Executor is IExecutor, AccessControl {
function getCurrentState(uint256 actionsSetId) public view override returns (ActionsSetState) {
if (actionsSetCount <= actionsSetId) revert InvalidActionsSetId();

ActionsSet storage actionsSet =_actionsSets[actionsSetId];
ActionsSet storage actionsSet = _actionsSets[actionsSetId];

if (actionsSet.canceled) return ActionsSetState.Canceled;
else if (actionsSet.executed) return ActionsSetState.Executed;
Expand All @@ -208,7 +199,6 @@ contract Executor is IExecutor, AccessControl {
uint256 value,
string memory signature,
bytes memory data,
uint256 executionTime,
bool withDelegatecall
) internal returns (bytes memory) {
if (address(this).balance < value) revert InsufficientBalance();
Expand All @@ -232,6 +222,7 @@ contract Executor is IExecutor, AccessControl {
}

function _updateGracePeriod(uint256 newGracePeriod) internal {
if (newGracePeriod < MINIMUM_GRACE_PERIOD) revert GracePeriodTooShort();
emit GracePeriodUpdate(gracePeriod, newGracePeriod);
gracePeriod = newGracePeriod;
}
Expand Down
3 changes: 1 addition & 2 deletions src/interfaces/IExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface IExecutor is IAccessControl {
/*** Errors ***/
/******************************************************************************************************************/

error InvalidInitParams();
error GracePeriodTooShort();
error OnlyQueuedActions();
error TimelockNotFinished();
Expand Down Expand Up @@ -161,7 +160,7 @@ interface IExecutor is IAccessControl {
* @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 signatures Array of function signatures to encode in each call by the actions which can be empty strings.
* @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.
**/
Expand Down
2 changes: 1 addition & 1 deletion test/Executor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ contract ExecutorTestBase is Test {
contract ExecutorConstructorTests is ExecutorTestBase {

function test_constructor_invalidInitParams_boundary() public {
vm.expectRevert(abi.encodeWithSignature("InvalidInitParams()"));
vm.expectRevert(abi.encodeWithSignature("GracePeriodTooShort()"));
executor = new Executor({
delay_: DELAY,
gracePeriod_: 10 minutes - 1
Expand Down

0 comments on commit 5c16676

Please sign in to comment.