-
Notifications
You must be signed in to change notification settings - Fork 486
Evaluation of CompiledCode for testing. #7072
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
base: master
Are you sure you want to change the base?
Conversation
e5242b2
to
51245f0
Compare
51245f0
to
3261543
Compare
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.
Copilot reviewed 13 out of 33 changed files in this pull request and generated no comments.
Files not reviewed (20)
- cabal.project: Language not supported
- nix/project.nix: Language not supported
- plutus-benchmark/common/PlutusBenchmark/Common.hs: Language not supported
- plutus-benchmark/plutus-benchmark.cabal: Language not supported
- plutus-benchmark/script-contexts/test/V1/Spec.hs: Language not supported
- plutus-benchmark/script-contexts/test/V2/Spec.hs: Language not supported
- plutus-benchmark/script-contexts/test/V3/Spec.hs: Language not supported
- plutus-ledger-api/plutus-ledger-api.cabal: Language not supported
- plutus-ledger-api/test-plugin/Spec/Data/MintValue/V3.hs: Language not supported
- plutus-ledger-api/test-plugin/Spec/MintValue/V3.hs: Language not supported
- plutus-ledger-api/test-plugin/Spec/Value/WithCurrencySymbol.hs: Language not supported
- plutus-tx-plugin/plutus-tx-plugin.cabal: Language not supported
- plutus-tx-plugin/test/AssocMap/Properties1.hs: Language not supported
- plutus-tx-plugin/test/AssocMap/Properties2.hs: Language not supported
- plutus-tx-plugin/test/AssocMap/Properties3.hs: Language not supported
- plutus-tx-plugin/test/List/Properties1.hs: Language not supported
- plutus-tx-plugin/test/List/Properties2.hs: Language not supported
- plutus-tx-plugin/test/Plugin/NoTrace/Lib.hs: Language not supported
- plutus-tx-plugin/test/Plugin/NoTrace/Spec.hs: Language not supported
- plutus-tx-plugin/test/ShortCircuit/Spec.hs: Language not supported
64d3e90
to
8f85c13
Compare
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
|
||
module PlutusTx.Test.Golden ( |
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.
The code has been moved here from PlutusTx.Test
without changes.
0900feb
to
a72fb70
Compare
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.
I'll take a closer look soon but I don't like putting this in plutus-tx-testlib
. First, it's a library with utilities for our internal testing, not for the users to test their own code. There may be some overlap but they are not quite the same. Second, it may not be used exclusively for testing - users may depend on it in their own libraries or executables that serve other purposes. I'd just put it in the plutus-tx
package, and call it "PlutusTx.Run" or something like that.
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 PR does multiple things - not just "Evaluation of CompiledCode for testing" but also lots of code reorganization. I find it difficult to review because I wanted to focus on the former, but the latter makes it much harder to do so - for example, "Updated existing tests to evaluate CompiledCode directly" - where is that, exactly?
In the future I'd highly recommend not doing both together.
|
||
```haskell | ||
result :: CodeResult | ||
result = evaluateCompiledCode compiledCode |
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.
The cost model and parameters depend on MajorProtocolVersion
and ledger language version (V1, V2, V3), so I'd expect evaluateCompiledCode
to take them as parameters. It could also take arguments to compiledCode
as a parameter.
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.
I see a trade-off here: on one hand I want to expose the most simple API to the users, and the less decisions they have to make - the better it is. On the other - we want it to be flexible: e.g. users can decide which CEK Parameters to use, but it means that CEK Parameters parameter needs to be exposed.
I decided to hardcode the defaultCekParametersForTesting
thus limiting the function applicability to testing.
From your comment I read that you'd go different route: ask users to chose the CEK parameters, directly or indirectly. I am thinking maybe we can have two functions for both sides of the trade-off...
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.
As I said in a comment above, I don't think running CompiledCode is only useful for testing. Even when someone uses it for testing, it is still important to use the accurate parameters - maybe they are trying to troubleshoot a budget exceeded error, and you can't reproduce it unless you use the correct parameters!
And one may also want to see the budget of their script, or see whether it exceeds the budget limit. None of these can be done unless using the correct parameters.
the less decisions they have to make
The "decision"s are just the PV and language version that one wants to run their script in - two natural numbers - I don't think it's too much to ask.
I am thinking maybe we can have two functions for both sides of the trade-off...
You can make it take Maybe (PV, LV)
. When passed Nothing, don't bother showing the budget in the result, because it won't be meaningful.
True.
I am sorry to hear that it still hard to review: I tried my best splitting changes in smaller meaningful commits for you to review individually.
Benchmarks are updated in this commit: Plugin and Ledger API are in this one:
What is an alternative approach to making a series of dependent changes that you recommend? |
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.
What is an alternative approach to making a series of dependent changes that you recommend?
This is discussed in the contributing guide - you can either open the second PR after the first is merged, or open the second PR against the first PR.
This is much better than trying to carefully organize the commits in a single PR, and asking reviewers to review commit-by-commit. The latter has too many problems:
- Most people don't do this. Often times they prefer to commit and push whenever convenient - e.g., before the lunch break, when they finish their day, etc.
- Going back and altering and earlier commit is non-trivial - it's much easier to add new commits.
- When addressing comments, you could make a new commit that significantly alter the changes introduced in a previous commit. Then if a new reviewer comes in and starts reviewing it commit-by-commit, they'll have to first review the earlier commit, only to realize that the later commit rendered it largely obsolete.
- When merging into master the commits are squashed so you'd get a big master commit.
|
||
```haskell | ||
result :: CodeResult | ||
result = evaluateCompiledCode compiledCode |
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.
As I said in a comment above, I don't think running CompiledCode is only useful for testing. Even when someone uses it for testing, it is still important to use the accurate parameters - maybe they are trying to troubleshoot a budget exceeded error, and you can't reproduce it unless you use the correct parameters!
And one may also want to see the budget of their script, or see whether it exceeds the budget limit. None of these can be done unless using the correct parameters.
the less decisions they have to make
The "decision"s are just the PV and language version that one wants to run their script in - two natural numbers - I don't think it's too much to ask.
I am thinking maybe we can have two functions for both sides of the trade-off...
You can make it take Maybe (PV, LV)
. When passed Nothing, don't bother showing the budget in the result, because it won't be meaningful.
443d2c5
to
63f14c6
Compare
fa14879
to
a37b1ee
Compare
a37b1ee
to
70fe442
Compare
…tusTx.Test.Util.Compiled` to the plutus-tx-testlib.
70fe442
to
e7bc91d
Compare
Closes https://github.com/IntersectMBO/plutus-private/issues/1540
(You might find it easier to review commit-by-commit).
PlutusTx.Test
module into a few smaller sub-modules such that it re-exports functions from sub-modules for backward-compatibility.:PlutusTx.Test.Golden
(golden* functions)PlutusTx.Text.Run.Uplc
(functionality to runPLC
)PlutusTx.Text.Run.Code
(functionality to runCompiledCode
, new)CompiledCode
directly, making them a bit simpler.plutus-tx-test-util
package for several reasons:PlutusTx.Test.Util.Compiled
, its an overkill to create a dedicated package for it.plutus-tx-testlib
package meant to host plutus testing functionality.