-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add trace message codifier #709
base: staging
Are you sure you want to change the base?
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.
Thank you @SeungheonOh , I would really like to see some tests covering this so the users don't discover any issues themselves.
@@ -65,19 +66,23 @@ common c | |||
-Wincomplete-record-updates -Wmissing-deriving-strategies | |||
-Wno-name-shadowing -Wunused-foralls -fprint-explicit-foralls | |||
-fprint-explicit-kinds -Wno-unrecognised-warning-flags | |||
-Wno-missing-export-lists |
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.
Why?
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 is a weird leftover from earlier Plutarch days. Should be removed I think.
errorTagReplacer :: Int -> Text -> Maybe Text | ||
errorTagReplacer n s = | ||
if T.isPrefixOf "ERR:" s | ||
then Just $ "CODE:" <> T.pack (show n) |
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.
Maybe also ERR:1
rather than CODE:1
?
codifyStrings :: (Int -> Text -> Maybe Text) -> Script -> (Script, [(Text, Text)]) | ||
codifyStrings codify (Script (UPLC.Program ann version terms)) = |
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 should return a Map Text Text
not a list?
collectErrorMessages uterm <> foldMap collectErrorMessages uterms | ||
|
||
replaceMessages :: | ||
[(Text, Text)] -> |
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.
Also Map Text Text
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.
Basically I think @bladyjoker beat me to most of the review.
immap :: forall a b. (Int -> a -> Maybe b) -> [a] -> [(a, b)] | ||
immap f xs = go 0 xs |
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.
Were you looking for this perhaps?
My thoughts:
(Feel free to disregard of course, this isn't a "request change" review.) |
This is per @bladyjoker 's request. I see this being very useful. IMO, not having any trace for mainnet script was a huge mistake, at least for Liqwid. Anytime script threw up, it was massive pain to recreate that with scripts with tracing to actually figure out what went wrong. Codifying error messages would save a lot of efforts without not much cost since it will be reference script anyways. As for UTF-8 codes, I think that is a good idea. I change it to support UTF-8 tags. Also, for having this on Plutarch's compile time, this was made to be external tool so that it can be used on already existing scripts as well. Also, deep integration to Plutarch was too much effort; this is small and portable. Maybe if we can get more funding on Plutarch, we can tackle this. |
That makes more sense, but FWIW you should be able to just use the same inputs for the script to figure out why it failed. |
Not really, in case of Liqwid, we'd need to deploy extra sets of scripts which will cost few hundred Ada and make changes to offchain in some annoying way. So, rather, we have this utility that extracts CBOR and input UTXOs in their resolved form into JSON. We import that to Haskell project and run the CEK manually. It is less painful for sure, but still immensely annoying. Not to mention, this is very offchain framework dependent. |
Small utility function to turn long messages into code table.