matter-labs / hardhat-zksync

Apache License 2.0
279 stars 227 forks source link

`@matterlabs/hardhat-zksync-verify` Version `1.7.0`: `Fail - Unable to verify` #1528

Closed pcaversaccio closed 1 week ago

pcaversaccio commented 2 weeks ago

Summary

I upgraded the dependency @matterlabs/hardhat-zksync-verify to the latest version 1.7.0 in my template repository: https://github.com/pcaversaccio/hardhat-project-template-ts/commit/d3a86672c94f895e071879d762d32c10f808442d.

I wanted to test the verification, but it consistently fails. The full log:

~$ pnpm compile

> hardhat-project-template-ts@1.0.0 compile /mnt/c/Dev/Blockchain/hardhat-project-template-ts
> npx hardhat compile && forge build --root . -C contracts/src --optimize --out forge-artifacts

Solidity 0.8.28 is not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly.

Learn more at https://hardhat.org/hardhat-runner/docs/reference/solidity-support

Compiling contracts for ZKsync Era with zksolc v1.5.7 and zkvm-solc v0.8.28-1.0.1
Compiling 3 Solidity files
Generating typings for: 3 artifacts in dir: typechain-types for target: ethers-v6
Successfully generated 20 typings!
Successfully compiled 3 Solidity files
 ·------------------------|--------------------------------|--------------------------------·
 |  Solc version: 0.8.28  ·  Optimizer enabled: true       ·  Runs: undefined               │
 ·························|································|·································
 |  Contract Name         ·  Deployed size (KiB) (change)  ·  Initcode size (KiB) (change)  │
 ·························|································|·································
 |  Greeter               ·                      3.906 ()  ·                      3.906 ()  │
 ·------------------------|--------------------------------|--------------------------------·
[⠃] Compiling...
[⠃] Compiling 27 files with Solc 0.8.28
[⠢] Solc 0.8.28 finished in 3.93s
Compiler run successful!
~$ pnpm deploy:zksynctestnet

> hardhat-project-template-ts@1.0.0 deploy:zksynctestnet /mnt/c/Dev/Blockchain/hardhat-project-template-ts
> npx hardhat deploy-zksync --network zkSyncTestnet --script deploy-zksync.ts

Greeter deployed to: 0x1424e5D9f188DE76b17763e762AAf500a9F940D3

Waiting 30 seconds before beginning the contract verification to allow the block explorer to index the contract...

 ·------------------------|--------------------------------|--------------------------------·
 |  Solc version: 0.8.28  ·  Optimizer enabled: true       ·  Runs: undefined               │
 ·························|································|·································
 |  Contract Name         ·  Deployed size (KiB) (change)  ·  Initcode size (KiB) (change)  │
 ·························|································|·································
 |  Greeter               ·                 3.906 (0.000)  ·                 3.906 (0.000)  │
 ·------------------------|--------------------------------|--------------------------------·
Your verification ID is: rhmgl6vee6fcjpzwuuevnq4xkpsum3dmhvjavnv1fxhp9w9nkh
We tried verifying your contract contracts/src/Greeter.sol:Greeter without including any unrelated one, but it failed.
Trying again with the full solc input used to compile and deploy it.
This means that unrelated contracts may be displayed on the explorer.
 ·------------------------|--------------------------------|--------------------------------·
 |  Solc version: 0.8.28  ·  Optimizer enabled: true       ·  Runs: undefined               │
 ·························|································|·································
 |  Contract Name         ·  Deployed size (KiB) (change)  ·  Initcode size (KiB) (change)  │
 ·························|································|·································
 |  Greeter               ·                 3.906 (0.000)  ·                 3.906 (0.000)  │
 ·------------------------|--------------------------------|--------------------------------·
Your verification ID is: vyypb2dfwnd3icttjp5zagydfgieppfw8fxfftjiwfrymde5ng
Error in plugin @matterlabs/hardhat-zksync-verify: Fail - Unable to verify. Solidity Compilation Error: Standard JSON parsing: missing field `` at line 26 column 7

For more info run Hardhat with --show-stack-traces
 ELIFECYCLE  Command failed with exit code 1.
~$ npx hardhat verify --network zkSyncTestnet --constructor-args arguments.js 0x1424e5D9f188DE76b17763e762AAf500a9F940D3
 ·------------------------|--------------------------------|--------------------------------·
 |  Solc version: 0.8.28  ·  Optimizer enabled: true       ·  Runs: undefined               │
 ·························|································|·································
 |  Contract Name         ·  Deployed size (KiB) (change)  ·  Initcode size (KiB) (change)  │
 ·························|································|·································
 |  Greeter               ·                 3.906 (0.000)  ·                 3.906 (0.000)  │
 ·------------------------|--------------------------------|--------------------------------·
Your verification ID is: cjim8qzjzuiqsy8ive6ndrvn4upss33dshlvcmxgfvuqqxnjr4
We tried verifying your contract contracts/src/Greeter.sol:Greeter without including any unrelated one, but it failed.
Trying again with the full solc input used to compile and deploy it.
This means that unrelated contracts may be displayed on the explorer.
 ·------------------------|--------------------------------|--------------------------------·
 |  Solc version: 0.8.28  ·  Optimizer enabled: true       ·  Runs: undefined               │
 ·························|································|·································
 |  Contract Name         ·  Deployed size (KiB) (change)  ·  Initcode size (KiB) (change)  │
 ·························|································|·································
 |  Greeter               ·                 3.906 (0.000)  ·                 3.906 (0.000)  │
 ·------------------------|--------------------------------|--------------------------------·
Your verification ID is: hazaulpwhd2ztvsfyalcx97q8ix6xx7v1nluehe16gwjf62pyj
 ·------------------------|--------------------------------|--------------------------------·
 |  Solc version: 0.8.28  ·  Optimizer enabled: true       ·  Runs: undefined               │
 ·························|································|·································
 |  Contract Name         ·  Deployed size (KiB) (change)  ·  Initcode size (KiB) (change)  │
 ·························|································|·································
 |  Greeter               ·                 3.906 (0.000)  ·                 3.906 (0.000)  │
 ·------------------------|--------------------------------|--------------------------------·
Your verification ID is: 31114
hardhat-zksync-verify found one or more errors during the verification process:

ZkSyncEtherscan:
Fail - Unable to verify. Solidity Compilation Error: Standard JSON parsing: missing field `` at line 26 column 7

ZkSyncBlockExplorer:
Failed to send contract verification request
 Reason: ZkSyncVerifyPluginError: Deployed bytecode is not equal to generated one from given source
kiriyaga-txfusion commented 1 week ago

Hello @pcaversaccio ,

It appears that Etherscan currently does not support zksolc version 1.5.7, which causes a backend error. We cloned your repository and tested it with version 1.5.6, and everything worked successfully. You can see the verification here: https://sepolia-era.zksync.network/address/0x6b17994de1a3447C95d03af991C67E218ac9B77a#code.

pcaversaccio commented 1 week ago

Hello @pcaversaccio ,

It appears that Etherscan currently does not support zksolc version 1.5.7, which causes a backend error. We cloned your repository and tested it with version 1.5.6, and everything worked successfully. You can see the verification here: https://sepolia-era.zksync.network/address/0x6b17994de1a3447C95d03af991C67E218ac9B77a#code.

Ah interesting! I thought for a while it was me doing something wrong. Can you ping them maybe to add support for zksolc version 1.5.7? I will close this issue as it's not a bug on the plugin side.

pcaversaccio commented 1 week ago

Ah one question: As you can see, there was also the error:

ZkSyncBlockExplorer:
Failed to send contract verification request
 Reason: ZkSyncVerifyPluginError: Deployed bytecode is not equal to generated one from given source

Have you also tested it on the ZKsync explorer? I guess it's also a version issue?

kiriyaga-txfusion commented 1 week ago

Yeah, it seems that the issue was related to the compiler version. It’s working now, and we successfully verified the contract with the new version. https://sepolia.explorer.zksync.io/address/0xaf941b089B396E64cE506B7200328102FC08a85D#contract