-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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: forc-test predicate logging #6996
base: master
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #6996 will not alter performanceComparing Summary
|
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.
Nice one! This looks good to me in general we should probably make log_generation
flag true in debug build profile by default which i left as a comment as well.
Also we should consider renaming the this flag in my opinion. Because logs are already being generated for other program kinds other than predicates without this flag. And users might end up mixing this with --logs
in forc-test flags. enable_predicate_logs
or something like this might be more on point (while being a little verbose, maybe we can find a common ground between this and enable_logs)
Agreed; renamed: 3ec072f |
I think this should be a breaking change? by default logs in predicates were a compile error but if the user does not pass in What do you think @FuelLabs/sway-compiler? Are you guys fine with |
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.
Apart from my changes and question, looks good.
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 we need the docs updated before merging with the build profile flag (enable predicate logging) and general limitations around predicates and logging such as:
- https://docs.fuel.network/guides/intro-to-predicates/debugging-with-scripts/#debugging-with-scripts
- https://docs.fuel.network/docs/forc/manifest_reference/#the-build-profile-section
For first one we might need to contact @calldelegation to see where these docs are hosted.
…n debug build profile
85f7f72
to
64d5b69
Compare
addressed: 64d5b69 |
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, nice work!
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.
Nice one!
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.
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.
Yeap release mode will fail to compile (throws typical error -
Using intrinsic "log" in a predicate is not allowed.
). You can explicitly override this though (even in release mode):[build-profile.release] enable-predicate-logs = true
Okay, this needs to be clearer in my opinion, we should have the error direct the user to a solution (either removing the logs or turning on this option) and making it clear what's happening here.
At the least the error should be updated to tell the truth (that it's allowed under certain circumstances).
I also think we should discuss eliding log predicate invocation in release builds by default instead of erroring out. I'm not sure that's the best behavior, but we should consider it versus having the user modify their source code when building for release. That would likely prove annoying. |
Description
This PR adds support for logging in predicates via the use of the
ECAL
opcode.In the
ECAL
implementation we simply replicate the functionality of theLOGD
instruction - but for predicates.Notes:
enable_predicate_logs
attribute in theBuildProfile
,BuildConfig
, andContext
structs; this needed to be propagated down deep into their_generation
so that the__log
compiler intrinsic could branch based on theenable_predicate_logs
attribute and the predicate programKind
.forc test --logs
andforc test --raw-logs
commands will now output logs for predicates.forc build
will compile the predicate (which contains logs) indebug
mode successfullyforc build
will NOT compile the predicate (which contains logs) inrelease
modeExample
Predicate
> forc test --logs
> forc test --raw-logs
Checklist
Breaking*
orNew Feature
labels where relevant.