-
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(forge): enable console logging in invariant handlers #4951
Comments
Agreed would like to see this as well. |
+1 would like to see this |
As brainstormed in person with @gakonst and @lucas-manuel, what we actually want here might be a new cheat |
Would love to flesh this out a tad more @PaulRBerg 👀 |
big fomo inducing sentence 😭 Also curious to hear more though, I don't think I understand the use case or suggestion—why is exiting the campaign early preferable over a standard console log? |
From what I remember in the earlier discussions about adding logs to invariant tests was that it had a big effect on performance, we were trying to think of ways around this. Is there any way to isolate just console.log output rather than the whole stack trace? |
i've been fiddling with this issue today and I've observed this—doing this the "obvious" way (just preserving logs and decoding them later) introduces a huge performance hit. I'm not super sure how a native cheatcode would look, as in the end we've got to recover the logs from the last call and decode them. I might need to think about this a tad more, but I feel that "rerouting" log output might require redesigning how we retrieve logs/traces a bit cc @mattsse |
The problem with the standard calls in invariant campaigns is two-fold:
However, implementing |
Hm isn't this how console logs currently work for fuzz tests though? They only show up for a single run—the last run if all runs pass, or the failed run if a run failed Performance issues make sense, though I'm still not understanding the UX/naming of If that's correct, presumably you'd also want #2985 support? |
You are right. The actual scenario I had in my head was this: You bumped into a failing invariant that you no longer observe, and you want to console log some state in a particular handler function, or at a particular depth.
Yes
No, the invariants campaign will not move to the next run. As I've said above, you would add this
Absolutely |
Forgive my lack of low-level understanding here haha but want to understand where the performance hit is coming from because yeah I think this is true^ Aren't invariants always run without logs and then in the case that they do fail they are re-run on the Also @mds1 @Evalir is there an issue yet for outputting a seed that causes a |
Thanks @PaulRBerg, I think I understand now. So If I'm still misunderstanding, would you mind provide a snippet of how
This is my understanding also
We have #2551 and #2552 for failure persistence, which should cover this use case. It's been a while since I've looked at those so feel free to leave any comments/suggestions there |
Hey all! Ton of discussion on this issue—heads up that we're implementing the requested feature (console log support) on #5488 ; happy to not close the issue if we wanna keep tracking the other requests here |
Yes, but not just before failures - it would be helpful for debugging purposes in general. For example, in Sablier, we are creating up to 100 streams in every given invariant campaign. We might be interested in logging something when this threshold is hit for the first time.
I would say that a performant |
Component
Forge
Describe the feature you would like
It would be useful to be able to use
console2.log
in invariant handlers, e.g.This code does not console log "Hello World" at the moment.
Additional context
No response
The text was updated successfully, but these errors were encountered: