Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy and Encode Upgrade Script #387

Merged
merged 15 commits into from
Oct 7, 2024
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ artifacts
#OpenZeppelin
.openzeppelin/unknown-*.json
*.keystore

# deployments and upgrades
.deployments
.upgrades
4 changes: 2 additions & 2 deletions contracts/Constellation/Utils/Directory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ contract Directory is UUPSUpgradeable, AccessControlUpgradeable {

/// @notice Internal function to authorize contract upgrades.
/// @dev This function is used internally to ensure that only administrators can authorize contract upgrades.
/// It checks whether the sender has the required ADMIN_ROLE before allowing the upgrade.
/// It checks whether the sender has the required TIMELOCK_LONG before allowing the upgrade.
function _authorizeUpgrade(address) internal view override {
require(hasRole(Constants.ADMIN_ROLE, msg.sender), Constants.ADMIN_ONLY_ERROR);
require(hasRole(Constants.TIMELOCK_LONG, msg.sender), Constants.TIMELOCK_LONG_ONLY_ERROR);
}

//----
Expand Down
53 changes: 26 additions & 27 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';
import '@openzeppelin/hardhat-upgrades';
import "hardhat-contract-sizer";
import "hardhat-gas-reporter";
import 'hardhat-contract-sizer';
import 'hardhat-gas-reporter';
import '@nomiclabs/hardhat-truffle5';
import 'solidity-docgen';
import 'hardhat-contract-sizer';

// task commands
import './tasks/adminTasks'
import './tasks/timelockTasks'
import './tasks/viewOperatorDistributorTasks'
import './tasks/viewSuperNodeAccountTasks'
import './tasks/adminTasks';
import './tasks/timelockTasks';
import './tasks/upgradeTasks';
import './tasks/viewOperatorDistributorTasks';
import './tasks/viewSuperNodeAccountTasks';

import dotenv from "dotenv";
import dotenv from 'dotenv';
import findConfig from 'find-config';

const dotenvPath = findConfig('.env');
Expand All @@ -29,7 +30,7 @@ const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.18",
version: '0.8.18',
settings: {
optimizer: {
enabled: true,
Expand All @@ -38,7 +39,7 @@ const config: HardhatUserConfig = {
},
},
{
version: "0.8.17",
version: '0.8.17',
settings: {
optimizer: {
enabled: true,
Expand All @@ -54,17 +55,17 @@ const config: HardhatUserConfig = {
runs: 15000,
},
},
}
]
},
],
},

gasReporter: {
enabled: process.env.REPORT_GAS === 'true', //
outputFile: 'gas-report.txt',
},

docgen: {
exclude: ["Testing", "Interfaces"],
exclude: ['Testing', 'Interfaces'],
},

networks: {
Expand All @@ -77,11 +78,11 @@ const config: HardhatUserConfig = {
},

holesky: {
url: process.env.HOLESKY_RPC || ""
url: process.env.HOLESKY_RPC || '',
},

ethereum: {
url: process.env.ETHEREUM_MAINNET_RPC || ""
url: process.env.ETHEREUM_MAINNET_RPC || '',
},
},
mocha: {
Expand All @@ -90,28 +91,26 @@ const config: HardhatUserConfig = {

etherscan: {
apiKey: {
holesky: process.env.ETHERSCAN_HOLESKY_API_KEY || "" as string,
mainnet: process.env.ETHERSCAN_MAINNET_API_KEY || "" as string,
holesky: process.env.ETHERSCAN_HOLESKY_API_KEY || ('' as string),
mainnet: process.env.ETHERSCAN_MAINNET_API_KEY || ('' as string),
},
customChains: [
{
network: "holesky",
network: 'holesky',
chainId: 17000,
urls: {
apiURL: "https://api-holesky.etherscan.io/api",
browserURL: "https://holesky.etherscan.io"
}
}
]
apiURL: 'https://api-holesky.etherscan.io/api',
browserURL: 'https://holesky.etherscan.io',
},
},
],
},

contractSizer: {
alphaSort: true,
runOnCompile: true,
disambiguatePaths: false,
},

};


export default config;
1 change: 0 additions & 1 deletion scripts/environments/deploy_dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { deployUsingEnv} from "../utils/deployment";
console.log("Successfully deployed dev...");
console.log("Directory address", directory?.address);
console.log(await directory?.getProtocol())
console.log(await directory?.getRocketIntegrations())
}


Expand Down
1 change: 0 additions & 1 deletion scripts/environments/deploy_prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ async function main() {
console.log("Successfully deployed production...");
console.log("Directory address", directory?.address);
console.log(await directory?.getProtocol())
console.log(await directory?.getRocketIntegrations())
}

main()
Expand Down
1 change: 0 additions & 1 deletion scripts/environments/deploy_staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ async function main() {
console.log("Successfully deployed staging...");
console.log("Directory address", directory?.address);
console.log(await directory?.getProtocol())
console.log(await directory?.getRocketIntegrations())
}

main()
Expand Down
47 changes: 25 additions & 22 deletions scripts/environments/timelock.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import findConfig from "find-config";
import dotenv from "dotenv";
import { getWalletFromPath } from "./keyReader";
import findConfig from 'find-config';
import dotenv from 'dotenv';
import { getWalletFromPath } from '../utils/keyReader';

export async function deployTimelockFromEnv(hre: any, env: string, log: boolean, minDelaySeconds: any, proposers: string[], executors: string[]) {
const dotenvPath = findConfig(`.env.${env}`);
if (dotenvPath !== null) {
dotenv.config({ path: dotenvPath });
} else {
console.error("File ", `.env.${env} could not be found`)
}
export async function deployTimelockFromEnv(
hre: any,
env: string,
log: boolean,
minDelaySeconds: any,
proposers: string[],
executors: string[]
) {
const dotenvPath = findConfig(`.env.${env}`);
if (dotenvPath !== null) {
dotenv.config({ path: dotenvPath });
} else {
console.error('File ', `.env.${env} could not be found`);
}

const deployerWallet = await getWalletFromPath(hre.ethers, process.env.DEPLOYER_PRIVATE_KEY_PATH as string);
const deployerWallet = await getWalletFromPath(hre.ethers, process.env.DEPLOYER_PRIVATE_KEY_PATH as string);

const Timelock = await hre.ethers.getContractFactory("TimelockController", deployerWallet)
const timelock = await Timelock.deploy(
minDelaySeconds,
proposers,
executors
);
const Timelock = await hre.ethers.getContractFactory('TimelockController', deployerWallet);
const timelock = await Timelock.deploy(minDelaySeconds, proposers, executors);

if(log) {
console.log(minDelaySeconds.toString(), "second timelock deployed to", timelock.address);
}
if (log) {
console.log(minDelaySeconds.toString(), 'second timelock deployed to', timelock.address);
}

return timelock.address
}
return timelock.address;
}
Loading
Loading