generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from zama-ai/fhevm-0-5-9
fix: compatibility with modified .env
- Loading branch information
Showing
11 changed files
with
129 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ abi/ | |
# files | ||
*.env | ||
*.log | ||
.env.docker | ||
.DS_Store | ||
.pnp.* | ||
coverage.json | ||
|
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
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
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
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 |
---|---|---|
@@ -1,28 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Assumes the following: | ||
# 1. A local and **fresh** fhEVM node is already running. | ||
# 2. All test addresses are funded (e.g. via the fund_test_addresses.sh script). | ||
npx hardhat clean | ||
# 1. Predeploys addresses have been precomputed via the precomputeAddresses.sh script. | ||
# 2. A local and **fresh** fhEVM node is already running. | ||
# 3. All test addresses are funded (e.g. via the fund_test_addresses.sh script). | ||
|
||
npx hardhat compile:specific --contract contracts | ||
|
||
mkdir -p fhevmTemp | ||
cp -L -r node_modules/fhevm fhevmTemp/ | ||
npx hardhat compile:specific --contract fhevmTemp/fhevm/lib | ||
npx hardhat compile:specific --contract fhevmTemp/fhevm/gateway | ||
mkdir -p abi | ||
cp artifacts/fhevmTemp/fhevm/lib/TFHEExecutor.sol/TFHEExecutor.json abi/TFHEExecutor.json | ||
|
||
PRIVATE_KEY_GATEWAY_DEPLOYER=$(grep PRIVATE_KEY_GATEWAY_DEPLOYER .env | cut -d '"' -f 2) | ||
npx hardhat task:computePredeployAddress --private-key "$PRIVATE_KEY_GATEWAY_DEPLOYER" | ||
|
||
npx hardhat compile:specific --contract contracts | ||
|
||
npx hardhat task:computeACLAddress | ||
npx hardhat task:computeTFHEExecutorAddress | ||
npx hardhat task:computeKMSVerifierAddress | ||
npx hardhat task:deployACL | ||
npx hardhat task:deployTFHEExecutor | ||
npx hardhat task:deployKMSVerifier | ||
|
||
rm -rf fhevmTemp | ||
npx hardhat task:launchFhevm --skip-get-coin true | ||
|
||
npx hardhat task:launchFhevm --skip-get-coin true | ||
rm -rf fhevmTemp |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
#!/bin/bash | ||
|
||
npx hardhat clean | ||
PRIVATE_KEY_GATEWAY_DEPLOYER=$(grep PRIVATE_KEY_GATEWAY_DEPLOYER .env | cut -d '"' -f 2) | ||
npx hardhat task:computeACLAddress --network hardhat | ||
npx hardhat task:computeTFHEExecutorAddress --network hardhat | ||
npx hardhat task:computeKMSVerifierAddress --network hardhat | ||
npx hardhat task:computePredeployAddress --private-key "$PRIVATE_KEY_GATEWAY_DEPLOYER" --network hardhat | ||
|
||
# Paths to input files | ||
ENV_EXEC="node_modules/fhevm/lib/.env.exec" | ||
ENV_GATEWAY="node_modules/fhevm/gateway/.env.gateway" | ||
ENV_FILE=".env" | ||
|
||
# Path to output file | ||
ENV_DOCKER=".env.docker" | ||
|
||
# Check if input files exist | ||
for file in "$ENV_EXEC" "$ENV_GATEWAY" "$ENV_FILE"; do | ||
if [ ! -f "$file" ]; then | ||
echo "Error: $file does not exist." | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Extract values | ||
TFHE_EXECUTOR_CONTRACT_ADDRESS=$(grep "^TFHE_EXECUTOR_CONTRACT_ADDRESS=" "$ENV_EXEC" | cut -d'=' -f2) | ||
GATEWAY_CONTRACT_PREDEPLOY_ADDRESS=$(grep "^GATEWAY_CONTRACT_PREDEPLOY_ADDRESS=" "$ENV_GATEWAY" | cut -d'=' -f2) | ||
GATEWAY_CONTRACT_PREDEPLOY_ADDRESS_NO0X=${GATEWAY_CONTRACT_PREDEPLOY_ADDRESS#0x} | ||
PRIVATE_KEY_GATEWAY_RELAYER=$(grep PRIVATE_KEY_GATEWAY_RELAYER .env | cut -d '"' -f 2) | ||
|
||
# Write to .env.docker | ||
cat << EOF > "$ENV_DOCKER" | ||
TFHE_EXECUTOR_CONTRACT_ADDRESS=$TFHE_EXECUTOR_CONTRACT_ADDRESS | ||
PRIVATE_KEY_GATEWAY_RELAYER=$PRIVATE_KEY_GATEWAY_RELAYER | ||
GATEWAY_CONTRACT_PREDEPLOY_ADDRESS=$GATEWAY_CONTRACT_PREDEPLOY_ADDRESS_NO0X | ||
EOF | ||
|
||
echo "Successfully created $ENV_DOCKER with the aggregated environment variables." |
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 |
---|---|---|
@@ -1,15 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker exec -i zama-dev-fhevm-validator-1 faucet a5e1defb98efe38ebb2d958cee052410247f4c80 | ||
sleep 8 | ||
docker exec -i zama-dev-fhevm-validator-1 faucet fCefe53c7012a075b8a711df391100d9c431c468 | ||
sleep 8 | ||
docker exec -i zama-dev-fhevm-validator-1 faucet a44366bAA26296c1409AD1e284264212029F02f1 | ||
sleep 8 | ||
docker exec -i zama-dev-fhevm-validator-1 faucet c1d91b49A1B3D1324E93F86778C44a03f1063f1b | ||
sleep 8 | ||
docker exec -i zama-dev-fhevm-validator-1 faucet 305F1F471e9baCFF2b3549F9601f9A4BEafc94e1 | ||
sleep 8 | ||
docker exec -i zama-dev-fhevm-validator-1 faucet c45994e4098271c3140117ebD5c74C70dd56D9cd | ||
sleep 8 | ||
docker exec -i zama-dev-fhevm-validator-1 faucet 97F272ccfef4026A1F3f0e0E879d514627B84E69 | ||
# Read MNEMONIC from .env file, remove 'export' and quotes | ||
MNEMONIC=$(grep MNEMONIC .env | cut -d '"' -f 2) | ||
PRIVATE_KEY_GATEWAY_DEPLOYER=$(grep PRIVATE_KEY_GATEWAY_DEPLOYER .env | cut -d '"' -f 2) | ||
PRIVATE_KEY_GATEWAY_OWNER=$(grep PRIVATE_KEY_GATEWAY_DEPLOYER .env | cut -d '"' -f 2) | ||
PRIVATE_KEY_GATEWAY_RELAYER=$(grep PRIVATE_KEY_GATEWAY_DEPLOYER .env | cut -d '"' -f 2) | ||
|
||
# Verify that global envs are set | ||
if [ -z "$MNEMONIC" ]; then | ||
echo "Error: MNEMONIC is not set." | ||
exit 1 | ||
fi | ||
if [ -z "$PRIVATE_KEY_GATEWAY_DEPLOYER" ]; then | ||
echo "Error: PRIVATE_KEY_GATEWAY_DEPLOYER is not set." | ||
exit 1 | ||
fi | ||
if [ -z "$PRIVATE_KEY_GATEWAY_OWNER" ]; then | ||
echo "Error: PRIVATE_KEY_GATEWAY_OWNER is not set." | ||
exit 1 | ||
fi | ||
if [ -z "$PRIVATE_KEY_GATEWAY_RELAYER" ]; then | ||
echo "Error: PRIVATE_KEY_GATEWAY_RELAYER is not set." | ||
exit 1 | ||
fi | ||
|
||
# Compute addresses using ethers.js v6 - signers[0] to signers[4] are Alice, Bob, Carol, David and Eve. signers[9] is the fhevm deployer. | ||
addresses=$(node -e " | ||
const { ethers } = require('ethers'); | ||
const derivationPath = \"m/44'/60'/0'/0\"; | ||
const mnemonicInstance = ethers.Mnemonic.fromPhrase('$MNEMONIC'); | ||
const hdNode = ethers.HDNodeWallet.fromMnemonic(mnemonicInstance, derivationPath); | ||
const indices = [0, 1, 2, 3, 4, 9]; | ||
for (const i of indices) { | ||
const childNode = hdNode.derivePath(\`\${i}\`); | ||
console.log(childNode.address); | ||
} | ||
const deployerAddress = new ethers.Wallet('$PRIVATE_KEY_GATEWAY_DEPLOYER').address; | ||
console.log(deployerAddress); | ||
const ownerAddress = new ethers.Wallet('$PRIVATE_KEY_GATEWAY_OWNER').address; | ||
console.log(ownerAddress); | ||
const relayerAddress = new ethers.Wallet('$PRIVATE_KEY_GATEWAY_RELAYER').address; | ||
console.log(relayerAddress); | ||
" 2>/dev/null) | ||
|
||
# Check if addresses were generated successfully | ||
if [ -z "$addresses" ]; then | ||
echo "Error: Failed to generate addresses." | ||
exit 1 | ||
fi | ||
|
||
# Convert the addresses string into an array | ||
IFS=$'\n' read -rd '' -a addressArray <<<"$addresses" | ||
|
||
# Loop through each address, strip '0x', and run the Docker command | ||
for addr in "${addressArray[@]}"; do | ||
addr_no0x=${addr#0x} | ||
docker exec -i zama-dev-fhevm-validator-1 faucet "$addr_no0x" | ||
sleep 8 | ||
done |
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
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