Skip to content

Commit 5857e81

Browse files
authored
fix: set named account and change admin to owner naming (#276)
1 parent f335502 commit 5857e81

23 files changed

+85
-52
lines changed

.env.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Also defined in Github environments
2-
DEPLOYER_PRIVATE_KEY=
2+
# Hardhat Account #0 (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
3+
DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
4+
# Hardhat Account #1 (0x70997970C51812dc3A010C7d01b50e0d17dc79C8)
5+
ADMIN_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
36
EXPLORER_API_KEY=
47
IS_VERIFICATION_API_V2=
58
ARBISCAN_API_KEY=

config/config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
"asset": "Token",
147147
"token": "0xe649e6a1F2afc63ca268C2363691ceCAF75CF47C",
148148
"richman": "",
149+
"deployer": "0x111167a21d2bdb8e10b84aee3501059d50756b67",
149150
"owner": "0x111165e3c379e4f8285df34d7137b433c30afa66",
150151
"uniswap": false,
151152
"v3": {
@@ -186,6 +187,7 @@
186187
"asset": "Token",
187188
"token": "0x9923eD3cbd90CD78b910c475f9A731A6e0b8C963",
188189
"richman": "0x9990cfb1Feb7f47297F54bef4d4EbeDf6c5463a3",
190+
"deployer": "0x9990cfb1Feb7f47297F54bef4d4EbeDf6c5463a3",
189191
"owner": "0x9990cfb1Feb7f47297F54bef4d4EbeDf6c5463a3",
190192
"uniswap": false,
191193
"v3": {

deploy/0_deploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { DiamondArgsStruct } from '../typechain/contracts/Diamond';
3838
import { Ownable__factory } from '../typechain/factories/@openzeppelin/contracts/access';
3939
import { FactoryDeployer } from '../utils/FactoryDeployer';
4040
import config from '../utils/config';
41+
import { getDeployerAndOwnerSigners } from '../utils/deploy-tools';
4142
import { getFunctionSelectors, linkContractToProxy } from '../utils/proxy-tools';
4243
import { getLibDiamondConfigOrEmpty } from '../utils/tools';
4344

@@ -49,7 +50,7 @@ export default async function deploy() {
4950
console.log('Deploying PoCo..');
5051
const network = await ethers.provider.getNetwork();
5152
const chainId = network.chainId;
52-
const [deployer] = await ethers.getSigners();
53+
const { deployer } = await getDeployerAndOwnerSigners();
5354
console.log(`Deployer: ${deployer.address}`);
5455
console.log(`Network: ${network.name} (${chainId})`);
5556
const deploymentOptions = config.getChainConfigOrDefault(chainId);

hardhat.config.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import 'solidity-docgen';
1414
import { cleanupDeployments, copyDeployments } from './scripts/tools/copy-deployments';
1515
import chainConfig from './utils/config';
1616

17-
const ZERO_PRIVATE_KEY = '0x0000000000000000000000000000000000000000000000000000000000000000';
1817
const isNativeChainType = chainConfig.isNativeChain();
1918
const isLocalFork = process.env.LOCAL_FORK == 'true';
2019
const isFujiFork = process.env.FUJI_FORK == 'true';
@@ -90,6 +89,20 @@ const config: HardhatUserConfig = {
9089
{ version: '0.4.11', settings }, // RLC contracts
9190
],
9291
},
92+
namedAccounts: {
93+
deployer: {
94+
default: 0,
95+
bellecour: chainConfig.chains['134'].deployer || 0,
96+
arbitrum: chainConfig.chains['42161'].deployer || 0,
97+
arbitrumSepolia: chainConfig.chains['421614'].deployer || 0,
98+
},
99+
owner: {
100+
default: 1,
101+
bellecour: chainConfig.chains['134'].owner || 1,
102+
arbitrum: chainConfig.chains['42161'].owner || 1,
103+
arbitrumSepolia: chainConfig.chains['421614'].owner || 1,
104+
},
105+
},
93106
networks: {
94107
hardhat: {
95108
accounts: {
@@ -178,41 +191,29 @@ const config: HardhatUserConfig = {
178191
process.env.FUJI_RPC_URL || // Used in local development
179192
process.env.RPC_URL || // Defined in Github Actions environments
180193
'https://api.avax-test.network/ext/bc/C/rpc',
181-
accounts: [
182-
process.env.DEPLOYER_PRIVATE_KEY || ZERO_PRIVATE_KEY,
183-
process.env.ADMIN_PRIVATE_KEY || ZERO_PRIVATE_KEY,
184-
],
194+
accounts: _getPrivateKeys(),
185195
...fujiBaseConfig,
186196
},
187197
arbitrum: {
188198
url:
189199
process.env.ARBITRUM_RPC_URL || // Used in local development
190200
process.env.RPC_URL || // Defined in Github Actions environments
191201
'https://arbitrum.gateway.tenderly.co',
192-
accounts: [
193-
process.env.DEPLOYER_PRIVATE_KEY || ZERO_PRIVATE_KEY,
194-
process.env.ADMIN_PRIVATE_KEY || ZERO_PRIVATE_KEY,
195-
],
202+
accounts: _getPrivateKeys(),
196203
...arbitrumBaseConfig,
197204
},
198205
arbitrumSepolia: {
199206
url:
200207
process.env.ARBITRUM_SEPOLIA_RPC_URL || // Used in local development
201208
process.env.RPC_URL || // Defined in Github Actions environments
202209
'https://sepolia-rollup.arbitrum.io/rpc',
203-
accounts: [
204-
process.env.DEPLOYER_PRIVATE_KEY || ZERO_PRIVATE_KEY,
205-
process.env.ADMIN_PRIVATE_KEY || ZERO_PRIVATE_KEY,
206-
],
210+
accounts: _getPrivateKeys(),
207211
...arbitrumSepoliaBaseConfig,
208212
},
209213
bellecour: {
210214
chainId: 134,
211215
url: 'https://bellecour.iex.ec',
212-
accounts: [
213-
process.env.DEPLOYER_PRIVATE_KEY || ZERO_PRIVATE_KEY,
214-
process.env.ADMIN_PRIVATE_KEY || ZERO_PRIVATE_KEY,
215-
],
216+
accounts: _getPrivateKeys(),
216217
...bellecourBaseConfig,
217218
verify: {
218219
etherscan: {
@@ -365,4 +366,11 @@ task('abis', 'Generate contract ABIs').setAction(async (taskArgs, hre) => {
365366
console.log(`Saved ${contracts.length} ABI files to ${abisDir} folder`);
366367
});
367368

369+
function _getPrivateKeys() {
370+
const ZERO_PRIVATE_KEY = '0x0000000000000000000000000000000000000000000000000000000000000000';
371+
const deployerKey = process.env.DEPLOYER_PRIVATE_KEY || ZERO_PRIVATE_KEY;
372+
const adminKey = process.env.ADMIN_PRIVATE_KEY || ZERO_PRIVATE_KEY;
373+
return [deployerKey, adminKey];
374+
}
375+
368376
export default config;

scripts/boost/0_deploy-modules.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import {
88
IexecPocoBoostFacet__factory,
99
} from '../../typechain';
1010
import config from '../../utils/config';
11+
import { getDeployerAndOwnerSigners } from '../../utils/deploy-tools';
1112
import { mineBlockIfOnLocalFork } from '../../utils/mine';
1213
const genericFactoryAddress = require('@amxx/factory/deployments/GenericFactory.json').address;
1314

1415
(async () => {
1516
console.log('Deploying Boost modules..');
1617
await mineBlockIfOnLocalFork();
17-
const [owner] = await ethers.getSigners();
18+
const { deployer } = await getDeployerAndOwnerSigners();
1819
const chainId = (await ethers.provider.getNetwork()).chainId;
1920
const deploymentOptions = config.getChainConfig(chainId).v5;
2021
if (!deploymentOptions.IexecLibOrders_v5) {
@@ -34,7 +35,7 @@ const genericFactoryAddress = require('@amxx/factory/deployments/GenericFactory.
3435
bytecode: IexecPocoBoostAccessorsFacet__factory.bytecode,
3536
},
3637
];
37-
const genericFactoryInstance = GenericFactory__factory.connect(genericFactoryAddress, owner);
38+
const genericFactoryInstance = GenericFactory__factory.connect(genericFactoryAddress, deployer);
3839
for (const module of modules) {
3940
const moduleAddress = await genericFactoryInstance.predictAddress(module.bytecode, salt);
4041
await genericFactoryInstance.createContract(module.bytecode, salt).then((tx) => tx.wait());

scripts/boost/1_add-modules-to-proxy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '../../typechain';
1212
import { Ownable__factory } from '../../typechain/factories/rlc-faucet-contract/contracts';
1313
import config from '../../utils/config';
14+
import { getDeployerAndOwnerSigners } from '../../utils/deploy-tools';
1415
import {
1516
encodeModuleProxyUpdate,
1617
printBlockTime,
@@ -32,8 +33,8 @@ import {
3233
const iexecPocoBoostAccessorsFacetAddress = (
3334
await deployments.get('IexecPocoBoostAccessorsFacet')
3435
).address; // Bellecour: 0x56185a2b0dc8b556BBfBAFB702BC971Ed75e868C
35-
const [account] = await ethers.getSigners();
36-
const timelockAddress = await Ownable__factory.connect(diamondProxyAddress, account).owner(); // Bellecour: 0x4611B943AA1d656Fc669623b5DA08756A7e288E9
36+
const { owner } = await getDeployerAndOwnerSigners();
37+
const timelockAddress = await Ownable__factory.connect(diamondProxyAddress, owner).owner(); // Bellecour: 0x4611B943AA1d656Fc669623b5DA08756A7e288E9
3738

3839
const iexecLibOrders = {
3940
['contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5']:
@@ -60,7 +61,7 @@ import {
6061
] as [string[], bigint[], BytesLike[], BytesLike, BytesLike];
6162
console.log('Scheduling proxy update..');
6263
await printBlockTime();
63-
const timelockInstance = TimelockController__factory.connect(timelockAddress, account);
64+
const timelockInstance = TimelockController__factory.connect(timelockAddress, owner);
6465
const timelockAdminAddress = await timelockInstance.getRoleMember(
6566
await timelockInstance.PROPOSER_ROLE(),
6667
0,

scripts/deploy-timelock.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { duration } from '@nomicfoundation/hardhat-network-helpers/dist/src/help
55
import { ethers } from 'hardhat';
66
import { TimelockController__factory } from '../typechain';
77
import { FactoryDeployer } from '../utils/FactoryDeployer';
8+
import { getDeployerAndOwnerSigners } from '../utils/deploy-tools';
89

910
/**
1011
* Deploy TimelockController contract using the generic factory.
@@ -13,8 +14,8 @@ import { FactoryDeployer } from '../utils/FactoryDeployer';
1314
export const deploy = async () => {
1415
console.log('Deploying TimelockController..');
1516
const chainId = (await ethers.provider.getNetwork()).chainId;
16-
const [owner] = await ethers.getSigners();
17-
const factoryDeployer = new FactoryDeployer(owner, chainId);
17+
const { deployer } = await getDeployerAndOwnerSigners();
18+
const factoryDeployer = new FactoryDeployer(deployer, chainId);
1819

1920
// Deploy TimelockController
2021
const ONE_WEEK_IN_SECONDS = duration.days(7);
@@ -33,7 +34,7 @@ export const deploy = async () => {
3334
'0x0B3a38b0A47aB0c5E8b208A703de366751Df5916', // v5 deployer
3435
];
3536
const constructorArgs = [ONE_WEEK_IN_SECONDS, ADMINISTRATORS, PROPOSERS, EXECUTORS];
36-
const timelockFactory = new TimelockController__factory(owner);
37+
const timelockFactory = new TimelockController__factory(deployer);
3738
await factoryDeployer.deployContract(timelockFactory, constructorArgs);
3839
};
3940

scripts/set-callback-gas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { ethers } from 'hardhat';
77
import { IexecInterfaceToken__factory } from '../typechain';
88
import config from '../utils/config';
9+
import { getDeployerAndOwnerSigners } from '../utils/deploy-tools';
910

1011
(async () => {
1112
const requestedCallbackGas = Number(process.env.CALLBACK_GAS);
@@ -19,8 +20,7 @@ import config from '../utils/config';
1920
throw new Error('Diamond proxy address is required');
2021
}
2122
console.log(`Diamond proxy address: ${proxyAddress}`);
22-
// TODO: update here to use getNamedAccounts
23-
const [, owner] = await ethers.getSigners();
23+
const { owner } = await getDeployerAndOwnerSigners();
2424
const iexecPoCo = IexecInterfaceToken__factory.connect(proxyAddress, owner);
2525
if ((await iexecPoCo.owner()) !== owner.address) {
2626
throw new Error(`Sender account ${owner.address} is not the PoCo owner.`);

scripts/sponsoring/0_deploy-modules.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
IexecPocoAccessorsFacet__factory,
1111
} from '../../typechain';
1212
import config from '../../utils/config';
13+
import { getDeployerAndOwnerSigners } from '../../utils/deploy-tools';
1314
const genericFactoryAddress = require('@amxx/factory/deployments/GenericFactory.json').address;
1415

1516
if (process.env.HANDLE_SPONSORING_UPGRADE_INTERNALLY != 'true') {
@@ -20,7 +21,7 @@ if (process.env.HANDLE_SPONSORING_UPGRADE_INTERNALLY != 'true') {
2021

2122
export async function deployModules() {
2223
console.log('Deploying modules..');
23-
const [deployer] = await ethers.getSigners();
24+
const { deployer } = await getDeployerAndOwnerSigners();
2425
console.log(`Deployer: ${deployer.address}`);
2526
const chainId = (await ethers.provider.getNetwork()).chainId;
2627
const deploymentOptions = config.getChainConfig(chainId).v5;

scripts/sponsoring/1_add-modules-to-proxy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ export async function addModulesToProxy() {
9898
console.log(`Expected Timelock proposer: ${timelockAdminAddress}`);
9999
/*
100100
// Enable this in production
101-
const [proposer] = await ethers.getSigners();
102-
console.log(`Actual Timelock proposer: ${proposer.address}`);
103-
if (proposer.address != timelockAdminAddress) {
101+
const { owner } = await getDeployerAndOwnerSigners();
102+
console.log(`Actual Timelock proposer: ${owner.address}`);
103+
if (owner.address != timelockAdminAddress) {
104104
console.error('Bad proposer');
105105
process.exit(1);
106106
}
107107
*/
108108
const timelockAdminSigner = await ethers.getImpersonatedSigner(timelockAdminAddress);
109-
//const timelockAdminSigner = proposer; // Enable this in production
109+
//const timelockAdminSigner = owner; // Enable this in production
110110
await scheduleUpgrade();
111111
await time.increase(delay); // Disable this in production
112112
console.log('Time traveling..');

0 commit comments

Comments
 (0)