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

bug: forge bind --alloy fails in specific contract #8444

Closed
2 tasks done
bluele opened this issue Jul 15, 2024 · 6 comments
Closed
2 tasks done

bug: forge bind --alloy fails in specific contract #8444

bluele opened this issue Jul 15, 2024 · 6 comments
Labels
C-forge Command: forge Cmd-forge-bind Command: forge bind T-bug Type: bug
Milestone

Comments

@bluele
Copy link

bluele commented Jul 15, 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 (5902a6f 2024-07-14T00:21:20.051403320Z)

What command(s) is the bug in?

forge bind --alloy

Operating System

Linux

Describe the bug

Thank you for providing such an amazing tool.

The following error occurred when the command forge bind --alloy was executed in my project:

[⠊] Compiling...
[⠢] Compiling 1 files with Solc 0.8.24
[⠆] Solc 0.8.24 finished in 74.15ms
Compiler run successful!
Generating bindings for 2 contracts
The application panicked (crashed).
Message:  proc-macro-error API cannot be used outside of `entry_point` invocation, perhaps you forgot to annotate your #[proc_macro] function with `#[proc_macro_error]
Location: /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro-error-1.0.4/src/lib.rs:483

This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: __libc_start_call_main<unknown>
      at ./csu/../sysdeps/nptl/libc_start_call_main.h:58
   2: __libc_start_main_impl<unknown>
      at ./csu/../csu/libc-start.c:392

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
[1]    558893 IOT instruction  forge bind --alloy

The relevant contract is here:

// src/Sample.sol
pragma solidity ^0.8.12;

library Height {
    struct Data {
        uint64 revision_number;
        uint64 revision_height;
    }
}

contract Sample {
    struct Data {
        Height.Data height;
    }

    function f(Data calldata m) public {}
}
@bluele bluele added the T-bug Type: bug label Jul 15, 2024
@zerosnacks zerosnacks added Cmd-forge-bind Command: forge bind C-forge Command: forge labels Jul 15, 2024
@zerosnacks zerosnacks changed the title forge bind --alloy fails in specific contract bug: forge bind --alloy fails in specific contract Jul 15, 2024
@zerosnacks
Copy link
Member

cc @yash-atreya + @DaniPopes

@yash-atreya
Copy link
Member

This is due to the structs having the same name in the library and contract i.e Data, changing any one of those fixes this.

pragma solidity ^0.8.12;

library Height {
    struct Info { // Changed name from `Data` to `Info`
        uint64 revision_number;
        uint64 revision_height;
    }
}

contract Sample {
    struct Data {
        Height.Info height;
    }

    function f(Data calldata m) public {}
}

@programskillforverification
Copy link
Contributor

programskillforverification commented Jul 15, 2024

--ethers
          Generate bindings for the `ethers` library, instead of `alloy` (default, deprecated)

This part in document make me confused. It means alloy is deprecated?

@zerosnacks
Copy link
Member

--ethers
          Generate bindings for the `ethers` library, instead of `alloy` (default, deprecated)

This part in document make me confused. It means alloy is deprecated?

--ethers is deprecated (but still default for the time), --alloy will become the default soon, replacing ethers

@bluele
Copy link
Author

bluele commented Jul 16, 2024

This is due to the structs having the same name in the library and contract i.e Data, changing any one of those fixes this.

@yash-atreya Thanks for the workaround suggestion. However, it isn't easy to apply it to my use-case.

@yash-atreya
Copy link
Member

This is no longer an issue with alloy-rs/core#694 included

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-bind Command: forge bind T-bug Type: bug
Projects
None yet
Development

No branches or pull requests

4 participants