-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix bugs and improve tracing #22
Conversation
It would be nice to know what the bugs were. Also needs to be updated to current |
@@ -88,7 +90,7 @@ mkProgrammableLogicMinting :: ClosedTerm (PAsData PCredential :--> PAsData PCurr | |||
mkProgrammableLogicMinting = plam $ \programmableLogicBase nodeCS mintingLogicCred ctx -> P.do | |||
ctxF <- pletFields @'["txInfo", "redeemer", "scriptInfo"] ctx | |||
infoF <- pletFields @'["referenceInputs", "outputs", "mint", "wdrl"] ctxF.txInfo | |||
let red = punsafeCoerce @_ @_ @PSmartTokenMintingAction (pto ctxF.redeemer) | |||
let red = punsafeCoerce @_ @_ @(PAsData PSmartTokenMintingAction) (pto ctxF.redeemer) |
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.
Bug 1. This type is actually data encoded but it was unsafeCoerced into non-data encoding.
@@ -109,12 +111,12 @@ mkProgrammableLogicMinting = plam $ \programmableLogicBase nodeCS mintingLogicCr | |||
# plam (pfstBuiltin #) | |||
# pto (pfromData infoF.wdrl) | |||
|
|||
pmatch red $ \case | |||
pmatch (pfromData red) $ \case |
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.
Because it is data encoded we need to use fromData to apply pasInt to get the underlying integer to branch on.
, phasUTxO # oref # infoF.inputs | ||
[ ptraceInfoIfFalse "token name mismatch" $ ownTokenName #== pprotocolParamsTokenData | ||
, ptraceInfoIfFalse "incorrect minted amount" $ ownNumMinted #== pconstantData 1 | ||
, ptraceInfoIfFalse "init UTxO not present" $ phasUTxO # oref # pfromData infoF.inputs |
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.
Bug 2. This list was data encoded so we should have applied fromData to pasList to convert from BuiltinData to BuiltinList
) | ||
# infoF.referenceInputs | ||
# pfromData infoF.referenceInputs |
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.
Same here
@@ -188,8 +154,12 @@ isHeadNode = plam $ \node -> | |||
|
|||
isTailNode :: ClosedTerm (PAsData PDirectorySetNode :--> PBool) | |||
isTailNode = plam $ \node -> | |||
pfield @"next" # node #== pemptyCSData | |||
pfield @"next" # node #== ptailNextData |
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.
Bug 3. isTail should check that next is the tail currency symbol (highest possible lexographic CS).
Ok thanks! |
closed in-favor of #33 |
Addressed a few bugs in the onchain code and improved tracing.