Open 0xJepsen opened 1 year ago
Able to reproduce with given instructions
forge bind
(ethers) generates bindings with the duplicate struct definitions as reported.
Unfortunately forge bind --alloy
fails to generate with:
Generating bindings for 394 contracts
Error:
expected identifier, found keyword `enum`
cc @DaniPopes + @yash-atreya could be a good setup for stress testing Alloy's binding generation
Created a repo with instructions here to simplify reproduction: https://github.com/zerosnacks/foundry-bug-5847-repro
closing since this is legacy ethers bind
reopen because alloy bind also fails -.-
Confirming this is still an active issue with Alloy, keeping it in the milestone
Updating title to scope to Alloy only
Generating bindings for 525 contracts
Error: expected identifier, found keyword `enum`
cc @yash-atreya / @DaniPopes
This is because one of the generated modules is named enum
which is a keyword in Rust.
The fix is to prefix invalid module names with r#
. We can either do it unconditionally or first check if the identifier is invalid
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (ecf9a10 2023-09-18T00:24:28.742120000Z)
What command(s) is the bug in?
forge bind
Operating System
macOS (Apple Silicon)
Describe the bug
To reproduce the bug run
then in the project root run
and add
foundry-contracts = { path = "lib/optimism/packages/contracts-bedrock/forge-artifacts/bindings" }
to thecargo.toml
at this point the static analyzer will pick up the compile errors in the bindings. but you can verify by attempting to import them to the main file with
use foundry_contracts::l2_output_oracle;
the bindings are mostly correct but generate duplicate struct definitions for the
https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L1/L2OutputOracle.sol
contract that then implicate thehttps://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L1/OptimismPortal.sol
From what i can tell the duplicate structs are in fact identical.
Desired functionality would be for forge bind to not produce codegen that doesn't compile.