foundry
foundry copied to clipboard
bug: invariant test chooses contract senders which are rejected due to EIP-3607
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 (56dc746 2022-08-26T00:07:43.474069Z)
What command(s) is the bug in?
forge test
Operating System
No response
Describe the bug
Using the same test contract as https://github.com/foundry-rs/foundry/issues/2962, sometimes the sender will be a contract chosen from the dictionary. In that case the call reverts with [FAIL. Reason: EvmError: RejectCallerWithCode] due to EIP-3607, similar to https://github.com/foundry-rs/foundry/pull/2090
IMO the ideal solution here is to bypass 3607 since the msg.sender can have code, and this is referring to the fact that tx.origin cannot have code which isn't too relevant for invariant tests.
Yeah implementing the same fix as #2090 here makes sense.
@mattsse can you pls take a look tomorrow on this? should be simple fix and apparently a big issue for invariant users
Can confirm that this is a big pain when testing invariants.
What is the fix until this issue gets fixed? Exclude all known contracts with excludeSender?
Update: the solution is to use targetSender, as Lucas Manuel does in his example-invariants repo.
Though I am not quite sure why this works. Does targetSender act as an allowlist? I have opened an issue in forge-std to document the functions available in InvariantTest.
Looks like #4181 has been merged. Should this issue be closed now?
Update: no, we shouldn't close this issue just yet. I updated Forge via foundryup and removed my targetSender calls, but I am still getting this error:
FAIL. Reason: EvmError: RejectCallerWithCode
it's not on foundryup yet, but I'm cutting a release now manually
Oh, I see, thanks.
@mattsse looks like this is fixed now. I updated via foundryup recently, removed my targetSender call, and my invariant tests passed.