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

CIP-0138 array #6749

Open
wants to merge 7 commits into
base: yura/cip-0138-builtin-array
Choose a base branch
from

Conversation

Unisay
Copy link
Contributor

@Unisay Unisay commented Dec 13, 2024

Closes ##6731

@Unisay Unisay self-assigned this Dec 13, 2024
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 1599c6d to 074629d Compare December 13, 2024 11:46
@Unisay Unisay changed the base branch from master to yura/cip-0138-builtin-array December 13, 2024 11:48
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 074629d to e6dad3a Compare December 13, 2024 14:44
@Unisay Unisay added No Changelog Required Add this to skip the Changelog Check and removed Don't look here yet labels Dec 13, 2024
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 5f9e7e1 to 58f219c Compare December 16, 2024 10:54
@Unisay Unisay marked this pull request as ready for review December 16, 2024 10:59
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 58f219c to d48a07a Compare December 16, 2024 11:08
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from d48a07a to 1f4f7cb Compare December 16, 2024 12:52
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 1f4f7cb to 850bb4d Compare December 16, 2024 13:19
@Unisay Unisay force-pushed the yura/cip-0138-builtin-array branch from fe5c0a3 to 2ac9dba Compare December 16, 2024 13:24
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 850bb4d to 19d137e Compare December 16, 2024 13:26
@Unisay Unisay requested a review from ana-pantilie December 16, 2024 13:52
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 19d137e to a10f2fa Compare December 16, 2024 13:55
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from a10f2fa to c3b233f Compare December 16, 2024 13:59
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.

This doesn't implement the builtin functions, right? It just defines them and the compiler recognizes them as builtins, but the evaluator doesn't yet know how to evaluate them. I assume that will be done in a separate commit/PR.

plutus-ledger-api/test/Spec/CostModelParams.hs Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
(program 1.1.0 (force indexArray [I 1, I 2, I 3] 2))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do the elements inside the array have I constructors, while the integer argument to indexArray (2) doesn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Idk, looks like a pretty-printing issue to me

Copy link
Contributor

@kwxm kwxm Jan 2, 2025

Choose a reason for hiding this comment

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

I think there's definitely something wrong there. The UPLC syntax is completely wrong. It should be something like

(program 1.1.0 [[(force (builtin indexArray) (con (array integer) [1,2,3])] (con integer 2)])`

Oh, wait. Maybe it's an array of data, in which case it should be

(program 1.1.0 [[(force (builtin indexArray) (con (array data) [I 1,I 2, I 3])] (con integer 2)])`

(maybe I haven't got the brackets exactly right).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We looked at this example with @bezirg and came to the conclusion that you're expecting "Classical" representation, while golden file uses "Readable" one.

Copy link
Contributor

Choose a reason for hiding this comment

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

while golden file uses "Readable" one.

Why though? I think all (?) of the other UPLC golden files in the repository are in "Classical" form. It's not that important though.

@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from c3b233f to 514b31a Compare December 16, 2024 16:08
@@ -97,6 +97,12 @@ data ParamName =
| FstPair'memory'arguments
| HeadList'cpu'arguments
| HeadList'memory'arguments
| LengthArray'cpu'arguments
Copy link
Member

Choose a reason for hiding this comment

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

New parameters must be appended, not inserted in the middle.

And these names don't seem accurate - e.g., ListToArray is linear, so there needs to be an intercept and a slope. If they aren't accurate, then I'm not sure what the point is adding them at all. @kwxm What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Also these need to be added to V1 and V2 as well.

Copy link
Contributor Author

@Unisay Unisay Dec 17, 2024

Choose a reason for hiding this comment

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

New parameters must be appended, not inserted in the middle.

👍🏼 I wrote a golden test which will fail if this condition is violated

And these names don't seem accurate - e.g., ListToArray is linear, so there needs to be an intercept and a slope. If they aren't accurate, then I'm not sure what the point is adding them at all.

The point is to make build green. Some parameters have to be added, otherwise CI tests fail.

Copy link
Member

Choose a reason for hiding this comment

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

I wrote a golden test which will fail if this condition is violated

How do we update the golden file when new parameters are added?

The point is to make build green. Some parameters have to be added, otherwise CI tests fail.

I'll let @kwxm check whether this is the right thing to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we update the golden file when new parameters are added?

cabal test plutus-ledger-api-test fails if new parameter names were inserted in the middle, not appended.
cabal test plutus-ledger-api-test --test-options --accept updates the golden file.

Copy link
Contributor

Choose a reason for hiding this comment

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

The easiest thing to do would have been to update plutus-tx and plutus-tx-plugin and deal with plutus-ledger-api in a separate PR after the costing gets done. I think it'd all get through CI in that case, although I might be wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

The point is to make build green. Some parameters have to be added, otherwise CI tests fail.

Is that true? If you put new things in futurePV then I think they're not tested. Maybe I'm missing something though: it's difficult to remember how all this works without going through the whole process of adding something.

@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from 48a36dc to 00e6771 Compare December 17, 2024 13:57
@Unisay Unisay requested a review from zliu41 December 17, 2024 13:57
@Unisay Unisay force-pushed the yura/cip-0138-plinth-array branch from ca42326 to a0268bc Compare December 17, 2024 16:22
@Unisay Unisay mentioned this pull request Jan 2, 2025
4 tasks
Copy link
Contributor

@kwxm kwxm left a comment

Choose a reason for hiding this comment

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

The sutff for plutus-tx and plutus-tx-plugin all looks OK (although I think there is a problem with the UPLC syntax in some of the golden tests: I'm not sure why that is becuase it's OK elsewhere). However I'd recommend not committing all of the changes to plutus-ledger-api: I think it's enough to add the new builtins to futurePV and leave everything else unchanged (but stash the updated tests somewhere in case we any them later!). It's not really meaningful to extend the cost model parameters until we know what they're going to be, so it's probably simpler to leave them unchaged for now. We also have to do expModInteger, caseList and caseData as well as the array builtins, and it'd probably be best to do everything at once when all of the costing is finished.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that there' an issue to update these tests. They got a bit broken when we made the interface more general for Conway. Maybe this is a good start!

@@ -84,6 +85,9 @@ clearBuiltinCostModel r = r
, paramFindFirstSetBit = mempty
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll probably have to modify all of this anyway for the next HF, since the cost model will have got bigger again for that. The new bitwise builtins and I think also ripemd_160 should certainly be in it, and maybe some of the other new ones as well.

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

Successfully merging this pull request may close these issues.

4 participants