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

bug(forge clone): generated remapping incorrectly maps to single files on some contracts #8499

Open
1 of 2 tasks
Tracked by #9157
joshstevens19 opened this issue Jul 23, 2024 · 1 comment
Open
1 of 2 tasks
Tracked by #9157
Labels
A-remappings Area: remappings C-forge Command: forge Cmd-forge-clone Command: forge clone P-normal Priority: normal T-bug Type: bug T-to-discuss Type: requires discussion

Comments

@joshstevens19
Copy link

joshstevens19 commented Jul 23, 2024

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 (62cdea8 2024-07-23T00:18:49.756549000Z)

What command(s) is the bug in?

forge clone

Operating System

macOS (Apple Silicon)

Describe the bug

When you try to clone 0x06bdf212c290473dcacea9793890c5024c7eb02c it errors i am guessing it will error for other contracts, this should work out the box i think.

trace:

joshstevens@AMWM-G2136D03XG blah6 % forge clone 0x06bdf212c290473dcacea9793890c5024c7eb02c --etherscan-api-key KEY_HERE --no-commit
Downloading the source code of 0x06bDF212C290473dCACea9793890C5024c7Eb02c from Etherscan...
Initializing /Users/joshstevens/code/blah6...
Installing forge-std in /Users/joshstevens/code/blah6/lib/forge-std (url: Some("https://github.com/foundry-rs/forge-std"), tag: None)
Cloning into '/Users/joshstevens/code/blah6/lib/forge-std'...
remote: Enumerating objects: 2378, done.
remote: Counting objects: 100% (2373/2373), done.
remote: Compressing objects: 100% (845/845), done.
remote: Total 2378 (delta 1579), reused 2200 (delta 1456), pack-reused 5
Receiving objects: 100% (2378/2378), 694.09 KiB | 5.93 MiB/s, done.
Resolving deltas: 100% (1579/1579), done.
    Installed forge-std v1.9.1
    Initialized forge project
Collecting the creation information of 0x06bDF212C290473dCACea9793890C5024c7Eb02c from Etherscan...
[⠊] Compiling...
[⠒] Compiling 14 files with Solc 0.8.19
[⠑] Solc 0.8.19 finished in 610.99ms
Error:
Compiler run failed:
Error (6275): Source "IPrismaCore.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IPrismaCore.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/PrismaOwnable.sol:5:1:
  |
5 | import "IPrismaCore.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "IERC20.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IERC20.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/SafeERC20.sol:6:1:
  |
6 | import "IERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "draft-IERC20Permit.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "draft-IERC20Permit.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/SafeERC20.sol:7:1:
  |
7 | import "draft-IERC20Permit.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "Address.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "Address.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/SafeERC20.sol:8:1:
  |
8 | import "Address.sol";
  | ^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "IPrismaCore.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IPrismaCore.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/SystemStart.sol:5:1:
  |
5 | import "IPrismaCore.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "SafeERC20.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "SafeERC20.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/Vault.sol:5:1:
  |
5 | import "SafeERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "Address.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "Address.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/Vault.sol:6:1:
  |
6 | import "Address.sol";
  | ^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "PrismaOwnable.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "PrismaOwnable.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/Vault.sol:7:1:
  |
7 | import "PrismaOwnable.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "SystemStart.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "SystemStart.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/Vault.sol:8:1:
  |
8 | import "SystemStart.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "IPrismaToken.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IPrismaToken.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
 --> src/Vault.sol:9:1:
  |
9 | import "IPrismaToken.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "IEmissionSchedule.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IEmissionSchedule.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
  --> src/Vault.sol:10:1:
   |
10 | import "IEmissionSchedule.sol";
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "IIncentiveVoting.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IIncentiveVoting.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
  --> src/Vault.sol:11:1:
   |
11 | import "IIncentiveVoting.sol";
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "ITokenLocker.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "ITokenLocker.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
  --> src/Vault.sol:12:1:
   |
12 | import "ITokenLocker.sol";
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "IBoostDelegate.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IBoostDelegate.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
  --> src/Vault.sol:13:1:
   |
13 | import "IBoostDelegate.sol";
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "IBoostCalculator.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
ParserError: Source "IBoostCalculator.sol" not found: File not found. Searched the following locations: "/Users/joshstevens/code/blah6".
  --> src/Vault.sol:14:1:
   |
14 | import "IBoostCalculator.sol";
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

joshstevens@AMWM-G2136D03XG blah6 %
@joshstevens19 joshstevens19 added the T-bug Type: bug label Jul 23, 2024
@joshstevens19 joshstevens19 changed the title forge clone 0x06bdf212c290473dcacea9793890c5024c7eb02c errors forge clone errors on some contracts Jul 23, 2024
@zerosnacks
Copy link
Member

All the files are imported correctly but the generated remapping is invalid:

forge-std/=lib/forge-std/src/
SystemStart.sol/=src/SystemStart.sol/
IBoostDelegate.sol/=src/IBoostDelegate.sol/
ITokenLocker.sol/=src/ITokenLocker.sol/
IEmissionSchedule.sol/=src/IEmissionSchedule.sol/
IPrismaCore.sol/=src/IPrismaCore.sol/
draft-IERC20Permit.sol/=src/draft-IERC20Permit.sol/
IPrismaToken.sol/=src/IPrismaToken.sol/
IIncentiveVoting.sol/=src/IIncentiveVoting.sol/
SafeERC20.sol/=src/SafeERC20.sol/
IBoostCalculator.sol/=src/IBoostCalculator.sol/
Address.sol/=src/Address.sol/
PrismaOwnable.sol/=src/PrismaOwnable.sol/
IERC20.sol/=src/IERC20.sol/
Vault.sol/=src/Vault.sol/

To temporarily work around it remove the remappings and rewrite import "SafeERC20.sol"; as import "./SafeERC20.sol";

Related: #6706

@zerosnacks zerosnacks added the Cmd-forge-clone Command: forge clone label Jul 23, 2024
@zerosnacks zerosnacks changed the title forge clone errors on some contracts bug(forge clone): remapping errors on some contracts Jul 23, 2024
@zerosnacks zerosnacks added the C-forge Command: forge label Jul 23, 2024
@zerosnacks zerosnacks changed the title bug(forge clone): remapping errors on some contracts bug(forge clone): generated remapping incorrectly maps to single files on some contracts Jul 25, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@jenpaff jenpaff added P-normal Priority: normal T-to-discuss Type: requires discussion labels Sep 26, 2024
@zerosnacks zerosnacks added the A-remappings Area: remappings label Oct 22, 2024
@grandizzy grandizzy removed this from the v1.0.0 milestone Feb 4, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-remappings Area: remappings C-forge Command: forge Cmd-forge-clone Command: forge clone P-normal Priority: normal T-bug Type: bug T-to-discuss Type: requires discussion
Projects
Status: Todo
Development

No branches or pull requests

4 participants