-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy script for the protocol and plugin upgrades (#384)
* feat: protect the DAO executor against reentrancy * fix: remove console.log * fix: prevent storage corruption * feat: refactored reentrancy guard into a modifier * feat: added tests and preliminary versioning * chore: cleaning * fix: remove empty comment * fix: refactor findEventTopicLog function * fix: moved implementation slot and renamed file * fix: remove redundant includes * prepare package * remember the branch * only artifact src * correct the paths * correct root path * update hashes * add logs * only copy typechain * generate typechain * setup rollup * update npm packages * update rollup index * add esm cjs * add readme * remove gitIgnore * update typechain * update typescript * convert script to typescript * change commit hash json * rename types to typechain * add test * add json to rollup and export types * update usage test * generate index.ts dynamically * update readme * add empty line * update commit hashes * fix index.ts * chore: update test * fix: removed redundant imports * chore: remove legacy version files of DAO * fix: adapt contracts-version tests * fix: remove version in title as contracts will get a constant * fix: compile legacy contracts for regression testing * Revert "fix: compile legacy contracts for regression testing " This reverts commit 403436c. * revert versioning changes * adapt tests * test with creating symbolic link * correct path * feat: added tests for proposal start and end date handling * fix: corrected wrong validation order * Revert "chore: remove legacy version files of DAO" This reverts commit 57f755c. * add legacy versions * fix: renaming of the versions * chore: remove old CI task * chore: maintained changelog * fix: version numbers * fix: imports * WIP * doc: clarified the origin of the implementation slot * fix: versioning * fix: move files * Apply suggestions from code review Co-authored-by: Jør∂¡ <[email protected]> * chore: formatting * chore: remove NatSpec version number from osx files * feat: added more tests * Applied review suggestion Co-authored-by: Rekard0 <[email protected]> * feat: added test checking that execution is still possible after the upgrade * Improved comments * feat: initialize _rentrancyStatus * doc: clarify comments * fix: change version number * fix: use upgradeToAndCall and correct versions * feat: added initializeUpgradeFrom function and tests * feat: improved function and added more tests * WIP * fix: tests * fix: finalize tests * fix typechain and add a script * fix: typo * feat: improve initializeUpgradeFrom * feat: added _initData parameter * feat: added test * fix: wrong version number * WIP * fix remaining tests * fix subgraph * add ref depth * fix: replacing getContractFactory and getContractAt by typechain factory calls and added missing awaits * fix: test timings * fix: re-introduced yarn postinstall * fix: remove redundant includes * fix: adapt upgrade tests * feat: optimize if statements * fix: tests * feat: rename initializeUpgradeFrom to initializeFrom * fix: correct test description * fix: removed duplicate file * fix: typo * fix: delete legacy files * revert: metadata changes as they will happen in #375 * fix: merge conflicts * fix: re-order changelog entries * fix: remove wrong/redundant import originating from merge * feat: improve upgrade version checks * fix: remove redundant ROOT_PERMISSION grant call * feat: added more checks to the upgrade tests * feat: more explicit variable naming * fix: reworked initializeFrom logic * feat: improved changelog entry * feat: improved comment * fix: use factories * feat: added deploy scripts * fix: use the correct deployment method * chore: remove the old, unused script for the v1.2.0 update * fix: use deploy method fix: use deploy method * fix: file name * feat: improve scripts by adding a TARGET_RELEASE variable * fix: file name * fix: wrong interface * fix: import order --------- Co-authored-by: Rekard0 <[email protected]> Co-authored-by: Jør∂¡ <[email protected]>
- Loading branch information
1 parent
14d5fe6
commit 43a5f39
Showing
9 changed files
with
215 additions
and
3 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
File renamed without changes.
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
File renamed without changes.
90 changes: 90 additions & 0 deletions
90
packages/contracts/deploy/update/to_v1.3.0/20_TokenVoting_Plugin.ts
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,90 @@ | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {PluginRepo__factory} from '../../../typechain'; | ||
import {getContractAddress, uploadToIPFS} from '../../helpers'; | ||
|
||
import tokenVotingSetupArtifact from '../../../artifacts/src/plugins/governance/majority-voting/token/TokenVotingSetup.sol/TokenVotingSetup.json'; | ||
import tokenVotingReleaseMetadata from '../../../src/plugins/governance/majority-voting/token/release-metadata.json'; | ||
import tokenVotingBuildMetadata from '../../../src/plugins/governance/majority-voting/token/build-metadata.json'; | ||
|
||
const TARGET_RELEASE = 1; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
console.log('\nUpdate TokenVoting Plugin'); | ||
const {deployments, ethers, network} = hre; | ||
const {deploy} = deployments; | ||
const [deployer] = await ethers.getSigners(); | ||
|
||
const deployResult = await deploy('TokenVotingSetup', { | ||
contract: tokenVotingSetupArtifact, | ||
from: deployer.address, | ||
args: [], | ||
log: true, | ||
}); | ||
|
||
const tokenVotingReleaseCIDPath = await uploadToIPFS( | ||
JSON.stringify(tokenVotingReleaseMetadata), | ||
network.name | ||
); | ||
const tokenVotingBuildCIDPath = await uploadToIPFS( | ||
JSON.stringify(tokenVotingBuildMetadata), | ||
network.name | ||
); | ||
|
||
const tokenVotingRepoAddress = await getContractAddress( | ||
'token-voting-repo', | ||
hre | ||
); | ||
const tokenVotingRepo = PluginRepo__factory.connect( | ||
tokenVotingRepoAddress, | ||
ethers.provider | ||
); | ||
if ( | ||
await tokenVotingRepo.callStatic.isGranted( | ||
tokenVotingRepoAddress, | ||
deployer.address, | ||
await tokenVotingRepo.MAINTAINER_PERMISSION_ID(), | ||
'0x00' | ||
) | ||
) { | ||
console.log(`Deployer has permission to install new TokenVoting version`); | ||
const tx = await tokenVotingRepo | ||
.connect(deployer) | ||
.createVersion( | ||
TARGET_RELEASE, | ||
deployResult.address, | ||
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingBuildCIDPath}`), | ||
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingReleaseCIDPath}`) | ||
); | ||
console.log(`Creating new TokenVoting build version with ${tx.hash}`); | ||
await tx.wait(); | ||
return; | ||
} | ||
|
||
const tx = await tokenVotingRepo | ||
.connect(deployer) | ||
.populateTransaction.createVersion( | ||
TARGET_RELEASE, | ||
deployResult.address, | ||
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingBuildCIDPath}`), | ||
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingReleaseCIDPath}`) | ||
); | ||
|
||
if (!tx.to || !tx.data) { | ||
throw new Error( | ||
`Failed to populate TokenVoting Repo createVersion transaction` | ||
); | ||
} | ||
|
||
console.log( | ||
`Deployer has no permission to create a new version. Adding managingDAO action` | ||
); | ||
hre.managingDAOActions.push({ | ||
to: tx.to, | ||
data: tx.data, | ||
value: 0, | ||
description: `Creates a new build for release 1 in the TokenVotingRepo (${tokenVotingRepoAddress}) with TokenVotingSetup (${deployResult.address})`, | ||
}); | ||
}; | ||
export default func; | ||
func.tags = ['Update', 'TokenVotingPlugin']; |
11 changes: 11 additions & 0 deletions
11
packages/contracts/deploy/update/to_v1.3.0/21_TokenVoting_Plugin_conclude.ts
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,11 @@ | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
console.log('\nConcluding TokenVoting Plugin Update'); | ||
|
||
hre.aragonToVerifyContracts.push( | ||
await hre.deployments.get('TokenVotingSetup') | ||
); | ||
}; | ||
export default func; | ||
func.tags = ['TokenVotingPlugin', 'Verify']; |
92 changes: 92 additions & 0 deletions
92
packages/contracts/deploy/update/to_v1.3.0/30_AddresslistVoting_Plugin.ts
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,92 @@ | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {PluginRepo__factory} from '../../../typechain'; | ||
import {getContractAddress, uploadToIPFS} from '../../helpers'; | ||
|
||
import addresslistVotingSetupArtifact from '../../../artifacts/src/plugins/governance/majority-voting/addresslist/AddresslistVotingSetup.sol/AddresslistVotingSetup.json'; | ||
import addresslistVotingReleaseMetadata from '../../../src/plugins/governance/majority-voting/addresslist/release-metadata.json'; | ||
import addresslistVotingBuildMetadata from '../../../src/plugins/governance/majority-voting/addresslist/build-metadata.json'; | ||
|
||
const TARGET_RELEASE = 1; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
console.log('\nUpdate AddresslistVoting Plugin'); | ||
const {deployments, ethers, network} = hre; | ||
const {deploy} = deployments; | ||
const [deployer] = await ethers.getSigners(); | ||
|
||
const deployResult = await deploy('AddresslistVotingSetup', { | ||
contract: addresslistVotingSetupArtifact, | ||
from: deployer.address, | ||
args: [], | ||
log: true, | ||
}); | ||
|
||
const addresslistVotingReleaseCIDPath = await uploadToIPFS( | ||
JSON.stringify(addresslistVotingReleaseMetadata), | ||
network.name | ||
); | ||
const addresslistVotingBuildCIDPath = await uploadToIPFS( | ||
JSON.stringify(addresslistVotingBuildMetadata), | ||
network.name | ||
); | ||
|
||
const addresslistVotingRepoAddress = await getContractAddress( | ||
'address-list-voting-repo', | ||
hre | ||
); | ||
const addresslistVotingRepo = PluginRepo__factory.connect( | ||
addresslistVotingRepoAddress, | ||
ethers.provider | ||
); | ||
if ( | ||
await addresslistVotingRepo.callStatic.isGranted( | ||
addresslistVotingRepoAddress, | ||
deployer.address, | ||
await addresslistVotingRepo.MAINTAINER_PERMISSION_ID(), | ||
'0x00' | ||
) | ||
) { | ||
console.log( | ||
`Deployer has permission to install new AddresslistVoting version` | ||
); | ||
const tx = await addresslistVotingRepo | ||
.connect(deployer) | ||
.createVersion( | ||
TARGET_RELEASE, | ||
deployResult.address, | ||
ethers.utils.toUtf8Bytes(`ipfs://${addresslistVotingBuildCIDPath}`), | ||
ethers.utils.toUtf8Bytes(`ipfs://${addresslistVotingReleaseCIDPath}`) | ||
); | ||
console.log(`Creating new AddresslistVoting build version with ${tx.hash}`); | ||
await tx.wait(); | ||
return; | ||
} | ||
|
||
const tx = await addresslistVotingRepo | ||
.connect(deployer) | ||
.populateTransaction.createVersion( | ||
TARGET_RELEASE, | ||
deployResult.address, | ||
ethers.utils.toUtf8Bytes(`ipfs://${addresslistVotingBuildCIDPath}`), | ||
ethers.utils.toUtf8Bytes(`ipfs://${addresslistVotingReleaseCIDPath}`) | ||
); | ||
|
||
if (!tx.to || !tx.data) { | ||
throw new Error( | ||
`Failed to populate AddresslistVoting Repo createVersion transaction` | ||
); | ||
} | ||
|
||
console.log( | ||
`Deployer has no permission to create a new version. Adding managingDAO action` | ||
); | ||
hre.managingDAOActions.push({ | ||
to: tx.to, | ||
data: tx.data, | ||
value: 0, | ||
description: `Creates a new build for release 1 in the AddresslistVotingRepo (${addresslistVotingRepoAddress}) with AddresslistVotingSetup (${deployResult.address})`, | ||
}); | ||
}; | ||
export default func; | ||
func.tags = ['Update', 'AddresslistVotingPlugin']; |
11 changes: 11 additions & 0 deletions
11
packages/contracts/deploy/update/to_v1.3.0/31_AddresslistVoting_Plugin_conclude.ts
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,11 @@ | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
console.log('\nConcluding AddresslistVoting Plugin Update'); | ||
|
||
hre.aragonToVerifyContracts.push( | ||
await hre.deployments.get('AddresslistVotingSetup') | ||
); | ||
}; | ||
export default func; | ||
func.tags = ['AddresslistVotingPlugin', 'Verify']; |
File renamed without changes.