From 0fab0b1b78d94534a851c6fb6569ecba97f463be Mon Sep 17 00:00:00 2001 From: 0xAA Date: Fri, 12 Aug 2022 16:25:33 +0800 Subject: [PATCH 1/3] Update Timelock.sol --- contracts/Timelock.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/Timelock.sol b/contracts/Timelock.sol index 69dcf3c1c..2ee122eea 100644 --- a/contracts/Timelock.sol +++ b/contracts/Timelock.sol @@ -73,6 +73,8 @@ contract Timelock { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); + require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); + queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); From ebbd9e58fe690039b8fe1e29963662085df77d4d Mon Sep 17 00:00:00 2001 From: 0xAA Date: Fri, 12 Aug 2022 22:32:10 +0800 Subject: [PATCH 2/3] Update Timelock.sol --- contracts/Timelock.sol | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/contracts/Timelock.sol b/contracts/Timelock.sol index 2ee122eea..e0bc9dc67 100644 --- a/contracts/Timelock.sol +++ b/contracts/Timelock.sol @@ -1,10 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.8.10; -import "./SafeMath.sol"; - contract Timelock { - using SafeMath for uint; event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); @@ -24,7 +21,7 @@ contract Timelock { mapping (bytes32 => bool) public queuedTransactions; - constructor(address admin_, uint delay_) public { + constructor(address admin_, uint delay_) { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); @@ -60,7 +57,7 @@ contract Timelock { function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); - require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay."); + require(eta >= getBlockTimestamp() + delay, "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; @@ -86,7 +83,7 @@ contract Timelock { bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); - require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale."); + require(getBlockTimestamp() <= eta + GRACE_PERIOD, "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false; From 57ebf3d70e493e3f4d19bee62546aa133e30e2b0 Mon Sep 17 00:00:00 2001 From: 0xAA Date: Fri, 12 Aug 2022 22:36:28 +0800 Subject: [PATCH 3/3] Update Timelock.sol --- contracts/Timelock.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/Timelock.sol b/contracts/Timelock.sol index e0bc9dc67..51a6bf740 100644 --- a/contracts/Timelock.sol +++ b/contracts/Timelock.sol @@ -70,7 +70,7 @@ contract Timelock { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); - require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); + require(queuedTransactions[txHash], "Timelock::cancelTransaction: Transaction hasn't been queued."); queuedTransactions[txHash] = false;