Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Verifying Solidity Libraries on zkSync #516

Open
mshakeg opened this issue Nov 29, 2023 · 3 comments
Open

Issue with Verifying Solidity Libraries on zkSync #516

mshakeg opened this issue Nov 29, 2023 · 3 comments

Comments

@mshakeg
Copy link

mshakeg commented Nov 29, 2023

Description

I am encountering an issue when attempting to verify a Solidity library on the zkSync network using the @matterlabs/hardhat-zksync plugin. While I was able to deploy a Solidity library (MathLib) successfully, the verification process fails with an error indicating a bytecode mismatch. This issue seems specific to the verification of Solidity libraries, as I was able to verify a regular contract (Greeter) without any problems.

Steps to Reproduce

  1. You can either:
  2. Create a Solidity library (MathLib.sol) and a dependent contract (Calculator.sol).

MathLib:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library MathLib {
    function add(uint a, uint b) external pure returns (uint) {
        return a + b;
    }
}

Calculator:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./MathLib.sol";

contract Calculator {
    function addNumbers(uint a, uint b) public view returns (uint) {
        return MathLib.add(a, b);
    }
}
  1. Deploy the MathLib library to the zkSync network: yarn hardhat deploy-zksync:libraries --private-key <private-key>
  2. Attempt to verify the MathLib library: yarn hardhat verify <MathLib address> --contract contracts/MathLib.sol:MathLib. My library was deployed to 0xE6f95768D5BADC7561EC7Fb6BCE2459F0fF69CDc
  3. Observe the following error:
Error in plugin @matterlabs/hardhat-zksync-verify: The address provided as argument contains a contract, but its bytecode doesn't match any of your local contracts.

      Possible causes are:
        - Contract code changed after the deployment was executed. This includes code for seemingly unrelated contracts.
        - A solidity file was added, moved, deleted or renamed after the deployment was executed. This includes files for seemingly unrelated contracts.
        - Solidity compiler settings were modified after the deployment was executed (like the optimizer, target EVM, etc.).
        - The given address is wrong.
        - The selected network is wrong.
@mshakeg
Copy link
Author

mshakeg commented Nov 29, 2023

The Greeter contract was verified automatically as part of the deployment process, it would be great if libraries were also verified automatically as part of yarn hardhat deploy-zksync:libraries

@nikola-bozin-txfusion
Copy link
Contributor

Thanks for the information. We are aware of this issue and we are working together with the backend verification team to resolve it.
As for the automatically verifying libraries as part of yarn hardhat deploy-zksync:libraries, that would mean that our deploy plugin needs to depend on verify plugin, and we don't want that because this would introduce unnecessary dependencies between those plugins.

@Fiifihayford
Copy link

Fiifihayford commented Nov 8, 2024

Is Zk Sync library issue working now because i am still getting an error deploying a contract on zk sync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants