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: --decode-internal (and related flags --flamechart / --flamegraph) only work when optimizer is explicitly turned off #8986

Closed
2 tasks done
akshatmittal opened this issue Sep 30, 2024 · 4 comments · Fixed by foundry-rs/compilers#209
Labels
A-compiler Area: compiler A-config Area: config A-tracing Area: tracing T-bug Type: bug T-to-investigate Type: to investigate
Milestone

Comments

@akshatmittal
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 (9a0f66e 2024-09-26T00:22:17.831423400Z)

What command(s) is the bug in?

No response

Operating System

None

Describe the bug

Any commands that utilizes --decode-internal (including --flamechart and --flamegraph) fail with failed to parse source map: no previous offset if optimizer isn't explicitly turned off.

The command should either throw a more descriptive error asking to disable optimizer or disable it automatically when running the command.

@akshatmittal akshatmittal added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Sep 30, 2024
@zerosnacks zerosnacks added the T-to-investigate Type: to investigate label Sep 30, 2024
@zerosnacks zerosnacks changed the title Decode Internal (and related flags) only work when optimizer is explicitly turned off bug: --decode-internal (and related flags --flamechart / --flamegraph) only work when optimizer is explicitly turned off Sep 30, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Sep 30, 2024
@zerosnacks zerosnacks added A-tracing Area: tracing A-compiler Area: compiler A-config Area: config and removed T-needs-triage Type: this issue needs to be labelled labels Sep 30, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Sep 30, 2024
@zerosnacks zerosnacks self-assigned this Sep 30, 2024
@zerosnacks
Copy link
Member

Hi @akshatmittal thanks for your report

Would you be able to provide a minimal reproduction that throws failed to parse source map: no previous offset or point to a code snippet that does?

It will help us greatly narrow down the issue

@akshatmittal
Copy link
Author

@zerosnacks Sure, here you go: https://github.com/uniswapfoundation/v4-template (I am working on a different codebase, but this starter repo has the same error)

forge test --decode-internal -vvvvv will throw the error I mentioned. (Narrowing to a single test doesn't change the outcome, but here you go anyway forge test --decode-internal --match-test testCounterHooks -vvvvv) Adding optimizer = false to config does work correctly.

@zerosnacks zerosnacks removed their assignment Sep 30, 2024
@zerosnacks zerosnacks moved this from In Progress to Todo in Foundry Oct 2, 2024
@DaniPopes
Copy link
Member

cc @klkvr

@DaniPopes
Copy link
Member

Error location: crates/evm/traces/src/debug/sources.rs:103

fn new(bytecode: ContractBytecodeSome, build_id: String, file_id: u32) -> Result<Self> {
let parse = |b: &Bytecode| {
// Only parse source map if it's not empty.
let source_map = if b.source_map.as_ref().map_or(true, |s| s.is_empty()) {
Ok(None)
} else {
b.source_map().transpose()
};
// Only parse bytecode if it's not empty.
let pc_ic_map = if let Some(bytes) = b.bytes() {
(!bytes.is_empty()).then(|| PcIcMap::new(bytes))
} else {
None
};
source_map.map(|source_map| (source_map, pc_ic_map))
};
let (source_map, pc_ic_map) = parse(&bytecode.bytecode)?;
let (source_map_runtime, pc_ic_map_runtime) = bytecode
.deployed_bytecode
.bytecode
.map(|b| parse(&b))
.unwrap_or_else(|| Ok((None, None)))?;
Ok(Self { source_map, source_map_runtime, pc_ic_map, pc_ic_map_runtime, build_id, file_id })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiler Area: compiler A-config Area: config A-tracing Area: tracing T-bug Type: bug T-to-investigate Type: to investigate
Projects
Archived in project
3 participants