-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(cheatcodes): lock files on reads / writes #11590
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
Conversation
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.
i think this makes sense
Makes sense to me, small nit |
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.
is it important that we flush all data (incl metadata) to disk for this to work? or can we just do File::sync_data
?
good point, yeah, I guess we can omit metadata |
this makes sense however i wonder if we should lock the file instead of syncing during cheatcode execution? this is on stable now so you can just call file.lock() for write, .lock_shared() for read, and .unlock() and should avoid fs |
warning: current MSRV (Minimum Supported Rust Version) is `1.88.0` but this item is stable since `1.89.0`
--> crates/cheatcodes/src/fs.rs:154:14
|
154 | file.lock_shared()?; should I bump? |
yes |
983337d
to
68dfb90
Compare
done, please recheck. |
please update title/description |
* fix(cheatcodes): ensure file sync on vm.writeFile * Consolidate common fs
Motivation
writeFile
cheatcode and then reading withreadFile
cheatcode and assert contentreadFile
issued after several writes in the same file failed witheven if traces were showing write just above the read

forge test
of the specific test in a loop<JSON file>
in traces above masked atfoundry/crates/evm/traces/src/decoder/mod.rs
Line 565 in f60a1d8
Solution
PR Checklist