-
Notifications
You must be signed in to change notification settings - Fork 483
Call trace for failing evaluation via new emitter mode #7178
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
|
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Evaluation/Machine/Cek/EmitterMode.hs
Outdated
Show resolved
Hide resolved
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Evaluation/Machine/Cek/EmitterMode.hs
Outdated
Show resolved
Hide resolved
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Evaluation/Machine/Cek/EmitterMode.hs
Show resolved
Hide resolved
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Evaluation/Machine/Cek/EmitterMode.hs
Outdated
Show resolved
Hide resolved
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 approach looks less invasive, indeed!
Sorry for all the formatting error! |
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Evaluation/Machine/Cek/EmitterMode.hs
Outdated
Show resolved
Hide resolved
Trace: | ||
-> func:test/CallTrace/Spec.hs:78:1-78:4 | ||
func 1 | ||
-> nestedLinear:test/CallTrace/Spec.hs:71:1-71:12 | ||
-> nestedLinear2:test/CallTrace/Spec.hs:72:1-72:13 | ||
-> nestedLinear3:test/CallTrace/Spec.hs:73:1-73:13 | ||
-> nestedLinear4:test/CallTrace/Spec.hs:74:1-74:13 | ||
-> error |
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.
Looks nice, IMO: the direction of calls is clear.
Having a space between the function name and its source location makes it even easier to 👀 scan:
Trace:
-> func (test/CallTrace/Spec.hs @ 78:1-78:4)
func 1
-> nestedLinear (test/CallTrace/Spec.hs @ 71:1-71:12)
-> nestedLinear2 (test/CallTrace/Spec.hs @ 72:1-72:13)
-> nestedLinear3 (test/CallTrace/Spec.hs @ 73:1-73:13)
-> nestedLinear4 (test/CallTrace/Spec.hs @ 74:1-74:13)
-> error
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 don't see a value in having this golden file: what exactly is being tested here?
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 tests that when program got evaluated without failure, there's no enter/exit marker left on the trace log.
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 explanation makes sense to me. Do you mind embedding it into the name of the golden file, e.g.:
successfullEvaluationYieldsNoTraceLog
or something along these lines?
-- FIXME: Variables will miss span information when the module they are defined | ||
-- in is loaded from cache instead of getting compiled. |
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 have recently agreed to avoid leaving orphaned TODO
, FIXME
comments in the code. The best course of action would be:
- Create a github issue, such that a FIXME or TODO work can be a part of our dev process: triaged, assigned to a sprint, assigned to a person ("owned") etc.
- Amend your
FIXME
comment with a link to the issue.
(The "triage" role that you assume this sprint includes work on removing such orphaned comments ;-) )
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.
done #7203
Caused by: error | ||
|
||
Trace: | ||
-> func (test/CallTrace/Spec.hs:78:1-78:4) |
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 encoding :78:1-78:4
confuses me: what does each section mean ?
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.
from line 78 column 1 to line 78 column 4. this is what SrcSpan pretty printer does. I don't really want to change the pretty instance.
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 see!
My first attempt to parse it in the head produced this result:
test/CallTrace/Spec.hs
78
1-78
4
🤣
I think that my mental parser trips over the :
as a separator between the file path (LHS) and SrcSpan
(RHS).
I agree that we don't want to change the way SrcSpan
is printed here,
but we can avoid mixing the same char :
to separate
- File path / Src Span
- Line / Column
I suggested to use @
as a 1. separator before.
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 can't change this without changing Pretty
instances
Just src -> nameStr <> " (" <> show (src ^. srcSpanIso) <> ")"
I think this is okay honestly. This is standard format used by GHC(and other languages as well!), e.g. test/CallTrace/Spec.hs:88:10
module CallTrace.OtherModule where | ||
|
||
import PlutusTx.Prelude | ||
import Prelude () |
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.
import Prelude () |
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.
Again, we need this because we don't have NoImplicitPrelude
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.
Add NoImplicitPrelude
? It seems to be more explicit in its purpose than import Prelude ()
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.
Ah, necessity to add explicitly add NoImplicitPrelude
to make prelude not implicit!
I generally not prefer adding extra language extension, but I don't really mind here.
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.
Left a few comments.
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 stuff, thanks a lot!
closes #7146.
This replaces #7148. Unlike my original PR which made the plugin generate callstack message, this PR uses already existing
profile-all
option and make no addition to plugin. Sinceprofile-all
option gives function entrance and exit, it is possible to just have another EmitterMode that can make call trace from the trace messages.I decided added new machinery just for callstack into plugin while we have
profile-all
which does something similar is unfavorable. This PR is much simpler and doesn't add maintenance burden to the plugin.We can do something more on the emitter: like putting all call traces together. I kept it simple but let me know if there something that can be improved on emitter