Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audit: No Setter for Delay in TimelockExecutionStrategy #213

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions src/execution-strategies/TimelockExecutionStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ contract TimelockExecutionStrategy is SimpleQuorumExecutionStrategy, IERC1155Rec
/// @param newVetoGuardian The new veto guardian.
event VetoGuardianSet(address vetoGuardian, address newVetoGuardian);

/// @notice Emitted when the timelock delay is set.
/// @param timelockDelay The old timelock delay.
/// @param newTimelockDelay The new timelock delay.
event TimelockDelaySet(uint256 timelockDelay, uint256 newTimelockDelay);

/// @notice Emitted when a proposal is vetoed.
/// @param executionPayloadHash The hash of the proposal execution payload.
event ProposalVetoed(bytes32 executionPayloadHash);
Expand Down Expand Up @@ -183,6 +188,11 @@ contract TimelockExecutionStrategy is SimpleQuorumExecutionStrategy, IERC1155Rec
vetoGuardian = newVetoGuardian;
}

function setTimelockDelay(uint256 newTimelockDelay) external onlyOwner {
emit TimelockDelaySet(timelockDelay, newTimelockDelay);
timelockDelay = newTimelockDelay;
}

/// @dev Throws if called by any account other than the veto guardian.
modifier onlyVetoGuardian() {
if (msg.sender != vetoGuardian) revert OnlyVetoGuardian();
Expand Down
16 changes: 16 additions & 0 deletions test/TimelockExecutionStrategy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ abstract contract TimelockExecutionStrategyTest is SpaceTest {
);
event TransactionQueued(MetaTransaction transaction, uint256 executionTime);
event ProposalVetoed(bytes32 executionPayloadHash);
event TimelockDelaySet(uint256 timelockDelay, uint256 newTimelockDelay);
event VetoGuardianSet(address vetoGuardian, address newVetoGuardian);

TimelockExecutionStrategy public timelockExecutionStrategy;
Expand Down Expand Up @@ -334,6 +335,21 @@ abstract contract TimelockExecutionStrategyTest is SpaceTest {
assertEq(recipient.balance, 1);
}

function testSetTimelockDelay() external {
uint256 newTimelockDelay = 1000;
vm.expectEmit(true, true, true, true);
emit TimelockDelaySet(timelockExecutionStrategy.timelockDelay(), newTimelockDelay);
timelockExecutionStrategy.setTimelockDelay(newTimelockDelay);
assertEq(timelockExecutionStrategy.timelockDelay(), newTimelockDelay);
}

function testSetTimelockDelayUnauthorized() external {
vm.prank(unauthorized);
uint256 newTimelockDelay = 1000;
vm.expectRevert("Ownable: caller is not the owner");
timelockExecutionStrategy.setTimelockDelay(newTimelockDelay);
}

function testVetoProposal() external {
MetaTransaction[] memory transactions = new MetaTransaction[](1);
transactions[0] = MetaTransaction(recipient, 1, "", Enum.Operation.Call, 0);
Expand Down