fix: better tracking of cache entries #138
Merged
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.
Currently, during sparse compilation (and probably in some other cases) we might end up in a situation when cache contains empty entries which can actually produce artifacts when compied.
For example, if A.sol imports B.sol and sparse filter tells us to only compile A.sol, then B.sol will appear in cache (because we have to track its source hash to invalidate A.sol's cache), however, we will erase its output selection when invoking solc, so it will not have any artifacts.
Thus, if compiler is invoked later without sparse filter, it will simply skip compiling B.sol because it will assume that it just does not contain any contract definitions:
compilers/src/cache.rs
Lines 658 to 663 in 4cf7843
Because of that, artifact for B.sol will be missing until the cache is cleared.
The issue is basically that we might have two situations:
This PR adds
seenByCompiler
flag which is set to false by default for all newly created entries and switched when entries are compiled as dirty files (without pruned output selection).