Skip to content

[Bug] Empty Anonymous Events Can Decode Any Event #1038

@cre-mer

Description

@cre-mer

Component

sol-types

What version of Alloy are you on?

v1.0.38

Operating System

macOS (Apple Silicon)

Describe the bug

An empty anonymous event can decode any other event. For example:

sol! {
    event NonAnonymousLog(addres, uint256, bool);
    event AnonymousLog() anonymous;
}

// Execute a transaction that emits `NonAnonymousLog(addres, uint256, bool)` and try decoding the log with `AnonymousLog`
let anonymous_log = tx.decoded_log::<AnonymousLog>(); // This will return `Some`
assert!(anonymous.is_some()); // This will not fail

This does not work if the event has fields. For instance, event AnonymousLog(address) anonymous cannot decode other events. I assume this happens because the empty anonymous event has no topics and no data, so the checks are skipped, which is not the case for a non-empty event.

Not sure whether this behavior is expected or not, but it is not very clear and can cause confusion or bugs in tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions