foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Support for internal function jump trace

Open KuTuGu opened this issue 2 years ago • 3 comments

Component

Cast

Describe the feature you would like

At present, foundry only supports external call trace, which is a black box for internal logic function calls, makes it difficult to debug some intermediate variable values.

Hope to introduce the analysis of JUMP opcode to support the internal function trace.

Additional context

  • Tenderly supports this feature.
  • Some alternatives use foundry AFAIK:
    • vm.etch() + console.log()
    • forge --debug mode

But the alternatives are a little bulky. We need this feature so that we can clearly see all internal and external function calls trace.

KuTuGu avatar Feb 14 '23 12:02 KuTuGu

This would also be useful for forge test. Maybe add another -v.

Right now when I am auditing a contract it is hard to follow the trace and understand which internal functions are called. This especially applies if there are a lot of if cases or otherwise complex control flow.

tonisives avatar Feb 25 '23 01:02 tonisives

This is non trivial since some internal functions get inlined.

onbjerg avatar Feb 25 '23 01:02 onbjerg

Yeah, it's hard to match all function. I wrote a simple demo based on structlog and ast analysis that ignores a large number of unmatched functions.

KuTuGu avatar Apr 06 '23 02:04 KuTuGu

Related WIP PR: https://github.com/foundry-rs/foundry/pull/8222

zerosnacks avatar Jun 25 '24 15:06 zerosnacks