Skip to content

fix: read runtime sourcemap strings from deployed bytecode#366

Merged
zerosnacks merged 1 commit intofoundry-rs:mainfrom
ethever:fix/runtime-sourcemap-string-accessor
Apr 9, 2026
Merged

fix: read runtime sourcemap strings from deployed bytecode#366
zerosnacks merged 1 commit intofoundry-rs:mainfrom
ethever:fix/runtime-sourcemap-string-accessor

Conversation

@ethever
Copy link
Copy Markdown
Contributor

@ethever ethever commented Apr 9, 2026

Summary

get_source_map_deployed_str() currently reads the creation bytecode sourcemap instead of the deployed/runtime bytecode sourcemap.

get_source_map_deployed() already uses get_deployed_bytecode(), but the string accessor still uses get_bytecode(). This makes the two runtime accessors disagree and causes downstream consumers that persist the string sourcemap to store the creation map in the runtime slot.

Changes

  • switch get_source_map_deployed_str() to read from get_deployed_bytecode()
  • add a regression test that gives creation and runtime bytecode different sourcemap strings and asserts the runtime string accessor returns the deployed value

Why this matters

Downstream tools can use the parsed runtime sourcemap accessor and get the correct result, while the string accessor currently returns the creation sourcemap instead. This is especially visible when consumers persist the raw runtime sourcemap string and later use it for runtime source lookups.

Testing

  • cargo test -p foundry-compilers deployed_source_map_string_uses_runtime_bytecode
  • cargo check -p foundry-compilers

  - switch get_source_map_deployed_str to read the deployed bytecode sourceMap instead of the creation bytecode sourceMap

  - add a regression test that gives creation and runtime bytecode different sourceMap strings and asserts the runtime accessor returns the deployed value
Copy link
Copy Markdown
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@zerosnacks zerosnacks merged commit 8cac107 into foundry-rs:main Apr 9, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants