alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
763 stars 135 forks source link

[Bug] sol! macro event signature mismatch #640

Closed bitful-pannul closed 3 months ago

bitful-pannul commented 3 months ago

Component

sol! macro

What version of Alloy are you on?

├── alloy-primitives v0.7.4 │ ├── alloy-rlp v0.3.5 │ │ ├── alloy-rlp-derive v0.3.5 (proc-macro) │ │ ├── alloy-rlp v0.3.5 () ├── alloy-sol-types v0.7.4 │ ├── alloy-primitives v0.7.4 () │ ├── alloy-sol-macro v0.7.4 (proc-macro) │ │ ├── alloy-sol-macro-expander v0.7.4 │ │ │ ├── alloy-sol-macro-input v0.7.4 │ │ ├── alloy-sol-macro-input v0.7.4 () │ ├── alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) │ │ ├── alloy-primitives v0.7.4 () │ ├── alloy-primitives v0.7.4 () │ ├── alloy-rpc-types v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) │ │ ├── alloy-consensus v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) │ │ │ ├── alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) │ │ │ │ ├── alloy-primitives v0.7.4 () │ │ │ │ ├── alloy-rlp v0.3.5 () │ │ │ │ ├── alloy-serde v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) │ │ │ │ │ ├── alloy-primitives v0.7.4 () │ │ │ ├── alloy-primitives v0.7.4 () │ │ │ ├── alloy-rlp v0.3.5 () │ │ │ ├── alloy-serde v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) () │ │ ├── alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) () │ │ ├── alloy-genesis v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) │ │ │ ├── alloy-primitives v0.7.4 () │ │ │ ├── alloy-serde v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) () │ │ ├── alloy-primitives v0.7.4 () │ │ ├── alloy-rlp v0.3.5 () │ │ ├── alloy-serde v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) () │ │ ├── alloy-sol-types v0.7.4 () │ ├── alloy-transport v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) │ │ ├── alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy.git?rev=cad7935#cad7935d) (*)

Operating System

macOS (Apple Silicon)

Describe the bug

I'm trying to use the sol! macro to get signature hashes for events, but it seems having the same name for 2 different events messes with the hashes of both:

sol! {
    event TestEvent(bytes32 indexed one);
    event TestEvent(bytes32 indexed one, bytes32 indexed two);
}

main() {
    println!("test1: {:?}", TestEvent_0::SIGNATURE_HASH);
    println!("test2: {:?}", TestEvent_0::SIGNATURE_HASH);
}

this leads to 0x4126a29fd17029d376521f62e26c90187da40445c02353770fc7f104fdcf4aad and 0x5605e19697b8c6a8f1030e73a4c1ee8f95910ba367148f89949f77cb79d3d5ce

whereas removing the second TestEvent and taking the first's signature yields the correct one: 0x2d87364d1542bf89b684ede9ddff45aed45971c6f05deaca687bd3d1b6caf1c3