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 script): --debug doesn't show source code #5435

Open
1 of 2 tasks
Tracked by #927
AmesCornish opened this issue Jul 19, 2023 · 13 comments
Open
1 of 2 tasks
Tracked by #927

bug(forge script): --debug doesn't show source code #5435

AmesCornish opened this issue Jul 19, 2023 · 13 comments
Labels
A-debugger Area: debugger C-forge Command: forge Cmd-forge-script Command: forge script P-normal Priority: normal T-bug Type: bug T-to-investigate Type: to investigate

Comments

@AmesCornish
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

nightly 0e72b71

What command(s) is the bug in?

forge script --debug

Operating System

Linux

Describe the bug

Source code debugging seems to have recently broken. In the current nightly (0e72b71), I can do the following:

foundryup --commit 0e72b71
forge init
forge script --debug script/Counter.s.sol

..and where the source should be, it says "Unknown contract at address 0x5b73...0519"

Earlier versions, for example 288ab2e from about 2 week ago, correctly show and step through the source.

Also, I have not been able to get any recent versions to show source code when stepping into on-chain contracts, even though I've set my ETHERSCAN_API_KEY in env and toml.

@AmesCornish AmesCornish added the T-bug Type: bug label Jul 19, 2023
@gakonst gakonst added this to Foundry Jul 19, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jul 19, 2023
@emo-eth
Copy link
Contributor

emo-eth commented Jul 28, 2023

Seeing this on my end as well.

@Evalir Evalir self-assigned this Jul 28, 2023
@Evalir Evalir added this to the v1.0.0 milestone Jul 28, 2023
@brucexu-eth
Copy link

image image

Same here, with the latest version.

@iFrostizz
Copy link
Contributor

Closing @Evalir ?

@brucexu-eth
Copy link

brucexu-eth commented Sep 17, 2023

Verified, working on my side. Thanks.
image

@block0xhash
Copy link

image
the docs says it should show source code https://book.getfoundry.sh/forge/debugger

@bestselection18
Copy link

I got same issues on my side.
image

@emo-eth
Copy link
Contributor

emo-eth commented Dec 17, 2023

cc @iFrostizz @Evalir, this seemed to be mitigated at the time, but I am frequently (inconsistently) not able to view sourcemap for te actual contract(s) I am testing – the test contract sourcemap works fine, but calls to the actual logic contract show no sourcemap.
Looks like other users are running into this as well.

@iFrostizz
Copy link
Contributor

Hard to say without having a reproducible example @emo-eth

@0xGuybrush
Copy link

I can look to work up a MCVE for this, if useful because we're hitting the same.

I just want to make sure I understand how it's meant to work correctly to rule out any false assumption on my part. So at the moment I'm trying to debug a deployed contract via forking like this:

CONTRACT=<contract-address> forge debug --debug scripts/DebugRemote.s.sol --fork-url $RPC_URL

DebugRemote.s.sol then looks like this:

pragma solidity ^0.8.22;
import {Script} from "forge-std/Script.sol";
import {console2} from "forge-std/console2.sol";

import {MyContract} from "../src/MyContract.sol";

contract DebugRemote is Script {

    address private CONTRACT = vm.envOr("CONTRACT", address(0));

    function run() public {
        require(CONTRACT != address(0), "CONTRACT env var missing");
        MyContract(INFO_CONTRACT).fooBar();
    }
}

When I'm walking through the debugger it shows me the source code for the DebugRemote script itself no problem, but as soon as it steps into fooBar() it says:

Unknown contract at address <contract-address>

MyContract.sol exists in my local repo (though it's not validated on-chain). I've ran a full forge clean && forge build before running the script, and the repo code matches the deployed.

Should forge debug be able to link the source code in this scenario and display it or have I misunderstood?

@emo-eth
Copy link
Contributor

emo-eth commented Feb 9, 2024

#7058 will hopefully resolve some of these issues

@Evalir Evalir removed their assignment Feb 25, 2024
@zerosnacks zerosnacks added A-debugger Area: debugger T-to-reproduce Type: requires reproduction labels Jul 3, 2024
@zerosnacks
Copy link
Member

Hi @0xGuybrush, sorry for the delay. Would be great to have a minimal reproduction of this!

@emo-eth are you still experiencing issues with this since #7111 + #7058?

@0xGuybrush
Copy link

Hi @0xGuybrush, sorry for the delay. Would be great to have a minimal reproduction of this!

Hi @zerosnacks. Yes absolutely! Please check it out here. I've just added a script to the default foundry init project, and then written up steps to reproduce in the README.

Happening still with foundryup as of this morning.

I'm seeing a flow like this:


1. Behaving as expected in the DebugRemote contract itself:

Screenshot 2024-07-03 at 15 36 00

2. Sometimes gives "No source map for contract DebugRemote":

Screenshot 2024-07-03 at 15 36 06

I think that's just for certain opcodes though, then keeps going and shows source again on the DebugRemote contract:

Screenshot 2024-07-03 at 15 36 16

3. Gives error when it drops into deployed Counter contract:

Screenshot 2024-07-03 at 15 36 47

4. Shows source again when it returns to DebugRemote:

Screenshot 2024-07-03 at 15 37 07

Hope this helps, let me know if I can give more details

@zerosnacks
Copy link
Member

Hope this helps, let me know if I can give more details

Awesome! This helps a ton

@zerosnacks zerosnacks added T-to-investigate Type: to investigate and removed T-to-reproduce Type: requires reproduction labels Jul 3, 2024
@zerosnacks zerosnacks self-assigned this Jul 3, 2024
@zerosnacks zerosnacks added C-forge Command: forge Cmd-forge-script Command: forge script labels Jul 26, 2024
@zerosnacks zerosnacks changed the title forge debug doesn't show source code bug(forge script): --debug doesn't show source code Jul 26, 2024
@zerosnacks zerosnacks removed their assignment Oct 29, 2024
@grandizzy grandizzy added the P-normal Priority: normal label Nov 19, 2024
@grandizzy grandizzy removed this from the v1.0.0 milestone Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debugger Area: debugger C-forge Command: forge Cmd-forge-script Command: forge script P-normal Priority: normal T-bug Type: bug T-to-investigate Type: to investigate
Projects
Archived in project
Development

No branches or pull requests

10 participants