* Fix F-3: Explicit Variable Return audit report * Reuse onlySecurityCouncil modifier and update its revert message * Fix F-5: modifier Optimization audit report * Fix F-7: Input Sanity Check audit report * Add audit report * Further gas optimise getting a checkpoint function by up to 100 gas * Fix F-6: return Statement Optimization audit report * Wrap logic in unchecked block to save 24 gas in getVotes and getQuadraticVotes each * Move audit doc into a dedicated folder
71 lines
2.6 KiB
Solidity
71 lines
2.6 KiB
Solidity
// SPDX-License-Identifier: Apache-2.0
|
|
/*
|
|
|
|
Copyright 2023 ZeroEx Intl.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
*/
|
|
pragma solidity ^0.8.19;
|
|
|
|
import "@openzeppelin/governance/TimelockController.sol";
|
|
|
|
contract ZeroExTimelock is TimelockController {
|
|
// minDelay is how long you have to wait before executing
|
|
// proposers is the list of addresses that can propose
|
|
// executors is the list of addresses that can execute
|
|
constructor(
|
|
uint256 minDelay,
|
|
address[] memory proposers,
|
|
address[] memory executors,
|
|
address admin
|
|
) TimelockController(minDelay, proposers, executors, admin) {}
|
|
|
|
/**
|
|
* @dev Execute a batch of rollback transactions. Similar to TimelockController.executeBatch function but without
|
|
* the timelock checks.
|
|
* Emits one {CallExecuted} event per transaction in the batch.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - the caller must have the 'executor' role.
|
|
*/
|
|
function executeRollbackBatch(
|
|
address[] calldata targets,
|
|
uint256[] calldata values,
|
|
bytes[] calldata payloads,
|
|
bytes32 predecessor,
|
|
bytes32 salt
|
|
) public payable onlyRoleOrOpenRole(EXECUTOR_ROLE) {
|
|
require(targets.length > 0, "ZeroExTimelock: empty targets");
|
|
require(targets.length == values.length, "ZeroExTimelock: length mismatch");
|
|
require(targets.length == payloads.length, "ZeroExTimelock: length mismatch");
|
|
|
|
bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);
|
|
|
|
for (uint256 i = 0; i < targets.length; ++i) {
|
|
address target = targets[i];
|
|
uint256 value = values[i];
|
|
bytes calldata payload = payloads[i];
|
|
// Check this is a rollback transaction
|
|
// function signature for rollback(bytes4,address)
|
|
// = bytes4(keccak256("rollback(bytes4,address)"))
|
|
// = 0x9db64a40
|
|
require(bytes4(payload) == bytes4(0x9db64a40), "ZeroExTimelock: not rollback");
|
|
|
|
_execute(target, value, payload);
|
|
emit CallExecuted(id, i, target, value, payload);
|
|
}
|
|
}
|
|
}
|