Skip to content

lint: 'reentrancy-events' flags on vm.expectEmit #16662

Description

@wjmelements

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.8.1 Commit SHA: 982849d Build Timestamp: 2026-08-28T17:50:20.499955000Z (1787939420) Build Profile: dist

What version of Foundryup are you on?

foundryup: 1.9.2

What command(s) is the bug in?

forge lint

Operating System

macOS (Intel)

Describe the bug

Here is an example from our codebase:

warning[reentrancy-events]: event emitted after an external call; reentrancy can reorder or fabricate logs that off-chain consumers rely on
    ╭▸ test/UnanimousGovernance.t.sol:220:9
    │
220 │         emit UnanimousGovernance.Rejected(taskId, alice);
    │         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    │
    ╰ help: https://getfoundry.sh/forge/linting/reentrancy-events

Immediate context:

        vm.expectEmit(true, true, false, false, address(harness));
        emit UnanimousGovernance.Rejected(taskId, alice);
        vm.prank(alice);
        harness.vetoRemoveOwner(bob);

It complains because before that we did the external call:

vm.prank(bob);
harness.removeOwner(bob);

So indeed we are emitting an event after an external call. But that external call and emitted event are necessary to set the preconditions to validate the event is emitted in the callee in the subsequent call.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bugType: bugT-needs-triageType: this issue needs to be labelled

    Type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions