Skip to content

Conversation

DaniPopes
Copy link
Member

Cache entries are keyed by absolute path relative to project root, but it's possible to construct and pass in Sources from a relative path, such as CLI argument in forge lint/forge eip712...

In these cases the path will be relative and will always be a cache miss. This includes the path's imports, which get resolved as relative to the initial path rather than root now with Solar.

Make all paths in Sources absolute when constructing Graph so that this change propagates through the entire compilation process.

I couldn't find a reproducer in today's stable/nightly Foundry, however making config.solar_project() use project() instead of ephemeral_project() will reproduce the behavior explained above.

With this change, solar_project will almost never call to solc.

Cache entries are keyed by absolute path relative to project root,
but it's possible to construct and pass in Sources from a relative
path, such as CLI argument in `forge lint`/`forge eip712`...

In these cases the path will be relative and will always be a cache
miss. This includes the path's imports, which get resolved as relative
to the initial path rather than root now with Solar.

Make all paths in Sources absolute when constructing Graph so that this
change propagates through the entire compilation process.

I couldn't find a reproducer in today's stable/nightly Foundry, however
making `config.solar_project()` use `project()` instead of `ephemeral_project()`
will reproduce the behavior explained above.

With this change, `solar_project` will almost never call to solc.
Comment on lines +403 to +404
// The cache relies on the absolute paths relative to the project root as cache keys.
sources.make_absolute(&paths.root);
Copy link
Member

Choose a reason for hiding this comment

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

ah I believe that makes sense

can't think of any issues this cause

@DaniPopes DaniPopes merged commit 353e85a into main Aug 29, 2025
15 checks passed
@DaniPopes DaniPopes deleted the dani/absolute-sources branch August 29, 2025 16:42
@DaniPopes DaniPopes self-assigned this Sep 1, 2025
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.

2 participants