-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c12da4
commit 2b5d16a
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[L1] Long array loop may cause out of gas revert. | ||
In Timelock contract, when we pause the timelock, we will remove all proposals from the _liveProposals. | ||
The problem is that if there are lots of pending, ready proposals, the pause function might be reverted because of out of gas. | ||
|
||
```solidity | ||
function pause() public override { | ||
/// check that msg.sender is the pause guardian, pause the contract | ||
super.pause(); | ||
bytes32[] memory proposals = _liveProposals.values(); | ||
for (uint256 i = 0; i < proposals.length; i++) { | ||
bytes32 id = proposals[i]; | ||
delete timestamps[id]; // Here we delete this timestamp, so we can create another same proposal again. | ||
assert(_liveProposals.remove(id)); // remove from live proposals. | ||
emit Cancelled(id); | ||
} | ||
} | ||
``` |