foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.15k stars 1.69k forks source link

Better error reporting when interacting with undeployed contracts #4141

Open PaulRBerg opened 1 year ago

PaulRBerg commented 1 year ago

Component

Forge

Describe the feature you would like

I have bumped into many EvmError errors that were caused by an attempt to interact with a contract which was either undeployed already or was deployed to a local network and by the time I was making the call, the contract did no longer exist because I had used a fork cheatcode.

I think that this is such a common scenario that it would be extremely helpful (and prevent many angry reports in the Foundry Support group) for Foundry to handle this sort of error more gracefully and display a clearer error, e.g.:

You have attempted to make a call to address 0xCAFE..., but not contract is present there

PaulRBerg commented 1 year ago

Another related use case - calling undeployed library functions.

When library functions are declared as public or external, the library must be deployed separately and then linked before it can be used.

PaulRBerg commented 1 year ago

I keep bumping into this issue every time I make a new deployment which I need to cross-reference in another repository - I forget to bump the block number.

The error message is generic and difficult to reverse engineer:

Screenshot 2023-06-18 at 4 32 26 PM
Evalir commented 1 year ago

sg @PaulRBerg — agreed we could probably improve this error. Will take a stab at this during the next week to see if we can improve this