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

forge script --verify intermittently generates bytecode mismatch #6780

Open
2 tasks done
hensha256 opened this issue Jan 12, 2024 · 4 comments
Open
2 tasks done

forge script --verify intermittently generates bytecode mismatch #6780

hensha256 opened this issue Jan 12, 2024 · 4 comments
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug T-to-investigate Type: to investigate
Milestone

Comments

@hensha256
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (68c3663 2024-01-11T00:37:40.946762000Z)

What command(s) is the bug in?

forge script --verify

Operating System

macOS (Apple Silicon)

Describe the bug

When trying to deploy and verify a contract, all in 1 command, forge sometimes successfully deploys the contract, but then throws and error when verifying:

Details: Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

The exact command being run was:

forge script --broadcast --skip-simulation \
--rpc-url "https://arb1.arbitrum.io/rpc" \
--private-key XX \
--sig 'run()' \
script/deployParameters/DeployArbitrum.s.sol:DeployArbitrum \
--etherscan-api-key XX \
--verify

to deploy Uniswap's UniversalRouter, using solidity 0.8.17, with via-ir enabled. The commit in question is 6a9846bfa6f488404b69128afdcc7522fa34496d.

I encountered this issue on all chains that we tried (Arbitrum, Optimism, Sepolia). We additionally tried from another device to deploy the same commit and the same issue occurred.

I then checked out a different commit of the repo (52be38e407ce07f2e84c7e101673f32e72bd0f09), and the contract was able to deploy and verify with no issues.

The issue is similar in aspects to what people have described in #3507, however the solution that seemed to work for people there was to add viaIR:true to the json output, and verify manually on etherscan. When I tried this, it seems forge already now correct sets viaIR to true in the json - so this solution did not fix my issue.

@lifeofjer
Copy link

I am also having this issue, and have tried every possible resolution from reviewing the foundry repo issues:

  • Polygon Network
  • Custom implementation of the OpenZeppelin ERC721 libraries

forge verify-contract <CONTRACT_ADDRESS_HERE> <CONTRACT_SRC_HERE> --evm-version london --compiler-version v0.8.17+commit.8df45f5f --num-of-optimizations 200 --chain-id 137 --watch --constructor-args <ABI_ENCODED_ARGS_HERE> --etherscan-api-key <ETHERSCAN_API_KEY_HERE> --via-ir

Current foundry version:

forge 0.2.0 (9b73e06 2024-02-22T00:16:42.490626000Z)

@sambacha
Copy link
Contributor

Depending on your foundry.toml configuration, certain options can lead to non-deterministic build output. Below are some settings that help enforce a more deterministic output in building/deploying

[profile.default]

# @see {@link https://github.com/foundry-rs/foundry/issues/4060}
auto_detect_remappings = false
bytecode_hash = "none"
cbor_metadata = false
sparse_mode = false

[profile.default.optimizer_details]
# constantOptimizer = true
yul = true

Important

A bug in Solidity v0.8.13-v0.8.21 causes the viaIR-generated bytecode to differ depending on how the dependencies are imported. For more details, see PaulRBerg's report on Twitter.

@mhxw
Copy link

mhxw commented Apr 2, 2024

Component

组件

Forge

锻造

Have you ensured that all of these are up to date?

您是否确保所有这些都是最新的?

  • Foundry 铸造厂
  • Foundryup 铸造

What version of Foundry are you on?

你用的是什么版本的铸造厂?

forge 0.2.0 (68c3663 2024-01-11T00:37:40.946762000Z)

Forge0.2.0(68c36632024-01-11T00:37:40.946762000Z)

What command(s) is the bug in?

错误出现在哪些命令中?

forge script --verify

伪造脚本,核实

Operating System

操作系统

macOS (Apple Silicon)

苹果硅(Apple Silicon)

Describe the bug

描述一下窃听器

When trying to deploy and verify a contract, all in 1 command, forge sometimes successfully deploys the contract, but then throws and error when verifying:

当尝试部署和验证一个契约时,all in 1命令有时会成功部署契约,但是在验证时会抛出错误:

Details: Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

The exact command being run was:

正在运行的命令是:

forge script --broadcast --skip-simulation \
--rpc-url "https://arb1.arbitrum.io/rpc" \
--private-key XX \
--sig 'run()' \
script/deployParameters/DeployArbitrum.s.sol:DeployArbitrum \
--etherscan-api-key XX \
--verify

to deploy Uniswap's UniversalRouter, using solidity 0.8.17, with via-ir enabled. The commit in question is 6a9846bfa6f488404b69128afdcc7522fa34496d.

在启用 via-ir 的情况下,使用 solid0.8.17部署 Uniswap 的 UniversalRouter。

I encountered this issue on all chains that we tried (Arbitrum, Optimism, Sepolia). We additionally tried from another device to deploy the same commit and the same issue occurred.

我遇到了这个问题,在所有的链,我们尝试(仲裁,乐观主义,塞波利亚)。我们还尝试从另一个设备部署相同的提交,结果发生了同样的问题。

I then checked out a different commit of the repo (52be38e407ce07f2e84c7e101673f32e72bd0f09), and the contract was able to deploy and verify with no issues.

然后我检查了一个不同的回购提交(52be38e407ce07f2e84c7e101673f32e72bd0f09) ,合同能够部署和验证,没有问题。

The issue is similar in aspects to what people have described in #3507, however the solution that seemed to work for people there was to add viaIR:true to the json output, and verify manually on etherscan. When I tried this, it seems forge already now correct sets viaIR to true in the json - so this solution did not fix my issue.

这个问题在某些方面与人们在 # 3507中所描述的相似,但是似乎对人们有效的解决方案是添加 viaIR: true to The json output,并在 etherscanner 上手动验证。当我尝试这个,它似乎锻造现在已经正确设置 viaIR 为真在 json-所以这个解决方案没有解决我的问题。

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (68c3663 2024-01-11T00:37:40.946762000Z)

What command(s) is the bug in?

forge script --verify

Operating System

macOS (Apple Silicon)

Describe the bug

When trying to deploy and verify a contract, all in 1 command, forge sometimes successfully deploys the contract, but then throws and error when verifying:

Details: Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

The exact command being run was:

forge script --broadcast --skip-simulation \
--rpc-url "https://arb1.arbitrum.io/rpc" \
--private-key XX \
--sig 'run()' \
script/deployParameters/DeployArbitrum.s.sol:DeployArbitrum \
--etherscan-api-key XX \
--verify

to deploy Uniswap's UniversalRouter, using solidity 0.8.17, with via-ir enabled. The commit in question is 6a9846bfa6f488404b69128afdcc7522fa34496d.

I encountered this issue on all chains that we tried (Arbitrum, Optimism, Sepolia). We additionally tried from another device to deploy the same commit and the same issue occurred.

I then checked out a different commit of the repo (52be38e407ce07f2e84c7e101673f32e72bd0f09), and the contract was able to deploy and verify with no issues.

The issue is similar in aspects to what people have described in #3507, however the solution that seemed to work for people there was to add viaIR:true to the json output, and verify manually on etherscan. When I tried this, it seems forge already now correct sets viaIR to true in the json - so this solution did not fix my issue.

me too

foundryup: installed - forge 0.2.0 (f625d0f 2024-04-02T00:16:42.810315000Z)
foundryup: installed - cast 0.2.0 (f625d0f 2024-04-02T00:16:42.803795000Z)
foundryup: installed - anvil 0.2.0 (f625d0f 2024-04-02T00:16:42.824772000Z)
foundryup: installed - chisel 0.2.0 (f625d0f 2024-04-02T00:16:42.782965000Z)
[profile.default]
src = 'contracts'
out = 'out'
libs = ['lib']
via_ir = true
solc_version = '0.8.17'
optimizer_runs = 1_000_000
fs_permissions = [{ access = "read", path = "./script/deployParameters/"}]
auto_detect_remappings = false
bytecode_hash = "none"
cbor_metadata = false
sparse_mode = false

[fmt]
line_length = 120
quote_style = 'single'

[profile.lite.optimizer_details.yulDetails]
optimizerSteps = ''

@pegahcarter
Copy link
Contributor

You may have success here migrating to bun.

@zerosnacks zerosnacks added C-forge Command: forge Cmd-forge-script Command: forge script T-to-investigate Type: to investigate labels Jun 27, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug T-to-investigate Type: to investigate
Projects
Status: Todo
Development

No branches or pull requests

6 participants