Skip to content

Conversation

SeungheonOh
Copy link
Collaborator

Changes COOP to use Data backed ledger types.

Some scripts have reduced cost, some increased(!!). This is probably because how scripts are written originally; original scripts pass around many un-deconstructed data and deconstruct those when needed, perhaps this is very expensive here.

@zliu41 Turns out RecordWildCards works perfectly fine with datatypes defined with asData. I was just being delusional.

@SeungheonOh SeungheonOh added the No Changelog Required Add this to skip the Changelog Check label Jul 24, 2025
@SeungheonOh SeungheonOh self-assigned this Jul 24, 2025
Memory: 3_572_506
Term Size: 4_267
Flat Size: 10_061
CPU: 1_189_413_270
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: error
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue why this is. No script logic was changed. 🫠

Copy link
Contributor

github-actions bot commented Jul 24, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://IntersectMBO.github.io/plutus/pr-preview/pr-7235/

Built to branch gh-pages at 2025-07-24 14:30 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@SeungheonOh SeungheonOh requested a review from zliu41 July 28, 2025 15:41
@zliu41 zliu41 requested a review from ana-pantilie August 14, 2025 14:11
Copy link
Contributor

@ana-pantilie ana-pantilie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to try to write the code where you convert between Data and SOP without the conversions. There are many instances of this in the PR, I didn't comment on all of them. Let me know if you need any help with that.

@@ -210,7 +204,7 @@ authMp'
"Must mint at least one $AUTH token:\n"
<> "Must have a specified CurrencySymbol in the Value"
Just tokenNameMap ->
case AssocMap.toList tokenNameMap of
case AssocMap.toSOPList tokenNameMap of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be one of the reasons there is a performance decrease. Data.AssocMap.toSOPList has to traverse the whole map, while the AssocMap.toList doesn't have any runtime cost. Can you avoid using toSOPList here?

Comment on lines +728 to +733
Value . AssocMap.safeFromSOPList . Map.toList . (AssocMap.safeFromSOPList . Map.toList <$>) $
Map.unionsWith
(Map.unionWith (+))
( [ Map.singleton cs (Map.singleton tn q)
| (cs, tokens) <- AssocMap.toList . getValue $ v
, (tn, q) <- AssocMap.toList tokens
| (cs, tokens) <- AssocMap.toSOPList . getValue $ v
, (tn, q) <- AssocMap.toSOPList tokens
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, Data <-> SOP conversions are expensive. Can this be avoided here? You won't be able to use the list comprehension, unfortunately, but there should be a way to write this code using builtins. Let me know if you need help with this and we can take a look together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Changelog Required Add this to skip the Changelog Check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants