As input to debugger, map source files to contract addresses encountered during debug session
Component
Forge
Describe the feature you would like
The title captures it pretty much.
Like when the top-level function of your forge script calls into an external contract you also have the source to, mappings can be checked to put the source into the source window when the execution flow enters it.
Additional context
My current case has me using a script to hit a proxied contract I've upgraded on an anvil fork of a mainnet. I upgraded the implementation on the fork and then fire the script to test a complicated scenario. It would be great if I could debug, with source highlighting, the flow from the script into the upgraded logic (implementation) contract.
related to #3006
I tried adding the functionality from #3006 to the test debugger and it seems like very little changes need to be made to support this, something similar in the script debugger would probably also work.
Seems like the DebuggerArgs sources parameter isn't using the get_compiled_contracts function made in #3006.
https://github.com/foundry-rs/foundry/blob/3e12d889fa0537ab0866b9ef6165bcf371ae03cf/crates/forge/bin/cmd/test/mod.rs#L318-L323
Adding in the call to get_compiled_contracts and using that source output as the base for the local artifact builder seems to solve some of the issue, and I can see source maps for some Etherscan verified contracts, but it's not working consistently. Here's the commit of the changes I made to get bare minimum sources working. Someone who knows more than me might be able to tell me why it's not consistently mapping the instructions to the downloaded sources.
https://github.com/janbro/foundry/commit/4d3a40483d49d6ca4d3585008ca9a8002ee46082#diff-289e6e32b190bdcdd1d4512466e34391afa813e748f99ed7316054a0352e7db8
we are going to track this request in https://github.com/foundry-rs/foundry/issues/5435 going to martk this as dupe, please reopen if you disagree. Thank you!