This repository was archived by the owner on Apr 20, 2026. It is now read-only.
feat: track and cache context of each compiler invocation#140
Merged
Conversation
mattsse
suggested changes
Jun 10, 2024
Member
mattsse
left a comment
There was a problem hiding this comment.
this makes a lot of sense and this approach works afaict
only have a pedantic nit,
can we do a foundry companion before merging?
Comment on lines
+30
to
+31
| /// A mapping from build_id to [BuildContext]. | ||
| pub type Builds<L> = BTreeMap<String, BuildContext<L>>; |
Member
There was a problem hiding this comment.
I'd prefer a wrapper type for this, just because aliases for maps are not great imo
Member
we can add "Unicode-3.0" to allowed in deny.toml |
mattsse
approved these changes
Jun 11, 2024
This was referenced Jun 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref foundry-rs/foundry#7379
ref foundry-rs/foundry#4981
ref foundry-rs/foundry#2704
The way Solidity assigns
source_ids is simply by order in which sources are passed in compiler input. Thus, if we have two sourcesA.solandB.sol, then on the first (non-cached) compiler run,A.solwill get assigned ID 1 andB.solwill have ID 2.Then, if we change
B.solslightly and recompile, it will be the only source in the input, so it will have ID 1.The same ID collisions are more often appearing on multi-version and multi-compiler builds. After many cached runs such discrepancies result in debugger basically displaying random sources.
This PR adds a way to link an artifact to the build info for input that produced it, thus allowing us to track correct
source_id -> sourcemapping for cached artifacts.I've added
BuildContextwhich is the foundry context we are tracking for each compiler invocation. It is getting inlined intoBuildInfo, and read along with cached artifacts.BuildContexts are indexed by the same IDsBuildInfos are, and eachArtifactIdnow has a reference tobuild_idwhich produced it.Build info now produced on every compiler run, however, it does not include complete input and output unless
project.build_infois true, to avoid overhead while keeping our internal logic working correctly.