diff --git a/packages/contracts/src/core/dao/DAO.sol b/packages/contracts/src/core/dao/DAO.sol index 8dcc24b89..35f245d29 100644 --- a/packages/contracts/src/core/dao/DAO.sol +++ b/packages/contracts/src/core/dao/DAO.sol @@ -152,7 +152,7 @@ contract DAO is address _initialOwner, address _trustedForwarder, string calldata daoURI_ - ) external reinitializer(2) { + ) external reinitializer(3) { _reentrancyStatus = _NOT_ENTERED; // added in v1.3.0 _registerInterface(type(IDAO).interfaceId); @@ -173,7 +173,7 @@ contract DAO is function initializeFrom( uint8[3] calldata _previousProtocolVersion, bytes calldata _initData - ) external reinitializer(2) { + ) external reinitializer(3) { _initData; // Silences the unused function parameter warning. // Check that the contract is not upgrading from a different major release. diff --git a/packages/contracts/test/core/dao/dao.ts b/packages/contracts/test/core/dao/dao.ts index 95c36f226..4137b04dd 100644 --- a/packages/contracts/test/core/dao/dao.ts +++ b/packages/contracts/test/core/dao/dao.ts @@ -204,7 +204,7 @@ describe('DAO', function () { ); }); - it('sets OZs `_initialized` at storage slot [0] to 2', async () => { + it('sets OZs `_initialized` at storage slot [0] to 3', async () => { expect( ethers.BigNumber.from( await ethers.provider.getStorageAt( @@ -212,7 +212,7 @@ describe('DAO', function () { OZ_INITIALIZED_SLOT_POSITION ) ).toNumber() - ).to.equal(2); + ).to.equal(3); }); it('sets the `_reentrancyStatus` at storage slot [304] to `_NOT_ENTERED = 1`', async () => { @@ -239,11 +239,11 @@ describe('DAO', function () { .withArgs([0, 1, 0]); }); - it('initializes `_reentrancyStatus` for versions < 1.3.0', async () => { + it('increments `_initialized` to `3`', async () => { // Create an unitialized DAO. const uninitializedDao = await deployWithProxy(DAO); - // Expect the contract to be uninitialized with `_initialized = 0` and `_reentrancyStatus = 0`. + // Expect the contract to be uninitialized with `_initialized = 0`. expect( ethers.BigNumber.from( await ethers.provider.getStorageAt( @@ -252,28 +252,42 @@ describe('DAO', function () { ) ).toNumber() ).to.equal(0); + + // Call `initializeFrom` with version 1.2.0. + await expect(uninitializedDao.initializeFrom([1, 2, 0], EMPTY_DATA)).to + .not.be.reverted; + + // Expect the contract to be initialized with `_initialized = 3`. expect( ethers.BigNumber.from( await ethers.provider.getStorageAt( uninitializedDao.address, - REENTRANCY_STATUS_SLOT_POSITION + OZ_INITIALIZED_SLOT_POSITION ) ).toNumber() - ).to.equal(0); + ).to.equal(3); + }); - // Call `initializeFrom` with version 1.2.0. - await expect(uninitializedDao.initializeFrom([1, 2, 0], EMPTY_DATA)).to - .not.be.reverted; + it('initializes `_reentrancyStatus` for versions < 1.3.0', async () => { + // Create an unitialized DAO. + const uninitializedDao = await deployWithProxy(DAO); + + // Expect the contract to be uninitialized with `_reentrancyStatus = 0`. - // Expect the contract to be initialized with `_initialized = 2` and `_reentrancyStatus = 1`. expect( ethers.BigNumber.from( await ethers.provider.getStorageAt( uninitializedDao.address, - OZ_INITIALIZED_SLOT_POSITION + REENTRANCY_STATUS_SLOT_POSITION ) ).toNumber() - ).to.equal(2); + ).to.equal(0); + + // Call `initializeFrom` with version 1.2.0. + await expect(uninitializedDao.initializeFrom([1, 2, 0], EMPTY_DATA)).to + .not.be.reverted; + + // Expect the contract to be initialized with `_reentrancyStatus = 1`. expect( ethers.BigNumber.from( await ethers.provider.getStorageAt( @@ -288,15 +302,8 @@ describe('DAO', function () { // Create an unitialized DAO. const uninitializedDao = await deployWithProxy(DAO); - // Expect the contract to be uninitialized with `_initialized = 0` and `_reentrancyStatus = 0`. - expect( - ethers.BigNumber.from( - await ethers.provider.getStorageAt( - uninitializedDao.address, - OZ_INITIALIZED_SLOT_POSITION - ) - ).toNumber() - ).to.equal(0); + // Expect the contract to be uninitialized with `_reentrancyStatus = 0`. + expect( ethers.BigNumber.from( await ethers.provider.getStorageAt( @@ -310,15 +317,8 @@ describe('DAO', function () { await expect(uninitializedDao.initializeFrom([1, 3, 0], EMPTY_DATA)).to .not.be.reverted; - // Expect the contract to be initialized with `_initialized = 2` but `_reentrancyStatus` to remain unchanged. - expect( - ethers.BigNumber.from( - await ethers.provider.getStorageAt( - uninitializedDao.address, - OZ_INITIALIZED_SLOT_POSITION - ) - ).toNumber() - ).to.equal(2); + // Expect `_reentrancyStatus` to remain unchanged. + expect( ethers.BigNumber.from( await ethers.provider.getStorageAt(