-
Notifications
You must be signed in to change notification settings - Fork 41
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
refactor: caching logic #90
Conversation
@@ -708,9 +704,8 @@ mod tests { | |||
let prep = compiler.preprocess().unwrap(); | |||
let cache = prep.cache.as_cached().unwrap(); | |||
// 3 contracts | |||
assert_eq!(cache.dirty_source_files.len(), 3); | |||
assert!(cache.filtered.is_empty()); | |||
assert!(cache.cache.is_empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are now adding entries for dirty files to cache during preprocessing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me, ptal @mattsse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
this makes a lot of sense
Patched foundry-rs/foundry#7334 with this PR branch, will merge after it succeeds |
ae4e864
to
9af80fe
Compare
30bb08e
to
122c9e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great!
clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm as well
missed this in #90 ref https://t.me/foundry_support/52331 after #90 we stopped removing out of scope sources from cache, however, we never validated if they are dirty, this results in invalid cached artifacts in certain cases. with this PR we iterate over all cache entries out of scope of current compiler run, then build graph with them to find if they import any of files marked as dirty.
Currently we are not keeping cache entries for files which were out of scope of compiler (might be dirty or not)
Because of that, when running
forge compile
, then runningforge compile --skip ...
which will filter some artifacts out, and then runningforge compile
again, some artifacts will be recompiled, because--skip
run removed those entries from cache.Solution is to keep those entries in cache (we already silently keep artifacts anyway).