Skip to content

Commit 51e1161

Browse files
Transpile f685729
1 parent b7a3d6a commit 51e1161

File tree

5 files changed

+83
-4
lines changed

5 files changed

+83
-4
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
1618
- uses: actions/setup-node@v3
1719
with:
1820
node-version: 12.x
@@ -24,8 +26,14 @@ jobs:
2426
restore-keys: npm-v2-
2527
- run: npm ci
2628
if: steps.cache.outputs.cache-hit != 'true'
29+
- run: bash scripts/upgradeable/git-user-config.sh
30+
- run: bash scripts/upgradeable/merge-upstream.sh
31+
env:
32+
REF: 'refs/heads/patches'
33+
BASE_REF: HEAD
34+
if: ${{ github.base_ref || github.ref }} == 'refs/heads/patches'
2735
- run: bash scripts/upgradeable/transpile.sh
28-
if: github.event_name == 'pull_request'
36+
if: ${{ github.base_ref || github.ref }} == 'refs/heads/patches'
2937
- run: npm run test
3038
env:
3139
FORCE_COLOR: 1

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
* `Initializable`: add an Initialized event that tracks initialized version numbers. ([#3294](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3294))
2424
* `ERC2981`: make `royaltiInfo` public to allow super call in overrides. ([#3305](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3305))
2525

26+
### Upgradeability notice
27+
28+
* `TimelockController`: **(Action needed)** The upgrade from <4.6 to >=4.6 introduces a new `CANCELLER_ROLE` that requires set up to be assignable. After the upgrade, only addresses with this role will have the ability to cancel. Proposers will no longer be able to cancel. Assigning cancellers can be done by an admin (including the timelock itself) once the role admin is set up. To do this, we recommend upgrading to the `TimelockControllerWith46MigrationUpgradeable` contract and then calling the `migrateTo46` function.
29+
2630
### Breaking changes
2731

2832
* `Governor`: Adds internal virtual `_getVotes` method that must be implemented; this is a breaking change for existing concrete extensions to `Governor`. To fix this on an existing voting module extension, rename `getVotes` to `_getVotes` and add a `bytes memory` argument. ([#3043](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3043))
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts v4.6.0 (governance/TimelockControllerWith46Migration.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import "./TimelockControllerUpgradeable.sol";
7+
import "../proxy/utils/Initializable.sol";
8+
9+
/**
10+
* @dev Extension of the TimelockController that includes an additional
11+
* function to migrate from OpenZeppelin Upgradeable Contracts <4.6 to >=4.6.
12+
*
13+
* This migration is necessary to setup administration rights over the new
14+
* `CANCELLER_ROLE`.
15+
*
16+
* The migration is trustless and can be performed by anyone.
17+
*
18+
* _Available since v4.6._
19+
*/
20+
contract TimelockControllerWith46MigrationUpgradeable is Initializable, TimelockControllerUpgradeable {
21+
function __TimelockControllerWith46Migration_init(
22+
uint256 minDelay,
23+
address[] memory proposers,
24+
address[] memory executors
25+
) internal onlyInitializing {
26+
__TimelockController_init_unchained(minDelay, proposers, executors);
27+
}
28+
29+
function __TimelockControllerWith46Migration_init_unchained(
30+
uint256,
31+
address[] memory,
32+
address[] memory
33+
) internal onlyInitializing {}
34+
35+
/**
36+
* @dev Migration function. Running it is necessary for upgradeable
37+
* instances that were initially setup with code <4.6 and that upgraded
38+
* to >=4.6.
39+
*/
40+
function migrateTo46() public virtual {
41+
require(
42+
getRoleAdmin(PROPOSER_ROLE) == TIMELOCK_ADMIN_ROLE && getRoleAdmin(CANCELLER_ROLE) == DEFAULT_ADMIN_ROLE,
43+
"TimelockController: already migrated"
44+
);
45+
_setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);
46+
}
47+
48+
/**
49+
* @dev This empty reserved space is put in place to allow future versions to add new
50+
* variables without shifting down storage in the inheritance chain.
51+
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
52+
*/
53+
uint256[50] private __gap;
54+
}

contracts/mocks/WithInit.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ contract TimelockControllerUpgradeableWithInit is TimelockControllerUpgradeable
1919
__TimelockController_init(minDelay, proposers, executors);
2020
}
2121
}
22+
import "../governance/TimelockControllerWith46MigrationUpgradeable.sol";
23+
24+
contract TimelockControllerWith46MigrationUpgradeableWithInit is TimelockControllerWith46MigrationUpgradeable {
25+
constructor(
26+
uint256 minDelay,
27+
address[] memory proposers,
28+
address[] memory executors
29+
) payable initializer {
30+
__TimelockControllerWith46Migration_init(minDelay, proposers, executors);
31+
}
32+
}
2233
import "./ERC165CheckerMockUpgradeable.sol";
2334

2435
contract ERC165CheckerMockUpgradeableWithInit is ERC165CheckerMockUpgradeable {

scripts/upgradeable/merge-upstream.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -euo pipefail
44

55
: "${REF:="$(git rev-parse --symbolic-full-name HEAD)"}"
6+
: "${BASE_REF:=refs/heads/origin/patches}"
67

78
if [[ "$REF" != refs/heads/* ]]; then
89
echo "$REF is not a branch" >&2
@@ -16,16 +17,17 @@ set -x
1617
input="${REF#refs/heads/}"
1718
upstream="${input#patched/}"
1819
branch="patched/$upstream"
20+
base="${BASE_REF}"
1921

20-
git checkout "$branch" 2>/dev/null || git checkout -b "$branch" origin/patches --no-track
22+
git checkout "$branch" 2>/dev/null || git checkout -b "$branch" "$base" --no-track
2123

2224
git fetch 'https://github.com/OpenZeppelin/openzeppelin-contracts.git' master
23-
merge_base="$(git merge-base origin/patches FETCH_HEAD)"
25+
merge_base="$(git merge-base "$base" FETCH_HEAD)"
2426

2527
git fetch 'https://github.com/OpenZeppelin/openzeppelin-contracts.git' "$upstream"
2628
# Check that patches is not ahead of the upstream branch we're merging.
2729
if ! git merge-base --is-ancestor "$merge_base" FETCH_HEAD; then
2830
echo "The patches branch is ahead of $upstream" >&2
2931
exit 1
3032
fi
31-
git merge origin/patches FETCH_HEAD -m "Merge upstream $upstream into $branch"
33+
git merge "$base" FETCH_HEAD -m "Merge upstream $upstream into $branch"

0 commit comments

Comments
 (0)