Skip to content

Commit

Permalink
Merge pull request #559 from zama-ai/etherscanVerification
Browse files Browse the repository at this point in the history
feat: added etherscan verification task
  • Loading branch information
jatZama authored Oct 7, 2024
2 parents 1b209c8 + eef0666 commit d1cd3e7
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export PRIVATE_KEY_KMS_SIGNER_1="bbaed91514fa4b7c86aa4f73becbabcf4bce0ae130240f0
export PRIVATE_KEY_KMS_SIGNER_2="1bfa3e2233b0103ad67954a728b246c528916791f7fab4894ff361e3937b47e1"
export PRIVATE_KEY_KMS_SIGNER_3="7a604eed8cf4a43277d192aa0c7894d368577a4021e52bf45420f256e34c7dd7"
export PRIVATE_KEY_COPROCESSOR_ACCOUNT="7ec8ada6642fc4ccfb7729bc29c17cf8d21b61abd5642d1db992c0b8672ab901"
export IS_COPROCESSOR="true"
export IS_COPROCESSOR="true"

export SEPOLIA_RPC_RUL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6 changes: 4 additions & 2 deletions .env.example.deployment
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ export ADDRESS_KMS_SIGNER_0="0x0971C80fF03B428fD2094dd5354600ab103201C5"
export ADDRESS_KMS_SIGNER_1="0xB68deCb047B5e6Cc82280502A7E2318c6b3E5eC6"
export ADDRESS_KMS_SIGNER_2="0xfe0fB0BCceb872ee7a6ef6c455e6E127Aef55DD7"
export ADDRESS_KMS_SIGNER_3="0x2dac5193bE0AB0eD8871399E6Ae61EAe6cc8cAE1"
export ADDRESS_COPROCESSOR="0xc9990FEfE0c27D31D0C2aa36196b085c0c4d456c"
export IS_COPROCESSOR="true"
export ADDRESS_COPROCESSOR_ACCOUNT="0xc9990FEfE0c27D31D0C2aa36196b085c0c4d456c"
export IS_COPROCESSOR="true"
export SEPOLIA_RPC_RUL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ deployments
typechain
typechain-types
.openzeppelin/unknown*
.openzeppelin/sepolia.json
8 changes: 8 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { resolve } from 'path';
import CustomProvider from './CustomProvider';
// Adjust the import path as needed
import './tasks/accounts';
import './tasks/etherscanVerify';
import './tasks/getEthereumAddress';
import './tasks/mint';
import './tasks/taskDeploy';
Expand Down Expand Up @@ -45,6 +46,7 @@ const chainIds = {
local: 9000,
localNetwork1: 9000,
multipleValidatorTestnet: 8009,
sepolia: 11155111,
};

function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
Expand All @@ -62,6 +64,8 @@ function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
case 'zama':
jsonRpcUrl = 'https://devnet.zama.ai';
break;
case 'sepolia':
jsonRpcUrl = process.env.SEPOLIA_RPC_RUL!;
}
return {
accounts: {
Expand Down Expand Up @@ -135,6 +139,7 @@ const config: HardhatUserConfig = {
path: "m/44'/60'/0'/0",
},
},
sepolia: getChainConfig('sepolia'),
zama: getChainConfig('zama'),
localDev: getChainConfig('local'),
local: getChainConfig('local'),
Expand Down Expand Up @@ -164,6 +169,9 @@ const config: HardhatUserConfig = {
evmVersion: 'cancun',
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY!,
},
warnings: {
'*': {
'transient-storage': false,
Expand Down
16 changes: 10 additions & 6 deletions launch-fhevm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ npx hardhat task:computeFHEPaymentAddress --private-key "$PRIVATE_KEY_FHEVM_DEPL
npx hardhat compile:specific --contract lib
npx hardhat compile:specific --contract gateway

npx hardhat task:deployACL --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER"
npx hardhat task:deployTFHEExecutor --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER"
npx hardhat task:deployKMSVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER"
npx hardhat task:deployInputVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER"
npx hardhat task:deployFHEPayment --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER"
npx hardhat task:deployACL --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network sepolia
npx hardhat task:deployTFHEExecutor --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network sepolia
npx hardhat task:deployKMSVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network sepolia
npx hardhat task:deployInputVerifier --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network sepolia
npx hardhat task:deployFHEPayment --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --network sepolia

npx hardhat task:addSigners --num-signers $NUM_KMS_SIGNERS --private-key "$PRIVATE_KEY_FHEVM_DEPLOYER" --use-address true

npx hardhat task:launchFhevm --skip-get-coin true --use-address true
npx hardhat task:launchFhevm --skip-get-coin true --use-address true --network sepolia

echo "Waiting 2 minutes before contract verification... Please wait..."
sleep 120 # makes sure that contracts bytescode propagates on Etherscan, otherwise contracts verification might fail in next step
npx hardhat task:verifyContracts --network sepolia
77 changes: 77 additions & 0 deletions tasks/etherscanVerify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import dotenv from 'dotenv';
import fs from 'fs';
import { task } from 'hardhat/config';

task('task:verifyContracts').setAction(async function (taskArguments, { upgrades, run }) {
const parsedEnvACL = dotenv.parse(fs.readFileSync('lib/.env.acl'));
const proxyACLAddress = parsedEnvACL.ACL_CONTRACT_ADDRESS;
const implementationACLAddress = await upgrades.erc1967.getImplementationAddress(proxyACLAddress);
await run('verify:verify', {
address: implementationACLAddress,
constructorArguments: [],
});
await run('verify:verify', {
address: proxyACLAddress,
constructorArguments: [],
});

const parsedEnvTFHEExecutor = dotenv.parse(fs.readFileSync('lib/.env.exec'));
const proxyTFHEExecutorAddress = parsedEnvTFHEExecutor.TFHE_EXECUTOR_CONTRACT_ADDRESS;
const implementationTFHEExecutorAddress = await upgrades.erc1967.getImplementationAddress(proxyTFHEExecutorAddress);
await run('verify:verify', {
address: implementationTFHEExecutorAddress,
constructorArguments: [],
});
await run('verify:verify', {
address: proxyTFHEExecutorAddress,
constructorArguments: [],
});

const parsedEnvKMSVerifier = dotenv.parse(fs.readFileSync('lib/.env.kmsverifier'));
const proxyKMSVerifier = parsedEnvKMSVerifier.KMS_VERIFIER_CONTRACT_ADDRESS;
const implementationKMSVerifierAddress = await upgrades.erc1967.getImplementationAddress(proxyKMSVerifier);
await run('verify:verify', {
address: implementationKMSVerifierAddress,
constructorArguments: [],
});
await run('verify:verify', {
address: proxyKMSVerifier,
constructorArguments: [],
});

const parsedEnvInputVerifier = dotenv.parse(fs.readFileSync('lib/.env.inputverifier'));
const proxyInputVerifier = parsedEnvInputVerifier.INPUT_VERIFIER_CONTRACT_ADDRESS;
const implementationInputVerifierAddress = await upgrades.erc1967.getImplementationAddress(proxyInputVerifier);
await run('verify:verify', {
address: implementationInputVerifierAddress,
constructorArguments: [],
});
await run('verify:verify', {
address: proxyInputVerifier,
constructorArguments: [],
});

const parsedEnvFHEPayment = dotenv.parse(fs.readFileSync('lib/.env.fhepayment'));
const proxyFHEPayment = parsedEnvFHEPayment.FHE_PAYMENT_CONTRACT_ADDRESS;
const implementationFHEPaymentAddress = await upgrades.erc1967.getImplementationAddress(proxyFHEPayment);
await run('verify:verify', {
address: implementationFHEPaymentAddress,
constructorArguments: [],
});
await run('verify:verify', {
address: proxyFHEPayment,
constructorArguments: [],
});

const parsedEnvGateway = dotenv.parse(fs.readFileSync('gateway/.env.gateway'));
const proxyGateway = parsedEnvGateway.GATEWAY_CONTRACT_PREDEPLOY_ADDRESS;
const implementationGatewayAddress = await upgrades.erc1967.getImplementationAddress(proxyGateway);
await run('verify:verify', {
address: implementationGatewayAddress,
constructorArguments: [],
});
await run('verify:verify', {
address: proxyGateway,
constructorArguments: [],
});
});
2 changes: 1 addition & 1 deletion tasks/taskTFHE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ address constant inputVerifierAdd = ${inputVerfierAddress};\n`;
if (!taskArguments.useAddress) {
coprocAddress = new ethers.Wallet(process.env.PRIVATE_KEY_COPROCESSOR_ACCOUNT!).address;
} else {
coprocAddress = process.env.ADDRESS_COPROCESSOR;
coprocAddress = process.env.ADDRESS_COPROCESSOR_ACCOUNT;
}
const envFilePath2 = path.join(__dirname, '../lib/.env.coprocessor');
const content2 = `COPROCESSOR_ADDRESS=${coprocAddress}\n`;
Expand Down

0 comments on commit d1cd3e7

Please sign in to comment.