Skip to content

Built-in contracts like vm and the create2 factory should be excluded senders in invariants #4163

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
2 tasks done
haydenshively opened this issue Jan 24, 2023 · 2 comments · Fixed by #8118
Closed
2 tasks done
Labels
T-bug Type: bug

Comments

@haydenshively
Copy link

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 (e7ef3c2 2023-01-24T00:14:27.601697Z)

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

When running invariant tests with fail_on_revert = true, one must call excludeSender for all addresses with code. Otherwise you get the following nondescript error:

  [0] 0x0000000000000000000000000000000000000000::fallback() 
    └─ ← ()

Ideally forge would automatically exclude contracts from its randomized sender generation. Barring that, users should be told to exclude the following built-in contracts, since they may be unaware of them:

  • 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D (vm)
  • 0x4e59b44847b379578588920cA78FbF26c0B4956C (create2 factory, not documented in foundrybook afaict)

Arguably this is a feature request, but as far as I'm concerned it's unexpected/unexplained behavior so I'm submitting as a bug.

@haydenshively haydenshively added the T-bug Type: bug label Jan 24, 2023
@mds1
Copy link
Collaborator

mds1 commented Jan 24, 2023

Ideally forge would automatically exclude contracts from its randomized sender generation.

I disagree with this: while a contract can't initiate a tx in reality, a contract can call other contracts, which is important to simulate

I do agree that forge should exclude a few addresses from being senders by default: the VM address, the console address, and the create2 factory address

@haydenshively
Copy link
Author

a contract can call other contracts, which is important to simulate

I agree, but afaict forge is unable to actually simulate that case. When trying to initiate calls from any address with code, it fails with the error I posted above. See #3879

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
T-bug Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants