Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Fix bugs and improve tracing #22

wants to merge 1 commit into from

Conversation

colll78
Copy link
Collaborator

@colll78 colll78 commented Dec 21, 2024

Addressed a few bugs in the onchain code and improved tracing.

@j-mueller
Copy link
Collaborator

It would be nice to know what the bugs were. Also needs to be updated to current main

@@ -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)
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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).

@j-mueller
Copy link
Collaborator

Ok thanks!

@colll78 colll78 closed this Jan 1, 2025
@colll78
Copy link
Collaborator Author

colll78 commented Jan 1, 2025

closed in-favor of #33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants