-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: vm.pauseTracing
+ vm.resumeTracing
#8696
Merged
Merged
Conversation
This file contains 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
mattsse
requested changes
Aug 20, 2024
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 is reasonable, this feature isn't too invasive and still easy to follow
pedantic doc nits
mattsse
approved these changes
Aug 22, 2024
klkvr
force-pushed
the
klkvr/pause-resume-trace
branch
from
August 26, 2024 10:47
ee8c744
to
d7e087b
Compare
klkvr
force-pushed
the
klkvr/pause-resume-trace
branch
from
August 26, 2024 11:11
fca1e23
to
2209908
Compare
benwjhack
pushed a commit
to CompassLabs/foundry-test
that referenced
this pull request
Sep 11, 2024
* feat: vm.pauseTracing + vm.resumeTracing * clippy * fixes * fix --decode-internal edge case * fmt * clippy + change tracing_inspector return type * update fixture * fix fixture
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
ref foundry-rs/forge-std#505 (comment), and I've also seen a request for this in one of the telegram chats recently (can't find now)
Adds
pauseTracing
andresumeTracing
cheats which allow hiding parts of the call trace.Solution
CheatcodeExecutor
withfn tracing_inspector(&mut self) -> Option<&mut TracingInspector>
allowing to manipulate traces and tracing configuration from cheatcodes. This should also be useful for feat(cheatcode):startDebugTraceRecording
andstopDebugTraceRecording
for ERC4337 testing #8571 and feat(cheatcodes): mark unmatched expectedEmits as unemitted #8686foundry/crates/cheatcodes/src/utils.rs
Lines 11 to 23 in 556eb84
Another approach could be to remove trace nodes and items through a mutable reference, though we're using traces for debugger and gas reports, so keeping an instance of complete trace is useful even if it was partially ignored
type Traces = Vec<(TraceKind, CallTraceArena)>
toVec<(TraceKind, SparsedTraceArena)>
whereSparsedTraceArena
keeps data about ignored traces and when being printed, constructs a copy of call trace arena without ignored items.CheatcodeExecutor::exec_create
to support EOF bytecodeThis already works pretty much reliably, though it messes with
TracingInspector
internals and thus there's at least one edge case I can think of related to--decode-internal
:Such test will result in a panic during printing if run with
--decode-internal
aspauseTracing
would result in end of decoded trace step being removed, causing issues inTraceWriter
We might want to introduce support for this feature on
revm-inspectors
level to address this and to also support more verbose output for ignored traces, e.g.: