Skip to content

Commit d1369ae

Browse files
authored
feat: updated tasks and script for staging (#381)
1 parent 85e9e90 commit d1369ae

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

contracts/hardhat.config.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import '@nomicfoundation/hardhat-toolbox';
22
import '@openzeppelin/hardhat-upgrades';
33
import dotenv from 'dotenv';
4+
import fs from 'fs';
45
import 'hardhat-deploy';
56
import 'hardhat-ignore-warnings';
67
import type { HardhatUserConfig, extendProvider } from 'hardhat/config';
@@ -50,6 +51,10 @@ task('test', async (taskArgs, hre, runSuper) => {
5051
if (hre.network.name === 'hardhat') {
5152
const privKeyFhevmDeployer = process.env.PRIVATE_KEY_FHEVM_DEPLOYER;
5253
const privKeyFhevmRelayer = process.env.PRIVATE_KEY_DECRYPTION_ORACLE_RELAYER;
54+
const parsedEnv2 = dotenv.parse(fs.readFileSync('addressesL2/.env.decryptionmanager'));
55+
const decryptionManagerAddress = parsedEnv2.DECRYPTION_MANAGER_ADDRESS;
56+
const parsedEnv3 = dotenv.parse(fs.readFileSync('addressesL2/.env.zkpokmanager'));
57+
const zkpokManagerAddress = parsedEnv3.ZKPOK_MANAGER_ADDRESS;
5358
await hre.run('task:faucetToPrivate', { privateKey: privKeyFhevmDeployer });
5459
await hre.run('task:faucetToPrivate', { privateKey: privKeyFhevmRelayer });
5560

@@ -62,8 +67,14 @@ task('test', async (taskArgs, hre, runSuper) => {
6267

6368
await hre.run('task:deployACL', { privateKey: privKeyFhevmDeployer });
6469
await hre.run('task:deployTFHEExecutor', { privateKey: privKeyFhevmDeployer });
65-
await hre.run('task:deployKMSVerifier', { privateKey: privKeyFhevmDeployer });
66-
await hre.run('task:deployInputVerifier', { privateKey: privKeyFhevmDeployer });
70+
await hre.run('task:deployKMSVerifier', {
71+
privateKey: privKeyFhevmDeployer,
72+
decryptionManagerAddress: decryptionManagerAddress,
73+
});
74+
await hre.run('task:deployInputVerifier', {
75+
privateKey: privKeyFhevmDeployer,
76+
zkpokManagerAddress: zkpokManagerAddress,
77+
});
6778
await hre.run('task:deployFHEGasLimit', { privateKey: privKeyFhevmDeployer });
6879
await hre.run('task:deployDecryptionOracle', { privateKey: privKeyFhevmDeployer });
6980

contracts/launch-fhevm-staging.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ mkdir -p addresses
66

77
PRIVATE_KEY_FHEVM_DEPLOYER=$(grep PRIVATE_KEY_FHEVM_DEPLOYER .env | cut -d '"' -f 2)
88
NUM_KMS_SIGNERS=$(grep NUM_KMS_SIGNERS .env | cut -d '"' -f 2)
9+
NUM_COPROCESSOR_SIGNERS=$(grep NUM_COPROCESSOR_SIGNERS .env | cut -d '"' -f 2)
10+
DECRYPTION_MANAGER_ADDRESS=$(grep DECRYPTION_MANAGER_ADDRESS .env | cut -d '"' -f 2)
11+
ZKPOK_MANAGER_ADDRESS=$(grep ZKPOK_MANAGER_ADDRESS .env | cut -d '"' -f 2)
912

1013
npx hardhat task:deployEmptyUUPSProxies --use-coprocessor-address true --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network staging
1114

@@ -14,9 +17,10 @@ npx hardhat compile:specific --contract decryptionOracle
1417

1518
npx hardhat task:deployACL --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network staging
1619
npx hardhat task:deployTFHEExecutor --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network staging
17-
npx hardhat task:deployKMSVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network staging
18-
npx hardhat task:deployInputVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network staging
20+
npx hardhat task:deployKMSVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --decryption-manager-address "$DECRYPTION_MANAGER_ADDRESS" --network staging
21+
npx hardhat task:deployInputVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --zkpok-manager-address "$ZKPOK_MANAGER_ADDRESS" --network staging
1922
npx hardhat task:deployFHEGasLimit --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network staging
2023
npx hardhat task:deployDecryptionOracle --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network staging
2124

2225
npx hardhat task:addSigners --num-signers "$NUM_KMS_SIGNERS" --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --use-address true --network staging
26+
npx hardhat task:addInputSigners --num-signers "$NUM_COPROCESSOR_SIGNERS" --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --use-address true --network staging

contracts/tasks/taskDeploy.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ task('task:deployTFHEExecutor')
104104

105105
task('task:deployKMSVerifier')
106106
.addParam('privateKey', 'The deployer private key')
107+
.addParam('decryptionManagerAddress', 'The decryption manager contract address from the Gateway chain')
107108
.setAction(async function (taskArguments: TaskArguments, { ethers, upgrades }) {
108109
const deployer = new ethers.Wallet(taskArguments.privateKey).connect(ethers.provider);
109110
const currentImplementation = await ethers.getContractFactory('EmptyUUPSProxy', deployer);
110111
const newImplem = await ethers.getContractFactory('KMSVerifier', deployer);
111112
const parsedEnv = dotenv.parse(fs.readFileSync('addresses/.env.kmsverifier'));
112113
const proxyAddress = parsedEnv.KMS_VERIFIER_CONTRACT_ADDRESS;
113114
const proxy = await upgrades.forceImport(proxyAddress, currentImplementation);
114-
const parsedEnv2 = dotenv.parse(fs.readFileSync('addressesL2/.env.decryptionmanager'));
115-
const verifyingContractSource = parsedEnv2.DECRYPTION_MANAGER_ADDRESS;
116-
const parsedEnv3 = dotenv.parse(fs.readFileSync('.env'));
117-
const chainIDSource = +parsedEnv3.CHAIN_ID_GATEWAY;
115+
const verifyingContractSource = taskArguments.decryptionManagerAddress;
116+
const parsedEnv2 = dotenv.parse(fs.readFileSync('.env'));
117+
const chainIDSource = +parsedEnv2.CHAIN_ID_GATEWAY;
118118
await upgrades.upgradeProxy(proxy, newImplem, {
119119
call: { fn: 'reinitialize', args: [verifyingContractSource, chainIDSource] },
120120
});
@@ -123,17 +123,17 @@ task('task:deployKMSVerifier')
123123

124124
task('task:deployInputVerifier')
125125
.addParam('privateKey', 'The deployer private key')
126+
.addParam('zkpokManagerAddress', 'The ZKPOK manager contract address from the Gateway chain')
126127
.setAction(async function (taskArguments: TaskArguments, { ethers, upgrades }) {
127128
const deployer = new ethers.Wallet(taskArguments.privateKey).connect(ethers.provider);
128129
const currentImplementation = await ethers.getContractFactory('EmptyUUPSProxy', deployer);
129130
const newImplem = await ethers.getContractFactory('./contracts/InputVerifier.sol:InputVerifier', deployer);
130131
const parsedEnv = dotenv.parse(fs.readFileSync('addresses/.env.inputverifier'));
131132
const proxyAddress = parsedEnv.INPUT_VERIFIER_CONTRACT_ADDRESS;
132133
const proxy = await upgrades.forceImport(proxyAddress, currentImplementation);
133-
const parsedEnv2 = dotenv.parse(fs.readFileSync('addressesL2/.env.zkpokmanager'));
134-
const verifyingContractSource = parsedEnv2.ZKPOK_MANAGER_ADDRESS;
135-
const parsedEnv3 = dotenv.parse(fs.readFileSync('.env'));
136-
const chainIDSource = +parsedEnv3.CHAIN_ID_GATEWAY;
134+
const verifyingContractSource = taskArguments.zkpokManagerAddress;
135+
const parsedEnv2 = dotenv.parse(fs.readFileSync('.env'));
136+
const chainIDSource = +parsedEnv2.CHAIN_ID_GATEWAY;
137137
await upgrades.upgradeProxy(proxy, newImplem, {
138138
call: { fn: 'reinitialize', args: [verifyingContractSource, chainIDSource] },
139139
});

0 commit comments

Comments
 (0)