Skip to content

bug(bind): all_derives skipped for custom solidity structs #10353

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

Open
2 tasks
sveitser opened this issue Apr 23, 2025 · 1 comment
Open
2 tasks

bug(bind): all_derives skipped for custom solidity structs #10353

sveitser opened this issue Apr 23, 2025 · 1 comment
Labels
C-forge Command: forge Cmd-forge-bind Command: forge bind T-bug Type: bug T-to-reproduce Type: requires reproduction

Comments

@sveitser
Copy link

sveitser commented Apr 23, 2025

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge Version: 1.0.0-nightly Commit SHA: 7a7ad4e Build Timestamp: 2025-04-01T06:03:16.218549398Z (1743487396) Build Profile: maxperf

What version of Foundryup are you on?

No response

What command(s) is the bug in?

forge bind

Operating System

Linux

Describe the bug

Since #10099 forge bind generates extra derives #[derive(Default, Debug, PartialEq, Eq, Hash)] for events, but only if they don't use custom solidity types.

There is an example here

https://github.com/EspressoSystems/espresso-network/blob/e005d4449eb5487f94f7e2cd9629bcf8b5d14c0d/contracts/rust/adapter/src/bindings/staketable.rs#L4659

To reproduce, the affected file above can be generated with

forge bind --skip test --skip script --use "0.8.28" --alloy --alloy-version "0.13.0" --contracts ./contracts/src/ --module --bindings-path contracts/rust/adapter/src/bindings --select "^StakeTable\$" --overwrite --force

in a checkout of https://github.com/EspressoSystems/espresso-network

At least in this case (but probably always?) the custom types also derive all of Default, Debug, PartialEq, Eq, Hash already. So I think so we should be able to derive them.

For example G2Point here: https://github.com/EspressoSystems/espresso-network/blob/87302f0cca4dcffa5a226fcbe55ff5065978a11b/contracts/rust/adapter/src/bindings/staketable.rs#L308

@sveitser sveitser added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Apr 23, 2025
@github-project-automation github-project-automation bot moved this to Backlog in Foundry Apr 23, 2025
@yash-atreya yash-atreya changed the title forge bind: extra derives skipped for custom solidity structs bug(bind): all_derives skipped for custom solidity structs Apr 23, 2025
@yash-atreya yash-atreya added C-forge Command: forge Cmd-forge-bind Command: forge bind T-to-reproduce Type: requires reproduction and removed T-needs-triage Type: this issue needs to be labelled labels Apr 23, 2025
@yash-atreya
Copy link
Member

Issue is a limitiation of the bindings expansion logic in alloy-core.

Currently, its unable derive the builtin traits for types (in this case - event) that are using custom types from a different interface (e.g G2Point) - which in turn uses custom types (e.g BaseField).

Minimal repro:

// external.sol
library External {
    // Custom type
    struct Something {
        // Nested custom type
        AnotherThing a;
    }

    struct AnotherThing {
         uint64 num;
    }
}

// contract.sol - uses External 

import "./external.sol";

contract MyContract {
     // Builtin traits won't be derived for this.
      event EmittedLog(External.Something s);
}

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 T-to-reproduce Type: requires reproduction
Projects
Status: Backlog
Development

No branches or pull requests

2 participants