Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Misleading Error Message: Could not find target contract #7244

Closed
2 tasks done
timolson opened this issue Feb 27, 2024 · 2 comments · Fixed by #7247
Closed
2 tasks done

Misleading Error Message: Could not find target contract #7244

timolson opened this issue Feb 27, 2024 · 2 comments · Fixed by #7247
Assignees
Labels
T-bug Type: bug

Comments

@timolson
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 (ac80261 2024-02-24T00:17:06.154246094Z)

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

Running forge script MyDeployment.sol fails with the message Error: Could not find target contract MyDeployment even though the file is clearly present and the script contract name is correct.

In my case, the real bug was calling an external library method which had been accidentally marked public/external instead of internal, causing a dynamic linkage failure, and the message "Error: Could not find target contract"

You should be able to reproduce using a library Foo { function foo() public {} } along with a contract which calls Foo.foo() and finally a deployment script which constructs the contract that uses the external lib. If you change the visibility to internal, the static binding / inlining causes the "Could not find target contract" message to go away.

This is the same error message as reported in #3076 but presumably with a different cause/solution.

@timolson timolson added the T-bug Type: bug label Feb 27, 2024
@klkvr klkvr self-assigned this Feb 29, 2024
@klkvr
Copy link
Member

klkvr commented Feb 29, 2024

Will be addressed by #7247

klkvr added a commit to klkvr/foundry that referenced this issue Feb 29, 2024
klkvr added a commit to klkvr/foundry that referenced this issue Mar 2, 2024
klkvr added a commit to klkvr/foundry that referenced this issue Mar 2, 2024
@chad-js
Copy link
Contributor

chad-js commented Mar 4, 2024

I ran into this same error a few days ago. Unsure specifically why, but may also be related to internal/external library usage as I use a few in my contracts as well. I reverted to a commit that I had deployed previously ~2 weeks ago, and I get the error on that commit now as well, so does seems like a forge issue.

I had just ran foundryup before this, which installed nightly-4a91072e326126cd852b9c43f577e98c8e13f84f. After installing an older version of foundry nightly-2cb875799419c907cc3709e586ece2559e6b340e (https://github.com/foundry-rs/foundry/releases), I managed to get my deploy working without issue, so seems like a regression somewhere in forge since then.

klkvr added a commit to klkvr/foundry that referenced this issue Mar 6, 2024
klkvr added a commit to klkvr/foundry that referenced this issue Mar 6, 2024
klkvr added a commit that referenced this issue Mar 8, 2024
* [wip] script refactoring

* execution refactor

* refactor simulation

* wip

* wip

* address #7244

* wip: enum for multi/single sequences

* refactor execution + resume

* wip: refactor verification

* wip: cleaning up

* naming

* wip: clean up

* cleanup ScriptSequence

* fmt

* better rpc tracking

* fix rpc logic + extract states to separate file

* fmt

* some docs

* remove --multi flag mentions

* docs

* checkpoint saves for multichain sequences

* docs + broadcasted renamed into dry_run

* fmt

* Update crates/forge/bin/cmd/script/resume.rs

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>

* fmt

* review fixes

* fmt

* wip: start extracting to separate crate

* Use CoreBuildArgs + skip

* fmt

* review fixes

* review fixes

* remove redundant methods

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants