zama-ai / fhevm-hardhat-template

fhEVM hardhat template
MIT License
22 stars 31 forks source link

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 197257911921588): insufficient funds: insufficient funds #37

Closed furkandemireleng closed 2 months ago

furkandemireleng commented 3 months ago

Hi Zama ! I have a question about deploying erc20 token.

I download the project then install packages after that I enter pnpm : pnpm run fhevm:start

it says :

`mpiled 3 Solidity files successfully (evm target: cancun).
gatewayContractAddress written to gateway/.env.gateway successfully!
node_modules/fhevm/gateway/lib/PredeployAddress.sol file has been generated successfully.
Nothing to compile
No need to generate any newer typings.
ACL address 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0 written successfully!
node_modules/fhevm/lib/ACLAddress.sol file generated successfully!
TFHE Executor address 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8 written successfully!
node_modules/fhevm/lib/FHEVMCoprocessorAddress.sol file generated successfully!
KMS Verifier address 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD written successfully!
node_modules/fhevm/lib/KMSVerifierAddress.sol file generated successfully!
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 114204164111464): insufficient funds: insufficient funds

Please replace TFHEExecutor for one of these options wherever you are trying to read its artifact:

fhevm/lib/TFHEExecutor.sol:TFHEExecutor
fhevmTemp/fhevm/lib/TFHEExecutor.sol:TFHEExecutor

For more info go to https://hardhat.org/HH701 or run Hardhat with --show-stack-traces
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 197257911921588): insufficient funds: insufficient funds
.....
privateKey 717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6
ownerAddress 0x305F1F471e9baCFF2b3549F9601f9A4BEafc94e1
GatewayContract was deployed at address:  0xc8c9303Cd7F337fab769686B593B87DC3403E0ce
Account 0x97F272ccfef4026A1F3f0e0E879d514627B84E69 was succesfully added as an gateway relayer`
the launch-fhevm.sh

# npx hardhat clean
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
jatZama commented 2 months ago

Please, send the full logs to help debugging. Did you first setup your .env file? Or at least did you do cp .env.example .env? Another recommended solution first, before launching a local fhevm node, is to try the mocked mode as well : pnpm test:mock.

furkandemireleng commented 2 months ago

Hi Jat Thanks for the response

my .env

export INFURA_API_KEY="key"
export MNEMONIC="dog huge boring street rookie possible cycle funny occur file present special anxiety law merge"
export PRIVATE_KEY_GATEWAY_DEPLOYER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6"
export PRIVATE_KEY_GATEWAY_OWNER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6"
export PRIVATE_KEY_GATEWAY_RELAYER="7ec931411ad75a7c201469a385d6f18a325d4923f9f213bd882bbea87e160b67"

# Block explorer API keys
# export ARBISCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# export BSCSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
export ETHERSCAN_API_KEY="key"
# export OPTIMISM_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# export POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# export SNOWTRACE_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

the pnpm test:mock returns


furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm test:mock      

> @zama-ai/fhevm-hardhat-template@1.0.0 test:mock /Users/furkandemirel/test/zama/fhevm-hardhat-template
> hardhat test --network hardhat

Nothing to compile
No need to generate any newer typings.
Nothing to compile
No need to generate any newer typings.
Nothing to compile
No need to generate any newer typings.
Code of Mocked Pre-compile set at address: 0x000000000000000000000000000000000000005d
gatewayContractAddress written to gateway/.env.gateway successfully!
node_modules/fhevm/gateway/lib/PredeployAddress.sol file has been generated successfully.
ACL address 0x2Fb4341027eb1d2aD8B5D9708187df8633cAFA92 written successfully!
node_modules/fhevm/lib/ACLAddress.sol file generated successfully!
TFHE Executor address 0x05fD9B5EFE0a996095f42Ed7e77c390810CF660c written successfully!
node_modules/fhevm/lib/FHEVMCoprocessorAddress.sol file generated successfully!
KMS Verifier address 0x12B064FB845C1cc05e9493856a1D637a73e944bE written successfully!
node_modules/fhevm/lib/KMSVerifierAddress.sol file generated successfully!
ACL was deployed at address: 0x2Fb4341027eb1d2aD8B5D9708187df8633cAFA92
Error HH701: There are multiple artifacts for contract "TFHEExecutor", please use a fully qualified name.

Please replace TFHEExecutor for one of these options wherever you are trying to read its artifact:

fhevm/lib/TFHEExecutor.sol:TFHEExecutor
fhevmTemp/lib/TFHEExecutor.sol:TFHEExecutor

For more info go to https://hardhat.org/HH701 or run Hardhat with --show-stack-traces
 ELIFECYCLE  Command failed with exit code 1.
 ```
 
 I probably miss something but I don't know where. I am looking forward to your responses !
 Thanks
 
jatZama commented 2 months ago

What OS are you using? If you use Windows, you should use the WSL. Otherwise, are you sure you are using the last main branch? Please retry by pulling last current main branch in a new clean directory.

furkandemireleng commented 2 months ago

Hi Jat, I probably miss something that's why I would like to share with you my logs. I get error when I start. Please help me 🙏 I use Mac m3 os 14.6

my node version is

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % node -v
v20.15.0

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % npm -v
10.7.0

Create a new directory

clone repo

 git clone https://github.com/zama-ai/fhevm-hardhat-template.git

then check branch

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % git pull origin main
From https://github.com/zama-ai/fhevm-hardhat-template
 * branch            main       -> FETCH_HEAD
Already up to date.

Update env

export INFURA_API_KEY="key"
export MNEMONIC="dog huge boring street rookie possible cycle funny occur file present special anxiety law merge"
export PRIVATE_KEY_GATEWAY_DEPLOYER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6"
export PRIVATE_KEY_GATEWAY_OWNER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6"
export PRIVATE_KEY_GATEWAY_RELAYER="7ec931411ad75a7c201469a385d6f18a325d4923f9f213bd882bbea87e160b67"

# Block explorer API keys
# export ARBISCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# export BSCSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
export ETHERSCAN_API_KEY="key"
# export OPTIMISM_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# export POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# export SNOWTRACE_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

then pnpm install

+ ts-generator 0.1.1
+ ts-node 10.9.2
+ typechain 8.3.2
+ typescript 5.5.4
+ typescript-eslint 8.0.1

> @zama-ai/fhevm-hardhat-template@1.0.0 preinstall /Users/furkandemirel/test/new_zama/fhevm-hardhat-template
> node tasks/checkNodeVersion.js

> @zama-ai/fhevm-hardhat-template@1.0.0 postinstall /Users/furkandemirel/test/new_zama/fhevm-hardhat-template
> DOTENV_CONFIG_PATH=./.env.example pnpm typechain

> @zama-ai/fhevm-hardhat-template@1.0.0 typechain /Users/furkandemirel/test/new_zama/fhevm-hardhat-template
> cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain

Compiled 23 Solidity files successfully (evm target: cancun).

Done in 7.7s

after that

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm fhevm:start

> @zama-ai/fhevm-hardhat-template@1.0.0 fhevm:start /Users/furkandemirel/test/new_zama/fhevm-hardhat-template
> make run-full && ./scripts/fund_test_addresses_docker.sh && ./launch-fhevm.sh

/Library/Developer/CommandLineTools/usr/bin/make generate-fhe-keys
ghcr.io/zama-ai/kms-service-dev:v0.7.1
v0.7.1: Pulling from zama-ai/kms-service-dev
Digest: sha256:63ef4519b44e03e78a3071fa920536ab938d080367de4059871068cce3ab2ac8
Status: Image is up to date for ghcr.io/zama-ai/kms-service-dev:v0.7.1
ghcr.io/zama-ai/kms-service-dev:v0.7.1

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview ghcr.io/zama-ai/kms-service-dev:v0.7.1
611486092ee675b538bfa7cbb747cb65a31ed85f014a14faed1134cb1e2e17d9
Successfully copied 253MB to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res
temp-container
/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res/keys
###########################################################
Keys creation is done, they are stored in /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res/keys
###########################################################
/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/network-fhe-keys
/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/kms-fhe-keys
###########################################################
All the required keys exist in /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res/keys
###########################################################
Copying PUB/ServerKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/network-fhe-keys, please wait ...
Copying PUB/PublicKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/network-fhe-keys, please wait ...
Copying PRIV/FhePrivateKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/kms-fhe-keys, please wait ...
[+] Running 7/7
 ✔ Network zama-dev_default              Created                                                                                               0.0s 
 ✔ Container zama-dev-fhevm-validator-1  Healthy                                                                                              20.8s 
 ✔ Container zama-dev-kms-validator-1    Healthy                                                                                               5.8s 
 ✔ Container zama-dev-gateway-store-1    Started                                                                                               0.3s 
 ✔ Container zama-dev-kms-core-1         Healthy                                                                                               5.8s 
 ✔ Container zama-dev-connector-1        Started                                                                                               5.9s 
 ✔ Container zama-dev-gateway-1          Started                                                                                              20.9s 
sleep a little to let the docker start up
sleep 5
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"BA3E57E4FC0EB4DF4A0CD11778FC1BE154CA8CFDABD993C4B038AF806FD97546","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"4622EE7FDE9ACD4F1F8C91F7DA4E662A4341429C04139259AAA45159D223DC90","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"D5E8BD5AEF9A9964B3DCC0A3151C55EAEA69893790C0F5DB5B90F8C6F2498F79","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"96593C58779A46BD7F5818C68D61390C6A0E5863C8C684860AE60DE51DA98B08","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"E080C49DD8DCC3DDAA1D6E1A263222C8BD7D16BD6C8E791162CD8947C7CB72BD","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"581FDDADC2E06A6ABFB94A5F25F824A300243B6A1D3454EFFCD8A386CB55D71A","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"8DB2E58520A6A951D04CD4BCC8C2FD31F3116F8D90FB03FDF94EA5A49F403F2A","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
Generating typings for: 22 artifacts in dir: types for target: ethers-v6
Successfully generated 56 typings!
Compiled 22 Solidity files successfully (evm target: cancun).
Generating typings for: 3 artifacts in dir: types for target: ethers-v6
Successfully generated 30 typings!
Compiled 3 Solidity files successfully (evm target: cancun).
gatewayContractAddress written to gateway/.env.gateway successfully!
node_modules/fhevm/gateway/lib/PredeployAddress.sol file has been generated successfully.
Generating typings for: 12 artifacts in dir: types for target: ethers-v6
Successfully generated 52 typings!
Compiled 11 Solidity files successfully (evm target: cancun).
ACL address 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0 written successfully!
node_modules/fhevm/lib/ACLAddress.sol file generated successfully!
TFHE Executor address 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8 written successfully!
node_modules/fhevm/lib/FHEVMCoprocessorAddress.sol file generated successfully!
KMS Verifier address 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD written successfully!
node_modules/fhevm/lib/KMSVerifierAddress.sol file generated successfully!
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 115819739411404): insufficient funds: insufficient funds
    at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
    at async SimpleTaskDefinition.action (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/tasks/taskDeploy.ts:31:15)
    at async Environment._runTaskDefinition (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at async Environment.run (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at async main (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 280356338702876): insufficient funds: insufficient funds
    at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
    at async SimpleTaskDefinition.action (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/tasks/taskDeploy.ts:44:16)
    at async Environment._runTaskDefinition (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at async Environment.run (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at async main (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 174032775419150): insufficient funds: insufficient funds
    at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
    at async SimpleTaskDefinition.action (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/tasks/taskDeploy.ts:57:16)
    at async Environment._runTaskDefinition (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at async Environment.run (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at async main (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
privateKey 717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6
ownerAddress 0x305F1F471e9baCFF2b3549F9601f9A4BEafc94e1
GatewayContract was deployed at address:  0xc8c9303Cd7F337fab769686B593B87DC3403E0ce
Account 0x97F272ccfef4026A1F3f0e0E879d514627B84E69 was succesfully added as an gateway relayer

also the pnpm: test says


furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm test

> @zama-ai/fhevm-hardhat-template@1.0.0 test /Users/furkandemirel/test/new_zama/fhevm-hardhat-template
> hardhat test

bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

  EncryptedERC20
    1) "before each" hook for "should mint the contract"

  TestAsyncDecrypt
    2) "before all" hook for "test async decrypt bool"

  0 passing (265ms)
  2 failing

  1) EncryptedERC20
       "before each" hook for "should mint the contract":
     ProviderError: failed to check sender balance: sender balance < tx cost (0 < 10627512): insufficient funds: insufficient funds
      at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
      at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
      at async deployEncryptedERC20Fixture (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/test/encryptedERC20/EncryptedERC20.fixture.ts:10:20)
      at async Context. (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/test/encryptedERC20/EncryptedERC20.ts:14:22)

  2) TestAsyncDecrypt
       "before all" hook for "test async decrypt bool":
     ProviderError: rpc error: code = Unknown desc = execution reverted
      at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async CustomProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/CustomProvider.ts:23:41)
      at async HardhatEthersProvider.estimateGas (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/internal/hardhat-ethers-provider.ts:246:27)
      at async /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:235:35
      at async Promise.all (index 0)
      at async HardhatEthersSigner._sendUncheckedTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:256:7)
      at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
      at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
      at async Context. (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/test/gatewayDecrypt/testAsyncDecrypt.ts:18:21)

jatZama commented 2 months ago

This is weird, I was unable to reproduce your error. Your error is related to the faucet. Maybe what you could try is to increase the time waiting between each faucet-related transaction, i.e change all those sleep 8 lines to sleep 20 for example, and then retry pnpm fhevm:start(after stopping the service via pnpm fhevm:stop first): https://github.com/zama-ai/fhevm-hardhat-template/blob/71432b5c9648eacf245ba308553ead86e57aa409/scripts/fund_test_addresses_docker.sh#L4-L14 ⚠️ Furthermore, can you please tell me what happens now when you try pnpm test:mock from a fresh cloned repo? This is very important since mocked mode should be the preferred method for developing smart contracts on fhEVM.

furkandemireleng commented 2 months ago

Hi Jat, Thanks for your quick response

First of all I try increase sleep time but it did not help

the logs:

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm fhevm:stop

> @zama-ai/fhevm-hardhat-template@1.0.0 fhevm:stop /Users/furkandemirel/test/new_zama/fhevm-hardhat-template
> make clean

/Library/Developer/CommandLineTools/usr/bin/make stop-full
[+] Running 7/7
 ✔ Container zama-dev-gateway-store-1    Removed                                                                              0.4s 
 ✔ Container zama-dev-gateway-1          Removed                                                                             10.2s 
 ✔ Container zama-dev-connector-1        Removed                                                                             10.1s 
 ✔ Container zama-dev-kms-core-1         Removed                                                                             10.1s 
 ✔ Container zama-dev-kms-validator-1    Removed                                                                             10.3s 
 ✔ Container zama-dev-fhevm-validator-1  Removed                                                                             10.2s 
 ✔ Network zama-dev_default              Removed                                                                              0.1s 
rm -rf network-fhe-keys
rm -rf kms-fhe-keys
furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm fhevm:start

> @zama-ai/fhevm-hardhat-template@1.0.0 fhevm:start /Users/furkandemirel/test/new_zama/fhevm-hardhat-template
> make run-full && ./scripts/fund_test_addresses_docker.sh && ./launch-fhevm.sh

/Library/Developer/CommandLineTools/usr/bin/make generate-fhe-keys
ghcr.io/zama-ai/kms-service-dev:v0.7.1
v0.7.1: Pulling from zama-ai/kms-service-dev
Digest: sha256:63ef4519b44e03e78a3071fa920536ab938d080367de4059871068cce3ab2ac8
Status: Image is up to date for ghcr.io/zama-ai/kms-service-dev:v0.7.1
ghcr.io/zama-ai/kms-service-dev:v0.7.1

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview ghcr.io/zama-ai/kms-service-dev:v0.7.1
aa2db390ebf70741f214491aaa5685c7bd3ae36371e379c27e6b49527f64d436
Successfully copied 253MB to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res
temp-container
/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res/keys
###########################################################
Keys creation is done, they are stored in /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res/keys
###########################################################
/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/network-fhe-keys
/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/kms-fhe-keys
###########################################################
All the required keys exist in /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/res/keys
###########################################################
Copying PUB/ServerKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/network-fhe-keys, please wait ...
Copying PUB/PublicKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/network-fhe-keys, please wait ...
Copying PRIV/FhePrivateKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/test/new_zama/fhevm-hardhat-template/kms-fhe-keys, please wait ...
[+] Running 7/7
 ✔ Network zama-dev_default              Created                                                                              0.0s 
 ✔ Container zama-dev-fhevm-validator-1  Healthy                                                                             21.0s 
 ✔ Container zama-dev-kms-validator-1    Healthy                                                                              6.0s 
 ✔ Container zama-dev-kms-core-1         Healthy                                                                              6.0s 
 ✔ Container zama-dev-gateway-store-1    Started                                                                              0.5s 
 ✔ Container zama-dev-connector-1        Started                                                                              5.8s 
 ✔ Container zama-dev-gateway-1          Started                                                                             20.8s 
sleep a little to let the docker start up
sleep 5
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"6BDBD3EF60B0313DB08AC9F9F492E69135BBAA914F7F654AE23762A5CD1D212E","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"F7D034BCFA5FB3B4AEEF1CCDBBF2696E952A1953A69113C81C6488ACB890A203","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"1A5A9A04552082C9BE647018933CE483ACCFB78FAB44AF455BC9645CA5C09761","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"36C3F94DE17AA00A59304D8A5BB08B6022261BFB0F5C8E169714702B627E758A","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"0B288868DD5B21E6522DE1F9A59B8D0A55741AEC7CFB8E1195F904EF69784B1B","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"8CCDE512B054FEB03B08FFE67D376EE029AD18B9C8BB65AA2ABE79460B2FB5C3","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"83189B10838DA41C89261E0A6B447F0BDC1041AF02759A3B8305D196E0D0D6A8","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
Generating typings for: 22 artifacts in dir: types for target: ethers-v6
Successfully generated 56 typings!
Compiled 22 Solidity files successfully (evm target: cancun).
Generating typings for: 3 artifacts in dir: types for target: ethers-v6
Successfully generated 30 typings!
Compiled 4 Solidity files successfully (evm target: cancun).
gatewayContractAddress written to gateway/.env.gateway successfully!
node_modules/fhevm/gateway/lib/PredeployAddress.sol file has been generated successfully.
Generating typings for: 12 artifacts in dir: types for target: ethers-v6
Successfully generated 52 typings!
Compiled 11 Solidity files successfully (evm target: cancun).
ACL address 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0 written successfully!
node_modules/fhevm/lib/ACLAddress.sol file generated successfully!
TFHE Executor address 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8 written successfully!
node_modules/fhevm/lib/FHEVMCoprocessorAddress.sol file generated successfully!
KMS Verifier address 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD written successfully!
node_modules/fhevm/lib/KMSVerifierAddress.sol file generated successfully!
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 15627988082031): insufficient funds: insufficient funds
    at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
    at async SimpleTaskDefinition.action (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/tasks/taskDeploy.ts:31:15)
    at async Environment._runTaskDefinition (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at async Environment.run (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at async main (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 43233740257578): insufficient funds: insufficient funds
    at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
    at async SimpleTaskDefinition.action (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/tasks/taskDeploy.ts:44:16)
    at async Environment._runTaskDefinition (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at async Environment.run (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at async main (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
An unexpected error occurred:

ProviderError: failed to check sender balance: sender balance < tx cost (0 < 26837587634325): insufficient funds: insufficient funds
    at HttpProvider.request (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/providers/http.ts:96:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HardhatEthersSigner.sendTransaction (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async ContractFactory.deploy (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
    at async SimpleTaskDefinition.action (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/tasks/taskDeploy.ts:57:16)
    at async Environment._runTaskDefinition (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at async Environment.run (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at async main (/Users/furkandemirel/test/new_zama/fhevm-hardhat-template/node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/cli/cli.ts:323:7)
privateKey 717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6
ownerAddress 0x305F1F471e9baCFF2b3549F9601f9A4BEafc94e1
GatewayContract was deployed at address:  0xc8c9303Cd7F337fab769686B593B87DC3403E0ce
Account 0x97F272ccfef4026A1F3f0e0E879d514627B84E69 was succesfully added as an gateway relayer

then I clone repo again but I failed all test :/

the logs

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pwd
/Users/furkandemirel/newzama/fhevm-hardhat-template
furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm install
Lockfile is up to date, resolution step is skipped
Packages: +764
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

   ╭──────────────────────────────────────────────────────────────────╮
   │                                                                  │
   │                Update available! 9.9.0 → 9.11.0.                 │
   │   Changelog: https://github.com/pnpm/pnpm/releases/tag/v9.11.0   │
   │                Run "pnpm add -g pnpm" to update.                 │
   │                                                                  │
   │         Follow @pnpmjs for updates: https://x.com/pnpmjs         │
   │                                                                  │
   ╰──────────────────────────────────────────────────────────────────╯

Progress: resolved 764, reused 764, downloaded 0, added 764, done

dependencies:
+ extra-bigint 1.1.18
+ sqlite3 5.1.7

devDependencies:
+ @eslint/js 9.9.0
+ @nomicfoundation/hardhat-chai-matchers 2.0.7
+ @nomicfoundation/hardhat-ethers 3.0.6
+ @nomicfoundation/hardhat-network-helpers 1.0.11
+ @nomicfoundation/hardhat-toolbox 3.0.0
+ @nomicfoundation/hardhat-verify 1.1.1
+ @openzeppelin/contracts 5.0.2
+ @trivago/prettier-plugin-sort-imports 4.3.0
+ @typechain/ethers-v6 0.4.3
+ @typechain/hardhat 8.0.3
+ @types/chai 4.3.17
+ @types/eslint__js 8.42.3
+ @types/fs-extra 9.0.13
+ @types/mocha 10.0.7
+ @types/node 18.19.44
+ @typescript-eslint/eslint-plugin 8.0.1
+ @typescript-eslint/parser 8.0.1
+ chai 4.5.0
+ cross-env 7.0.3
+ dotenv 16.4.5
+ eslint 9.9.0
+ eslint-config-prettier 8.10.0
+ ethers 6.13.2
+ fhevm 0.5.8
+ fhevmjs 0.5.2
+ fs-extra 10.1.0
+ globals 15.9.0
+ hardhat 2.22.8
+ hardhat-deploy 0.12.4
+ hardhat-gas-reporter 1.0.10
+ hardhat-ignore-warnings 0.2.11
+ hardhat-preprocessor 0.1.5
+ lodash 4.17.21
+ mocha 10.7.3
+ prettier 2.8.8
+ prettier-plugin-solidity 1.3.1
+ rimraf 4.4.1
+ solhint 3.6.2
+ solhint-plugin-prettier 0.0.5
+ solidity-coverage 0.8.12
+ ts-generator 0.1.1
+ ts-node 10.9.2
+ typechain 8.3.2
+ typescript 5.5.4
+ typescript-eslint 8.0.1

> @zama-ai/fhevm-hardhat-template@1.0.0 preinstall /Users/furkandemirel/newzama/fhevm-hardhat-template
> node tasks/checkNodeVersion.js

> @zama-ai/fhevm-hardhat-template@1.0.0 postinstall /Users/furkandemirel/newzama/fhevm-hardhat-template
> DOTENV_CONFIG_PATH=./.env.example pnpm typechain

> @zama-ai/fhevm-hardhat-template@1.0.0 typechain /Users/furkandemirel/newzama/fhevm-hardhat-template
> cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain

Compiled 23 Solidity files successfully (evm target: cancun).

Done in 7.3s
furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm test:mock

> @zama-ai/fhevm-hardhat-template@1.0.0 test:mock /Users/furkandemirel/newzama/fhevm-hardhat-template
> hardhat test --network hardhat

Nothing to compile
No need to generate any newer typings.
Generating typings for: 10 artifacts in dir: types for target: ethers-v6
Successfully generated 48 typings!
Compiled 10 Solidity files successfully (evm target: cancun).
Generating typings for: 3 artifacts in dir: types for target: ethers-v6
Successfully generated 38 typings!
Compiled 3 Solidity files successfully (evm target: cancun).
Code of Mocked Pre-compile set at address: 0x000000000000000000000000000000000000005d
gatewayContractAddress written to gateway/.env.gateway successfully!
node_modules/fhevm/gateway/lib/PredeployAddress.sol file has been generated successfully.
ACL address 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0 written successfully!
node_modules/fhevm/lib/ACLAddress.sol file generated successfully!
TFHE Executor address 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8 written successfully!
node_modules/fhevm/lib/FHEVMCoprocessorAddress.sol file generated successfully!
KMS Verifier address 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD written successfully!
node_modules/fhevm/lib/KMSVerifierAddress.sol file generated successfully!
ACL was deployed at address: 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0
TFHEExecutor was deployed at address: 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8
KMSVerifier was deployed at address: 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD
privateKey 717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6
ownerAddress 0x305F1F471e9baCFF2b3549F9601f9A4BEafc94e1
GatewayContract was deployed at address:  0xc8c9303Cd7F337fab769686B593B87DC3403E0ce
Account 0x97F272ccfef4026A1F3f0e0E879d514627B84E69 was succesfully added as an gateway relayer
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

  EncryptedERC20
    1) should mint the contract
    2) should transfer tokens between two users
    3) should not transfer tokens between two users
    4) should be able to transferFrom only if allowance is sufficient

  TestAsyncDecrypt
    5) "before all" hook for "test async decrypt bool"

  0 passing (43ms)
  5 failing

  1) EncryptedERC20
       should mint the contract:
     Error: Transaction reverted: function returned an unexpected amount of data
    at EncryptedERC20.trivialEncrypt (fhevm/lib/Impl.sol:258)
    at EncryptedERC20.asEuint64 (fhevm/lib/TFHE.sol:5521)
    at EncryptedERC20.add (fhevm/lib/TFHE.sol:4695)
    at EncryptedERC20.mint (contracts/EncryptedERC20.sol:46)
    at EdrProviderWrapper.request (node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:433:41)
    at async HardhatEthersSigner.sendTransaction (node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async send (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:313:20)
    at async Proxy.mint (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:352:16)
    at async Context. (test/encryptedERC20/EncryptedERC20.ts:21:25)

  2) EncryptedERC20
       should transfer tokens between two users:
     Error: Transaction reverted: function returned an unexpected amount of data
    at EncryptedERC20.trivialEncrypt (fhevm/lib/Impl.sol:258)
    at EncryptedERC20.asEuint64 (fhevm/lib/TFHE.sol:5521)
    at EncryptedERC20.add (fhevm/lib/TFHE.sol:4695)
    at EncryptedERC20.mint (contracts/EncryptedERC20.sol:46)
    at EdrProviderWrapper.request (node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:433:41)
    at async HardhatEthersSigner.sendTransaction (node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async send (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:313:20)
    at async Proxy.mint (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:352:16)
    at async Context. (test/encryptedERC20/EncryptedERC20.ts:48:25)

  3) EncryptedERC20
       should not transfer tokens between two users:
     Error: Transaction reverted: function returned an unexpected amount of data
    at EncryptedERC20.trivialEncrypt (fhevm/lib/Impl.sol:258)
    at EncryptedERC20.asEuint64 (fhevm/lib/TFHE.sol:5521)
    at EncryptedERC20.add (fhevm/lib/TFHE.sol:4695)
    at EncryptedERC20.mint (contracts/EncryptedERC20.sol:46)
    at EdrProviderWrapper.request (node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:433:41)
    at async HardhatEthersSigner.sendTransaction (node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async send (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:313:20)
    at async Proxy.mint (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:352:16)
    at async Context. (test/encryptedERC20/EncryptedERC20.ts:106:25)

  4) EncryptedERC20
       should be able to transferFrom only if allowance is sufficient:
     Error: Transaction reverted: function returned an unexpected amount of data
    at EncryptedERC20.trivialEncrypt (fhevm/lib/Impl.sol:258)
    at EncryptedERC20.asEuint64 (fhevm/lib/TFHE.sol:5521)
    at EncryptedERC20.add (fhevm/lib/TFHE.sol:4695)
    at EncryptedERC20.mint (contracts/EncryptedERC20.sol:46)
    at EdrProviderWrapper.request (node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:433:41)
    at async HardhatEthersSigner.sendTransaction (node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async send (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:313:20)
    at async Proxy.mint (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/contract.ts:352:16)
    at async Context. (test/encryptedERC20/EncryptedERC20.ts:161:25)

  5) TestAsyncDecrypt
       "before all" hook for "test async decrypt bool":
     Error: Transaction reverted: function returned an unexpected amount of data
    at TestAsyncDecrypt.trivialEncrypt (fhevm/lib/Impl.sol:258)
    at TestAsyncDecrypt.asEbool (fhevm/lib/TFHE.sol:5308)
    at TestAsyncDecrypt.asEbool (fhevm/lib/TFHE.sol:5314)
    at TestAsyncDecrypt.constructor (contracts/TestAsyncDecrypt.sol:35)
    at EdrProviderWrapper.request (node_modules/.pnpm/hardhat@2.22.8_ts-node@10.9.2_@types+node@18.19.44_typescript@5.5.4__typescript@5.5.4/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:433:41)
    at async HardhatEthersSigner.sendTransaction (node_modules/.pnpm/@nomicfoundation+hardhat-ethers@3.0.6_ethers@6.13.2_hardhat@2.22.8_ts-node@10.9.2_@types+node_vkquq6dcbonnprw62xwpjnn4ua/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async ContractFactory.deploy (node_modules/.pnpm/ethers@6.13.2/node_modules/ethers/src.ts/contract/factory.ts:111:24)
    at async Context. (test/gatewayDecrypt/testAsyncDecrypt.ts:18:21)

╭───────────────────────────────────────────────────────╮
│                                                       │
│   New Hardhat release available! 2.22.8 -> 2.22.12.   │
│                                                       │
│   Changelog: https://hardhat.org/release/2.22.12      │
│                                                       │
│   Run "pnpm install hardhat@latest" to update.        │
│                                                       │
╰───────────────────────────────────────────────────────╯
 ELIFECYCLE  Command failed with exit code 5.
jatZama commented 2 months ago

I managed to run successfully all tests, both in regular local node fhevm mode, as well as in mocked mode, on a clean instance of a Ubuntu VM, as well as on my Mac OS M3. And I am still unable to reproduce any of the issues you mentionned. Btw something looks strange with your Node.js version, I see in your logs this message when you run pnpm test:mock : bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?). Did you try what is suggested in the logs, i.e npm run build? Another question: did you modify the .env file, or just did cp .env.example .evn (I suggest you just copy original example at first before modifying it)?

jatZama commented 2 months ago

Hi @furkandemireleng I noticed your error was due to the fact that you changed the default mnemonic phrase inside your .env file. I just pushed a fix on this repo, now you can use and test in mocked mode even when using a custom mnemonic phrase or custom private keys. Notice however that for some reason, I only partially solved the issue when NOT using mocked mode, ie only initial deployment is fixed, but I am still getting Gateway error when testing in this case. I spent a bit too much time trying to solve this, but I think this is a limitation of current KMS docker image, which will be solved in next release.

So currently you have two choices: 1/ Either you reuse default values inside if .env file , meaning you do cp .env.example .env: in this case you could use either the real local fhevm node and tests : ie pnpm fhevm:start then pnpm test, or either use succesfully mocked mode for testing : pnpm test:mock (this is recommended anyways for devX) 2/ If you really want to use a custom .env with your own mnemonic phrase/private keys, then this only work in mocked mode : pnpm test:mock.

Don't forget to pull latest changes from main branch which I have just updated if you want to use a custom .env file and to also redo pnpm install first, before doing new tests on your machine.

jatZama commented 2 months ago

Hello @furkandemireleng I have good news: I just pushed another fix which will let now use even the real fhevm node (non-mocked mode) with any custom .env file you want. So you can now pull latest changes from main branch and do pnpm i, then use your own mnemonic and private keys inside the .env file , and then run the real tests with pnpm fhevm:start then pnpm test. Of course, mocked mode is also still supported as well with any value you put in .env, via pnpm test:mocked. If you confirm this solves all your issues I would like to close this issue asap. Thanks.

furkandemireleng commented 2 months ago

Hi @jatZama ! Yes ! It solves. When I pull them make start

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm fhevm:start

> @zama-ai/fhevm-hardhat-template@1.0.0 fhevm:start /Users/furkandemirel/newzama/fhevm-hardhat-template
> ./scripts/precomputeAddresses.sh && ./scripts/rewrite-docker-compose.sh && make run-full && ./scripts/fund_test_addresses_docker.sh && ./launch-fhevm.sh

ACL address 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0 written successfully!
node_modules/fhevm/lib/ACLAddress.sol file generated successfully!
TFHE Executor address 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8 written successfully!
node_modules/fhevm/lib/FHEVMCoprocessorAddress.sol file generated successfully!
KMS Verifier address 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD written successfully!
node_modules/fhevm/lib/KMSVerifierAddress.sol file generated successfully!
gatewayContractAddress written to gateway/.env.gateway successfully!
node_modules/fhevm/gateway/lib/PredeployAddress.sol file has been generated successfully.
Successfully created .env.docker with the aggregated environment variables.
Processed docker-compose/docker-compose-full.yml.template and wrote result to docker-compose/docker-compose-full.yml
/Library/Developer/CommandLineTools/usr/bin/make generate-fhe-keys
ghcr.io/zama-ai/kms-service-dev:v0.7.1
v0.7.1: Pulling from zama-ai/kms-service-dev
Digest: sha256:63ef4519b44e03e78a3071fa920536ab938d080367de4059871068cce3ab2ac8
Status: Image is up to date for ghcr.io/zama-ai/kms-service-dev:v0.7.1
ghcr.io/zama-ai/kms-service-dev:v0.7.1

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview ghcr.io/zama-ai/kms-service-dev:v0.7.1
9582e182637b181e7f63a65fec307c384605c2dcd87018147000b4e85689b21e
Successfully copied 253MB to /Users/furkandemirel/newzama/fhevm-hardhat-template/res
temp-container
/Users/furkandemirel/newzama/fhevm-hardhat-template/res/keys
###########################################################
Keys creation is done, they are stored in /Users/furkandemirel/newzama/fhevm-hardhat-template/res/keys
###########################################################
/Users/furkandemirel/newzama/fhevm-hardhat-template/network-fhe-keys
/Users/furkandemirel/newzama/fhevm-hardhat-template/kms-fhe-keys
###########################################################
All the required keys exist in /Users/furkandemirel/newzama/fhevm-hardhat-template/res/keys
###########################################################
Copying PUB/ServerKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/newzama/fhevm-hardhat-template/network-fhe-keys, please wait ...
Copying PUB/PublicKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/newzama/fhevm-hardhat-template/network-fhe-keys, please wait ...
Copying PRIV/FhePrivateKey/408d8cbaa51dece7f782fe04ba0b1c1d017b1088 to /Users/furkandemirel/newzama/fhevm-hardhat-template/kms-fhe-keys, please wait ...
[+] Running 6/6
 ✔ Container zama-dev-kms-validator-1    Healthy                                                                                              21.0s 
 ✔ Container zama-dev-kms-core-1         Healthy                                                                                              21.0s 
 ✔ Container zama-dev-gateway-store-1    Running                                                                                               0.0s 
 ✔ Container zama-dev-connector-1        Running                                                                                               0.0s 
 ✔ Container zama-dev-fhevm-validator-1  Healthy                                                                                              41.1s 
 ✔ Container zama-dev-gateway-1          Started                                                                                              31.0s 
sleep a little to let the docker start up
sleep 5
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"265DE76C27243D9A03C18B3A4C0F730BB469BAD52D7B024C54E30997D21E3C1F","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"BBF1D698918DB4C2A7F73FFF9E997920ACFC18F046734441A645B7969FFD10DE","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"8634E6EF771FBE8B21E2935F89ED9F0B845B00F1A43B86C1E416D9ACEFF14128","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"60AE30BEB209D4E4CED467F785ED5090077938391DF0D2B2714FFA21BF0277D3","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"547F91789F068EE212D7E7A27AC2E364693531CC91132FB6C17B82B51573EE9E","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"86B848FF420EE564BC5FDA36A77413C5252FD825CDBB1E55F79C78D8CBB81FDC","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"A38A2E2780B48582C107A62E423C20FD77467C67A4D13114CBB8EB602A956026","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"0789E442BA21F7D508DEFDB2351885C6335CED3582C3C5A257DCFC4616D2920E","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
INFO: global keys loaded from: /root/.ethermintd/zama/keys/network-fhe-keys
INFO: global keys are initialized automatically using FHEVM_GO_KEYS_DIR env variable
{"height":"0","txhash":"2C91BEE94DBC3B4A08551CE7BF23CAAA477B44C3A3C610AB28A8DA51F95FE21D","codespace":"","code":0,"data":"","raw_log":"[]","logs":[],"info":"","gas_wanted":"0","gas_used":"0","tx":null,"timestamp":"","events":[]}
Generating typings for: 24 artifacts in dir: types for target: ethers-v6
Successfully generated 58 typings!
Compiled 25 Solidity files successfully (evm target: cancun).
Generating typings for: 10 artifacts in dir: types for target: ethers-v6
Successfully generated 50 typings!
Compiled 10 Solidity files successfully (evm target: cancun).
Generating typings for: 3 artifacts in dir: types for target: ethers-v6
Successfully generated 40 typings!
Compiled 4 Solidity files successfully (evm target: cancun).
ACL was deployed at address: 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0
TFHEExecutor was deployed at address: 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8
KMSVerifier was deployed at address: 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD
privateKey 717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6
ownerAddress 0x305F1F471e9baCFF2b3549F9601f9A4BEafc94e1
GatewayContract was deployed at address:  0xc8c9303Cd7F337fab769686B593B87DC3403E0ce
Account 0x97F272ccfef4026A1F3f0e0E879d514627B84E69 was succesfully added as an gateway relayer

then I made a mock

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm test:mock

> @zama-ai/fhevm-hardhat-template@1.0.0 test:mock /Users/furkandemirel/newzama/fhevm-hardhat-template
> hardhat test --network hardhat

gatewayContractAddress written to gateway/.env.gateway successfully!
node_modules/fhevm/gateway/lib/PredeployAddress.sol file has been generated successfully.
ACL address 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0 written successfully!
node_modules/fhevm/lib/ACLAddress.sol file generated successfully!
TFHE Executor address 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8 written successfully!
node_modules/fhevm/lib/FHEVMCoprocessorAddress.sol file generated successfully!
KMS Verifier address 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD written successfully!
node_modules/fhevm/lib/KMSVerifierAddress.sol file generated successfully!
Nothing to compile
No need to generate any newer typings.
Generating typings for: 10 artifacts in dir: types for target: ethers-v6
Successfully generated 48 typings!
Compiled 10 Solidity files successfully (evm target: cancun).
Generating typings for: 3 artifacts in dir: types for target: ethers-v6
Successfully generated 38 typings!
Compiled 4 Solidity files successfully (evm target: cancun).
Code of Mocked Pre-compile set at address: 0x000000000000000000000000000000000000005d
ACL was deployed at address: 0xf162A696Ea1441D1250DFf40f37694Ea3284Aab0
TFHEExecutor was deployed at address: 0x8632ae1E429F0BB3897d49937E0d78B999ac4Db8
KMSVerifier was deployed at address: 0x39af75d7870A3067286c4EeD89B47cf56bdE4daD
privateKey 717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6
ownerAddress 0x305F1F471e9baCFF2b3549F9601f9A4BEafc94e1
GatewayContract was deployed at address:  0xc8c9303Cd7F337fab769686B593B87DC3403E0ce
Account 0x97F272ccfef4026A1F3f0e0E879d514627B84E69 was succesfully added as an gateway relayer
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

  EncryptedERC20
    ✔ should mint the contract (55ms)
    ✔ should transfer tokens between two users (181ms)
    ✔ should not transfer tokens between two users (151ms)
    ✔ should be able to transferFrom only if allowance is sufficient (490ms)

  TestAsyncDecrypt
gas paid by relayer (fulfil tx) :  93486842611000n
gas paid by user (request tx) :  168008113618042n
    ✔ test async decrypt bool (290ms)
11:59:59 PM - Fulfilled decrypt on block 25 (requestID 1)
92346846812262n
    ✔ test async decrypt uint4 (258ms)
11:59:59 PM - Fulfilled decrypt on block 28 (requestID 2)
    ✔ test async decrypt uint8 (149ms)
11:59:59 PM - Fulfilled decrypt on block 31 (requestID 3)
    ✔ test async decrypt uint16 (205ms)
11:59:59 PM - Fulfilled decrypt on block 34 (requestID 4)
    ✔ test async decrypt uint32 (163ms)
11:59:59 PM - Fulfilled decrypt on block 37 (requestID 5)
    ✔ test async decrypt uint64 (131ms)
12:00:00 AM - Fulfilled decrypt on block 40 (requestID 6)
    ✔ test async decrypt address (160ms)
12:00:00 AM - Fulfilled decrypt on block 43 (requestID 7)
    ✔ test async decrypt several addresses (153ms)
12:00:00 AM - Fulfilled decrypt on block 46 (requestID 8)
    ✔ test async decrypt mixed (308ms)
12:00:00 AM - Fulfilled decrypt on block 50 (requestID 9)
    ✔ test async decrypt uint64 non-trivial (180ms)
12:00:00 AM - Fulfilled decrypt on block 53 (requestID 10)
    ✔ test async decrypt ebytes256 non-trivial (157ms)
12:00:01 AM - Fulfilled decrypt on block 56 (requestID 11)
    ✔ test async decrypt ebytes256 non-trivial with snapshot [skip-on-coverage] (236ms)
12:00:01 AM - Fulfilled decrypt on block 59 (requestID 12)
    ✔ test async decrypt mixed with ebytes256 (173ms)

  17 passing (4s)

then I make a pnpm test it gives me an error says

Gateway didn't response correctly

logs:

furkandemirel@Furkan-MacBook-Pro fhevm-hardhat-template % pnpm test

> @zama-ai/fhevm-hardhat-template@1.0.0 test /Users/furkandemirel/newzama/fhevm-hardhat-template
> hardhat test

bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

  EncryptedERC20
    ✔ should mint the contract (7548ms)
    ✔ should transfer tokens between two users (18156ms)
    1) should not transfer tokens between two users
    ✔ should be able to transferFrom only if allowance is sufficient (39694ms)

  TestAsyncDecrypt
11:52:39 PM - Fulfilled decrypt on block 54 (requestID 1)
gas paid by relayer (fulfil tx) :  7500000000000000n
gas paid by user (request tx) :  6360095000000n
    ✔ test async decrypt bool (10210ms)
11:52:54 PM - Fulfilled decrypt on block 57 (requestID 2)
7500000000000000n
    ✔ test async decrypt uint4 (10178ms)
11:53:09 PM - Fulfilled decrypt on block 60 (requestID 3)
    ✔ test async decrypt uint8 (10149ms)
11:53:24 PM - Fulfilled decrypt on block 63 (requestID 4)
    ✔ test async decrypt uint16 (10152ms)
11:53:39 PM - Fulfilled decrypt on block 66 (requestID 5)
    ✔ test async decrypt uint32 (10141ms)
11:53:54 PM - Fulfilled decrypt on block 69 (requestID 6)
    ✔ test async decrypt uint64 (9665ms)
11:54:09 PM - Fulfilled decrypt on block 72 (requestID 7)
    ✔ test async decrypt address (10203ms)
11:54:24 PM - Fulfilled decrypt on block 75 (requestID 8)
    ✔ test async decrypt several addresses (10166ms)
11:54:54 PM - Fulfilled decrypt on block 81 (requestID 9)
    ✔ test async decrypt mixed (25111ms)
11:55:09 PM - Fulfilled decrypt on block 84 (requestID 10)
    ✔ test async decrypt uint64 non-trivial (10160ms)
11:55:37 PM - Fulfilled decrypt on block 89 (requestID 11)
    ✔ test async decrypt ebytes256 non-trivial (22807ms)
    ✔ test async decrypt ebytes256 non-trivial with snapshot [skip-on-coverage]
11:56:12 PM - Fulfilled decrypt on block 95 (requestID 12)
    ✔ test async decrypt mixed with ebytes256 (24915ms)

  16 passing (5m)
  1 failing

  1) EncryptedERC20
       should not transfer tokens between two users:
     Error: Gateway didn't response correctly
      at Object.reencrypt (node_modules/.pnpm/fhevmjs@0.5.2_encoding@0.1.13/node_modules/fhevmjs/lib/node.cjs:2712:15)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Context. (test/encryptedERC20/EncryptedERC20.ts:127:26)

 ELIFECYCLE  Test failed. See above for more details.

Thanks for your effort Jat. I hope my answers or logs helped Zama :)

jatZama commented 2 months ago

The last error you got is a known issue with current version of Gateway which is unstable giving flaky results. Next release (end of october) we will publish a more stable gateway service. For now, to solve this, you should either re-run your tests (several times if needed until all your tests pass without the Error: Gateway didn't response correctly), or either just run your tests always in mocked mode. I will close this issue for now, since I could not do anything more on this topic before next release.