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

Solidity verifier does not accept optimization mode #1072

Closed
monokh opened this issue Feb 14, 2024 · 8 comments · Fixed by #1079
Closed

Solidity verifier does not accept optimization mode #1072

monokh opened this issue Feb 14, 2024 · 8 comments · Fixed by #1079
Labels
bug Something isn't working

Comments

@monokh
Copy link

monokh commented Feb 14, 2024

🐛 Bug Report

📝 Description

Calling the verifier api with a contract compiled using any optimization mode except "3" will not result in the correct compilation from the verifier.

🔄 Reproduction Steps

Compile a contract with zksolc optimizer mode "z"

Use hardhat verifier, manually or on explorer.

🤔 Expected Behavior

Verifier should pass and verify the contract correctly

😯 Current Behavior

Verifier errors: Deployed bytecode is not equal to generated one from given source

🖥️ Environment

Any relevant environment details.

📋 Additional Context

This seems to happen because for building the solc input, the verifier does not pass on optimizerMode like it does for the vyper input:

https://github.com/matter-labs/zksync-era/blob/main/core/bin/contract-verifier/src/verifier.rs#L304

See implemented correctly for vyper: https://github.com/matter-labs/zksync-era/blob/main/core/bin/contract-verifier/src/verifier.rs#L304

📎 Log Output

Error in plugin @matterlabs/hardhat-zksync-verify: Backend verification error: Deployed bytecode is not equal to generated one from given source

ZkSyncVerifyPluginError: Backend verification error: Deployed bytecode is not equal to generated one from given source
@monokh monokh added the bug Something isn't working label Feb 14, 2024
@hypenikkkkk
Copy link

let settings = Settings {
libraries: None,
output_selection: Some(default_output_selection),
optimizer: Optimizer::new(request.req.optimization_used),
is_system: request.req.is_system,
metadata: None,
};

@perekopskiy
Copy link
Contributor

Hi @monokh, thanks for raising it! This a bug indeed and I will prepare a fix soon, but it affects only solidity-single-file verification mode, while solidity-standard-json seems to be working correctly with optimizer modes. AFAIK, hardhat plugin uses only solidity-standard-json so you should be able to verify contract with non-default optimizer mode using plugin

@monokh
Copy link
Author

monokh commented Feb 15, 2024

Hi @monokh, thanks for raising it! This a bug indeed and I will prepare a fix soon, but it affects only solidity-single-file verification mode, while solidity-standard-json seems to be working correctly with optimizer modes. AFAIK, hardhat plugin uses only solidity-standard-json so you should be able to verify contract with non-default optimizer mode using plugin

Thanks for looking into this
You are right, the hardhat plugin is using standard json input.
The way i found this issue is using single solidity file, especially on the zksync explorer and etherscan.
The zksync explorer doesn't support standard json input and the etherscan explorer doesn't allow me to upload because the size of the input (3.2 MB) is above the allowed size (3MB) :/

Yet I am still unable to verify our contract, I have checked that the compiler versions match through the verification payload and build.json
Reproducable example here if you would like to try it: https://github.com/bebop-dex/bebop-jam-contracts?tab=readme-ov-file#deploying-to-zksync

@monokh
Copy link
Author

monokh commented Feb 15, 2024

I should also mention that our contract deploys another contract in the constructor
Does this cause an issue with verification? I believe that i saw an issue somewhere about this

@perekopskiy
Copy link
Contributor

Thanks, it should be enough to investigate, let me come back later after I try it

github-merge-queue bot pushed a commit that referenced this issue Feb 15, 2024
…rification (#1079)

## What ❔

Fixes #1072

## Why ❔

Bug fix

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.
@monokh
Copy link
Author

monokh commented Feb 15, 2024

Thanks, it should be enough to investigate, let me come back later after I try it

Thanks. Here are deployed versions if you'd like to avoid deploying yourself:

They were compiled and deployed using the settings in the repo

Testnet: 0xf496cbaB8205c3426E374281d87f0629D6460365
Mainnet: 0x574d1fcF950eb48b11de5DF22A007703cbD2b129

@perekopskiy perekopskiy reopened this Feb 15, 2024
@monokh
Copy link
Author

monokh commented Feb 15, 2024

sorry had the mainnet adress wrong 😅 I've updated it - correct is 0x574d1fcF950eb48b11de5DF22A007703cbD2b129

@perekopskiy
Copy link
Contributor

@monokh we've found a problem in hardhat verification plugin. Problem was triggered because you are using hardhat-preproccesor plugin. For now please verify contracts compiled with this plugin with no-compile flag, i.e.npx hardhat verify --no-compile ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants